The Gaudi Framework  master (37c0b60a)
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>
17 #include <GaudiKernel/MsgStream.h>
18 #include <GaudiKernel/SmartIF.h>
19 
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 //------------------------------------------------------------------------------
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 //------------------------------------------------------------------------------
68  //------------------------------------------------------------------------------
69  info() << "executing...." << endmsg;
70 
71  return StatusCode::SUCCESS;
72 }
73 
74 //------------------------------------------------------------------------------
76  //------------------------------------------------------------------------------
77  info() << "finalizing...." << endmsg;
78 
79  return StatusCode::SUCCESS;
80 }
IAlgManager.h
std::string
STL class.
PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >::setProperty
StatusCode setProperty(const Gaudi::Details::PropertyBase &p)
Set the property from a property.
Definition: IProperty.h:39
ISvcLocator
Definition: ISvcLocator.h:46
Gaudi::Algorithm::initialize
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition: Algorithm.h:178
Algorithm
Alias for backward compatibility.
Definition: Algorithm.h:58
PropertyProxy::m_remAlg
IProperty * m_remAlg
Definition: PropertyProxy.h:35
PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >::getProperty
StatusCode getProperty(Gaudi::Details::PropertyBase *p) const override
get the property
Definition: PropertyHolder.h:190
IDataProviderSvc.h
IProperty::getProperty
virtual StatusCode getProperty(Gaudi::Details::PropertyBase *p) const =0
Get the property by property.
IAlgManager
Definition: IAlgManager.h:37
SmartIF.h
StatusCode
Definition: StatusCode.h:65
SmartIF< IProperty >
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
PropertyProxy.h
StatusCode::ignore
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition: StatusCode.h:139
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
DataObject.h
IChronoStatSvc.h
std
STL namespace.
PropertyProxy::finalize
StatusCode finalize() override
Definition: PropertyProxy.cpp:75
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
PropertyProxy::initialize
StatusCode initialize() override
Three mandatory member functions of any algorithm.
Definition: PropertyProxy.cpp:39
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
PropertyProxy::execute
StatusCode execute() override
Definition: PropertyProxy.cpp:67
PropertyProxy
Definition: PropertyProxy.h:24
MsgStream.h