The Gaudi Framework  master (82fdf313)
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
18#include <GaudiKernel/SmartIF.h>
19
21
22// Constructor
23//------------------------------------------------------------------------------
24PropertyProxy::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//------------------------------------------------------------------------------
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
64}
65
66//------------------------------------------------------------------------------
68 //------------------------------------------------------------------------------
69 info() << "executing...." << endmsg;
70
72}
73
74//------------------------------------------------------------------------------
76 //------------------------------------------------------------------------------
77 info() << "finalizing...." << endmsg;
78
80}
const char *PyHelper getProperty(IInterface *p, char *name)
bool PyHelper setProperty(IInterface *p, char *name, char *value)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define DECLARE_COMPONENT(type)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition Algorithm.h:98
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition Algorithm.h:175
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
const std::string & name() const override
The identifying name of the algorithm object.
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition IAlgManager.h:34
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
Gaudi::Details::PropertyBase * declareRemoteProperty(const std::string &name, IProperty *rsvc, const std::string &rname="")
Trivial Algorithm for tutotial purposes.
StatusCode finalize() override
PropertyProxy(const std::string &name, ISvcLocator *pSvcLocator)
Constructor of this form must be provided.
StatusCode execute() override
StatusCode initialize() override
Three mandatory member functions of any algorithm.
IProperty * m_remAlg
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100
STL namespace.