The Gaudi Framework
master (bdbe7744)
Toggle main menu visibility
Loading...
Searching...
No Matches
PropertyProxy.cpp
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
#include "
PropertyProxy.h
"
12
13
#include <
GaudiKernel/DataObject.h
>
14
#include <
GaudiKernel/IAlgManager.h
>
15
#include <
GaudiKernel/IChronoStatSvc.h
>
16
#include <
GaudiKernel/IDataProviderSvc.h
>
17
#include <
GaudiKernel/MsgStream.h
>
18
#include <
GaudiKernel/SmartIF.h
>
19
20
DECLARE_COMPONENT
(
PropertyProxy
)
21
22
// Constructor
23
//------------------------------------------------------------------------------
24
PropertyProxy
::
PropertyProxy
( const
std
::
string
&
name
,
ISvcLocator
* ploc ) :
Algorithm
(
name
, ploc ) {
25
//------------------------------------------------------------------------------
26
// Declare remote properties at this moment
27
auto
algMgr =
serviceLocator
()->as<
IAlgManager
>();
28
SmartIF<IProperty>
rAlgP( algMgr->algorithm(
"PropertyAlg"
) );
29
if
( rAlgP ) {
30
m_remAlg
= rAlgP;
// remember it for later
31
declareRemoteProperty
(
"RInt"
, rAlgP,
"Int"
);
32
declareRemoteProperty
(
"String"
, rAlgP );
33
}
else
{
34
warning
() <<
" The 'remote' Algorithm PropertyAlg is not found"
<<
endmsg
;
35
}
36
}
37
38
//------------------------------------------------------------------------------
39
StatusCode
PropertyProxy::initialize
() {
40
if
( !
Algorithm::initialize
() )
return
StatusCode::FAILURE
;
41
42
std::string value(
"empty"
);
43
std::string value1(
"empty"
);
44
45
if
( !this->
getProperty
(
"RInt"
, value ) ) {
warning
() <<
"failed to get property RInt"
<<
endmsg
; }
46
info
() <<
" Got property this.RInt = "
<< value <<
";"
<<
endmsg
;
47
48
info
() <<
" Set property this.RInt = 1001;"
<<
endmsg
;
49
if
( !this->
setProperty
(
"RInt"
, 1001 ) ) {
warning
() <<
"failed to set property RInt"
<< endmsg; }
50
51
this->
getProperty
(
"RInt"
, value ).ignore();
52
info
() <<
" Got property this.RInt = "
<< value <<
";"
<<
endmsg
;
53
if
( value !=
"1001"
) {
error
() <<
"RInt value not what expected"
<<
endmsg
; }
54
55
this->
getProperty
(
"String"
, value ).ignore();
56
m_remAlg
->getProperty(
"String"
, value1 ).ignore();
57
if
( value == value1 ) {
58
info
() <<
" Got property this.String = "
<< value <<
";"
<<
endmsg
;
59
}
else
{
60
error
() <<
" Local property ["
<< value1 <<
"] not equal ["
<< value <<
"]"
<<
endmsg
;
61
}
62
63
return
StatusCode::SUCCESS
;
64
}
65
66
//------------------------------------------------------------------------------
67
StatusCode
PropertyProxy::execute
() {
68
//------------------------------------------------------------------------------
69
info
() <<
"executing...."
<<
endmsg
;
70
71
return
StatusCode::SUCCESS
;
72
}
73
74
//------------------------------------------------------------------------------
75
StatusCode
PropertyProxy::finalize
() {
76
//------------------------------------------------------------------------------
77
info
() <<
"finalizing...."
<<
endmsg
;
78
79
return
StatusCode::SUCCESS
;
80
}
getProperty
const char *PyHelper getProperty(IInterface *p, char *name)
Definition
Bootstrap.cpp:215
setProperty
bool PyHelper setProperty(IInterface *p, char *name, char *value)
Definition
Bootstrap.cpp:211
DataObject.h
IAlgManager.h
IChronoStatSvc.h
IDataProviderSvc.h
MsgStream.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition
MsgStream.h:198
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
PropertyProxy.h
SmartIF.h
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition
CommonMessaging.h:109
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition
CommonMessaging.h:112
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition
CommonMessaging.h:115
Gaudi::Algorithm::Algorithm
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition
Algorithm.h:98
Gaudi::Algorithm::initialize
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition
Algorithm.h:175
Gaudi::Algorithm::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition
Algorithm.cpp:562
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition
Algorithm.cpp:518
IAlgManager
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition
IAlgManager.h:34
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition
ISvcLocator.h:42
PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >::declareRemoteProperty
Gaudi::Details::PropertyBase * declareRemoteProperty(const std::string &name, IProperty *rsvc, const std::string &rname="")
Definition
PropertyHolder.h:133
PropertyProxy
Trivial Algorithm for tutotial purposes.
Definition
PropertyProxy.h:23
PropertyProxy::finalize
StatusCode finalize() override
Definition
PropertyProxy.cpp:75
PropertyProxy::PropertyProxy
PropertyProxy(const std::string &name, ISvcLocator *pSvcLocator)
Constructor of this form must be provided.
Definition
PropertyProxy.cpp:24
PropertyProxy::execute
StatusCode execute() override
Definition
PropertyProxy.cpp:67
PropertyProxy::initialize
StatusCode initialize() override
Three mandatory member functions of any algorithm.
Definition
PropertyProxy.cpp:39
PropertyProxy::m_remAlg
IProperty * m_remAlg
Definition
PropertyProxy.h:34
SmartIF
Small smart pointer class with automatic reference counting for IInterface.
Definition
SmartIF.h:28
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition
StatusCode.h:100
std
STL namespace.
GaudiTestSuite
src
Properties
PropertyProxy.cpp
Generated on
for The Gaudi Framework by
1.17.0