The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
PropertyAlg Class Reference

Trivial Algorithm for tutorial purposes. More...

#include </builds/gaudi/Gaudi/GaudiTestSuite/src/Properties/PropertyAlg.h>

Inheritance diagram for PropertyAlg:
Collaboration diagram for PropertyAlg:

Public Member Functions

 PropertyAlg (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor of this form must be provided.
 
StatusCode initialize () override
 Three mandatory member functions of any algorithm.
 
StatusCode execute () override
 
StatusCode finalize () override
 
void readHandler (Gaudi::Details::PropertyBase &)
 Callbacks for properties.
 
void updateHandler (Gaudi::Details::PropertyBase &)
 
- Public Member Functions inherited from Algorithm
 LegacyAlgorithmAdapter (std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
 
- Public Member Functions inherited from Gaudi::details::LegacyAlgorithmAdapter
 LegacyAlgorithmAdapter (std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
 
const EventContextgetContext () const
 
bool isExecuted () const
 Has this algorithm been executed since the last reset?
 
void setExecuted (bool state) const
 Set the executed flag to the specified state.
 
bool filterPassed () const
 Did this algorithm pass or fail its filter criterion for the last event?
 
void setFilterPassed (bool state) const
 Set the filter passed flag to the specified state.
 
- Public Member Functions inherited from Gaudi::Algorithm
 Algorithm (std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
 Constructor.
 
StatusCode sysStart () override
 Reinitialization method invoked by the framework.
 
StatusCode sysInitialize () override
 Initialization method invoked by the framework.
 
StatusCode sysReinitialize () override
 Reinitialization method invoked by the framework.
 
StatusCode sysRestart () override
 Restart method invoked by the framework.
 
StatusCode sysExecute (const EventContext &ctx) override
 The actions to be performed by the algorithm on an event.
 
StatusCode sysStop () override
 System stop.
 
StatusCode sysFinalize () override
 System finalization.
 
const std::string & name () const override
 The identifying name of the algorithm object.
 
const Gaudi::StringKeynameKey () const override
 
const std::string & type () const override
 The type of the algorithm object.
 
void setType (std::string type) override
 
const std::string & version () const override
 
unsigned int index () const override
 
StatusCode configure () override
 Dummy implementation of IStateful::configure() method.
 
StatusCode terminate () override
 Dummy implementation of IStateful::terminate() method.
 
StatusCode initialize () override
 the default (empty) implementation of IStateful::initialize() method
 
StatusCode start () override
 the default (empty) implementation of IStateful::start() method
 
StatusCode stop () override
 the default (empty) implementation of IStateful::stop() method
 
StatusCode finalize () override
 the default (empty) implementation of IStateful::finalize() method
 
StatusCode reinitialize () override
 the default (empty) implementation of IStateful::reinitialize() method
 
StatusCode restart () override
 the default (empty) implementation of IStateful::restart() method
 
Gaudi::StateMachine::State FSMState () const override
 returns the current state of the algorithm
 
Gaudi::StateMachine::State targetFSMState () const override
 returns the state the algorithm will be in after the ongoing transition
 
bool isEnabled () const override
 Is this algorithm enabled or disabled?
 
bool isSequence () const override
 Are we a Sequence?
 
unsigned int errorCount () const
 Get the number of failures of the algorithm.
 
SmartIF< IServiceservice (std::string_view name, const bool createIf=true, const bool quiet=false) const
 Return a pointer to the service identified by name (or "type/name")
 
template<class T>
SmartIF< T > service (std::string_view name, bool createIf=true, bool quiet=false) const
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
SmartIF< IChronoStatSvc > & chronoSvc () const
 The standard Chrono & Stat service, Return a pointer to the service if present.
 
SmartIF< IDataProviderSvc > & detSvc () const
 The standard detector data service.
 
SmartIF< IConversionSvc > & detCnvSvc () const
 The standard detector data persistency conversion service.
 
SmartIF< IDataProviderSvc > & eventSvc () const
 The standard event data service.
 
SmartIF< IDataProviderSvc > & evtSvc () const
 shortcut for method eventSvc
 
SmartIF< IConversionSvc > & eventCnvSvc () const
 The standard event data persistency conversion service.
 
SmartIF< IHistogramSvc > & histoSvc () const
 The standard histogram service.
 
SmartIF< INTupleSvc > & ntupleSvc () const
 The standard N tuple service.
 
SmartIF< IRndmGenSvc > & randSvc () const
 The standard RandomGen service, Return a pointer to the service if present.
 
SmartIF< IToolSvc > & toolSvc () const
 The standard ToolSvc service, Return a pointer to the service if present.
 
SmartIF< IExceptionSvc > & exceptionSvc () const
 Get the exception Service.
 
SmartIF< IAlgContextSvc > & contextSvc () const
 get Algorithm Context Service
 
SmartIF< ITimelineSvc > & timelineSvc () const
 
SmartIF< ISvcLocator > & serviceLocator () const override
 The standard service locator.
 
SmartIF< ISvcLocator > & svcLoc () const
 shortcut for method serviceLocator
 
SmartIF< IHiveWhiteBoard > & whiteboard () const
 
SmartIF< IAlgExecStateSvc > & algExecStateSvc () const
 
bool registerContext () const
 register for Algorithm Context Service?
 
template<class T>
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T>
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
SmartIF< IMonitorSvc > & monitorSvc () const
 Access the monitor service.
 
template<class T>
void declareInfo (const std::string &name, const T &var, const std::string &desc) const
 Declare monitoring information.
 
void declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const
 Declare monitoring information (special case)
 
void acceptDHVisitor (IDataHandleVisitor *) const override
 
void registerTool (IAlgTool *tool) const
 
void deregisterTool (IAlgTool *tool) const
 
template<class T>
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T>
StatusCode declareTool (ToolHandle< T > &handle, const std::string &toolTypeAndName, bool createIf=true)
 
template<class T>
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
bool isAsynchronous () const
 
void setAsynchronous (bool value)
 
unsigned int cardinality () const override
 Return the cardinality.
 
const std::vector< std::string > & neededResources () const override
 
AlgExecStateRef execState (const EventContext &ctx) const override
 get the AlgExecStateRef of current algorithm Actually a small wrapper around it, thus the plain object return type
 
std::ostream & toControlFlowExpression (std::ostream &os) const override
 Produce string represention of the control flow expression.
 
- Public Member Functions inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
std::vector< Gaudi::DataHandle * > inputHandles () const override
 
std::vector< Gaudi::DataHandle * > outputHandles () const override
 
virtual const DataObjIDCollextraInputDeps () const override
 
virtual const DataObjIDCollextraOutputDeps () const override
 
void declare (Gaudi::DataHandle &handle) override
 
void renounce (Gaudi::DataHandle &handle) override
 
bool renounceInput (const DataObjID &id) override
 
const DataObjIDCollinputDataObjs () const override
 
const DataObjIDColloutputDataObjs () const override
 
void addDependency (const DataObjID &id, const Gaudi::DataHandle::Mode &mode) override
 
- Public Member Functions inherited from extends< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >, IDataHandleHolder >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property.
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property.
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation.
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property.
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name.
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream)
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor.
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 

Private Attributes

Gaudi::Property< int > m_int { this, "Int", 100 }
 These data members are used in the execution of this algorithm They are set in the initialization phase by the job options service.
 
Gaudi::Property< long long > m_int64 { this, "Int64", 100 }
 
Gaudi::Property< unsigned long long > m_uint64 { this, "UInt64", 100 }
 
Gaudi::Property< double > m_double { this, "Double", 100. }
 
Gaudi::Property< std::string > m_string { this, "String", "hundred" }
 
Gaudi::Property< bool > m_bool { this, "Bool", true }
 
Gaudi::Property< std::vector< int > > m_intarray { this, "IntArray" }
 
Gaudi::Property< std::vector< long long > > m_int64array { this, "Int64Array" }
 
Gaudi::Property< std::vector< unsigned long long > > m_uint64array { this, "UInt64Array" }
 
Gaudi::Property< std::vector< double > > m_doublearray { this, "DoubleArray" }
 
Gaudi::Property< std::vector< std::string > > m_stringarray { this, "StringArray" }
 
Gaudi::Property< std::vector< bool > > m_boolarray { this, "BoolArray" }
 
Gaudi::Property< std::vector< double > > m_emptyarray { this, "EmptyArray" }
 
Gaudi::Property< std::vector< double > > u_doublearrayunits { this, "DoubleArrayWithUnits" }
 
Gaudi::Property< std::vector< double > > u_doublearray { this, "DoubleArrayWithoutUnits" }
 
Gaudi::Property< std::vector< std::pair< int, int > > > u_intpairarray { this, "IntPairArray" }
 
Gaudi::Property< std::vector< std::pair< double, double > > > u_doublepairarray { this, "DoublePairArray" }
 
Gaudi::Property< std::set< int > > m_intset { this, "IntSet" }
 
Gaudi::Property< std::set< std::string > > m_stringset { this, "StringSet" }
 
Gaudi::Property< std::unordered_set< float > > m_floatuset { this, "FloatUnorderedSet" }
 
Gaudi::Property< std::map< std::string, std::string > > m_strmap { this, "StringMap" }
 
Gaudi::CheckedProperty< int > p_int { this, "PInt", 100, "An integer property" }
 
Gaudi::PropertyWithReadHandler< double > p_double { this, "PDouble", 100. }
 
Gaudi::Property< std::string > p_string { this, "PString", "hundred" }
 
Gaudi::Property< bool > p_bool { this, "PBool", false }
 
Gaudi::Property< std::vector< int > > p_intarray { this, "PIntArray" }
 
Gaudi::Property< std::vector< double > > p_doublearray { this, "PDoubleArray" }
 
Gaudi::Property< std::vector< std::string > > p_stringarray { this, "PStringArray" }
 
Gaudi::Property< std::vector< bool > > p_boolarray { this, "PBoolArray" }
 

Additional Inherited Members

- Public Types inherited from Gaudi::Algorithm
typedef Gaudi::PluginService::Factory< IAlgorithm *(const std::string &, ISvcLocator *)> Factory
 
- Public Types inherited from extends< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >, IDataHandleHolder >
using base_class
 Typedef to this class.
 
using extend_interfaces_base
 Typedef to the base of this class.
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
using PropertyHolderImpl
 Typedef used to refer to this class from derived classes, as in.
 
- Public Types inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
using base_class
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
 
- Public Attributes inherited from Gaudi::Algorithm
friend AlgorithmManager
 
- Protected Member Functions inherited from Gaudi::details::LegacyAlgorithmAdapter
bool isReEntrant () const override
 
- Protected Member Functions inherited from Gaudi::Algorithm
std::vector< IAlgTool * > & tools ()
 
bool isInitialized () const override
 Has the Algorithm already been initialized?
 
bool isFinalized () const override
 Has the Algorithm already been finalized?
 
void setIndex (const unsigned int &idx) override
 set instantiation index of Alg
 
bool isReEntrant () const override
 
- Protected Member Functions inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
void initDataHandleHolder ()
 initializes all handles - called by the sysInitialize method of any descendant of this
 
- Protected Member Functions inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches.
 
MSG::Level resetMessaging ()
 Reinitialize internal states.
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream.
 
- Protected Attributes inherited from Gaudi::Algorithm
std::unique_ptr< IDataHandleVisitorm_updateDataHandles
 Hook for for derived classes to provide a custom visitor for data handles.
 
- Protected Attributes inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
DataObjIDColl m_inputDataObjs
 
DataObjIDColl m_outputDataObjs
 

Detailed Description

Trivial Algorithm for tutorial purposes.

Author
nobody

Definition at line 28 of file PropertyAlg.h.

Constructor & Destructor Documentation

◆ PropertyAlg()

PropertyAlg::PropertyAlg ( const std::string & name,
ISvcLocator * pSvcLocator )

Constructor of this form must be provided.

Definition at line 52 of file PropertyAlg.cpp.

52 : Algorithm( name, ploc ) {
53 //------------------------------------------------------------------------------
54 // Associate read and update handlers
55
56 p_double.declareUpdateHandler( &PropertyAlg::updateHandler, this );
57 p_double.declareReadHandler( &PropertyAlg::readHandler, this );
58
59 {
60 // do not print messages if we are created in genconf
61 const std::string cmd = System::cmdLineArgs()[0];
62 if ( cmd.find( "genconf" ) != std::string::npos ) return;
63 }
64
65 info() << "Before Initialization......" << endmsg;
66
67 info() << "Int = " << m_int.value() << endmsg;
68 info() << "Int64 = " << m_int64.value() << endmsg;
69 info() << "UInt64 = " << m_uint64.value() << endmsg;
70 info() << "Double = " << m_double.value() << endmsg;
71 info() << "String = " << m_string.value() << endmsg;
72 info() << "Bool = " << m_bool.value() << endmsg;
73 info() << "IntArray = " << m_intarray.value() << endmsg;
74 info() << "Int64Array = " << m_int64array.value() << endmsg;
75 info() << "UInt64Array = " << m_uint64array.value() << endmsg;
76 info() << "DoubleArray = " << m_doublearray.value() << endmsg;
77 info() << "StringArray = " << m_stringarray.value() << endmsg;
78 info() << "BoolArray = " << m_boolarray.value() << endmsg;
79 info() << "EmptyArray = " << m_emptyarray.value() << endmsg;
80 info() << "IntPairArray = " << u_intpairarray.value() << endmsg;
81 info() << "DoublePairArray = " << u_doublepairarray.value() << endmsg;
82 info() << "IntSet = " << m_intset.value() << endmsg;
83 info() << "StringSet = " << m_stringset.value() << endmsg;
84 info() << "FloatUnorderedSet = " << m_floatuset.value() << endmsg;
85
86 info() << "PInt = " << p_int << endmsg;
87 std::ostringstream os;
88 os << p_double; // avoid read handler from printing _during_ info()!
89 info() << "PDouble = " << os.str() << endmsg;
90 info() << "PString = " << p_string << endmsg;
91 info() << "PBool = " << p_bool << endmsg;
92 info() << "PIntArray = " << p_intarray << endmsg;
93 info() << "PDoubleArray = " << p_doublearray << endmsg;
94 info() << "PStringArray = " << p_stringarray << endmsg;
95 info() << "PBoolArray = " << p_boolarray << endmsg;
96}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
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
const std::string & name() const override
The identifying name of the algorithm object.
void readHandler(Gaudi::Details::PropertyBase &)
Callbacks for properties.
Gaudi::Property< double > m_double
Definition PropertyAlg.h:48
Gaudi::Property< unsigned long long > m_uint64
Definition PropertyAlg.h:47
Gaudi::Property< std::vector< std::pair< double, double > > > u_doublepairarray
Definition PropertyAlg.h:63
Gaudi::Property< std::vector< std::pair< int, int > > > u_intpairarray
Definition PropertyAlg.h:62
Gaudi::Property< std::vector< int > > p_intarray
Definition PropertyAlg.h:77
Gaudi::Property< int > m_int
These data members are used in the execution of this algorithm They are set in the initialization pha...
Definition PropertyAlg.h:45
Gaudi::Property< std::vector< std::string > > p_stringarray
Definition PropertyAlg.h:79
Gaudi::Property< std::string > p_string
Definition PropertyAlg.h:74
Gaudi::Property< bool > m_bool
Definition PropertyAlg.h:50
Gaudi::Property< bool > p_bool
Definition PropertyAlg.h:75
Gaudi::Property< std::vector< long long > > m_int64array
Definition PropertyAlg.h:53
Gaudi::Property< std::vector< bool > > p_boolarray
Definition PropertyAlg.h:80
Gaudi::Property< long long > m_int64
Definition PropertyAlg.h:46
Gaudi::Property< std::vector< bool > > m_boolarray
Definition PropertyAlg.h:57
Gaudi::PropertyWithReadHandler< double > p_double
Definition PropertyAlg.h:72
Gaudi::Property< std::set< std::string > > m_stringset
Definition PropertyAlg.h:66
Gaudi::Property< std::vector< int > > m_intarray
Definition PropertyAlg.h:52
Gaudi::Property< std::vector< unsigned long long > > m_uint64array
Definition PropertyAlg.h:54
Gaudi::CheckedProperty< int > p_int
Definition PropertyAlg.h:71
Gaudi::Property< std::string > m_string
Definition PropertyAlg.h:49
Gaudi::Property< std::vector< std::string > > m_stringarray
Definition PropertyAlg.h:56
Gaudi::Property< std::unordered_set< float > > m_floatuset
Definition PropertyAlg.h:67
Gaudi::Property< std::vector< double > > p_doublearray
Definition PropertyAlg.h:78
void updateHandler(Gaudi::Details::PropertyBase &)
Gaudi::Property< std::vector< double > > m_emptyarray
Definition PropertyAlg.h:58
Gaudi::Property< std::vector< double > > m_doublearray
Definition PropertyAlg.h:55
Gaudi::Property< std::set< int > > m_intset
Definition PropertyAlg.h:65
GAUDI_API const std::vector< std::string > cmdLineArgs()
Command line arguments including executable name as arg[0] as vector of strings.
Definition System.cpp:310

Member Function Documentation

◆ execute()

StatusCode PropertyAlg::execute ( )
overridevirtual

Implements Algorithm.

Definition at line 286 of file PropertyAlg.cpp.

286 {
287 //------------------------------------------------------------------------------
288 info() << "executing...." << endmsg;
289 return StatusCode::SUCCESS;
290}
constexpr static const auto SUCCESS
Definition StatusCode.h:99

◆ finalize()

StatusCode PropertyAlg::finalize ( )
override

Definition at line 293 of file PropertyAlg.cpp.

293 {
294 //------------------------------------------------------------------------------
295 info() << "finalizing...." << endmsg;
296 return StatusCode::SUCCESS;
297}

◆ initialize()

StatusCode PropertyAlg::initialize ( )
override

Three mandatory member functions of any algorithm.

Definition at line 99 of file PropertyAlg.cpp.

99 {
100 //------------------------------------------------------------------------------
101
102 //
103 // Checking the JobOptions interface. Be able to set the properties
104 //
105 info() << "After Initialization having read the JobOptions file..." << endmsg;
106
107 info() << "Int = " << m_int.value() << endmsg;
108 info() << "Int64 = " << m_int64.value() << endmsg;
109 info() << "UInt64 = " << m_uint64.value() << endmsg;
110 info() << "Double = " << m_double.value() << endmsg;
111 info() << "String = " << m_string.value() << endmsg;
112 info() << "Bool = " << m_bool.value() << endmsg;
113 info() << "IntArray = " << m_intarray.value() << endmsg;
114 info() << "Int64Array = " << m_int64array.value() << endmsg;
115 info() << "UInt64Array = " << m_uint64array.value() << endmsg;
116 info() << "DoubleArray = " << m_doublearray.value() << endmsg;
117 info() << "StringArray = " << m_stringarray.value() << endmsg;
118 info() << "BoolArray = " << m_boolarray.value() << endmsg;
119 info() << "EmptyArray = " << m_emptyarray.value() << endmsg;
120 info() << "IntPairArray = " << u_intpairarray.value() << endmsg;
121 info() << "DoublePairArray = " << u_doublepairarray.value() << endmsg;
122 info() << "IntSet = " << m_intset.value() << endmsg;
123 info() << "StringSet = " << m_stringset.value() << endmsg;
124 info() << "FloatUnorderedSet = " << m_floatuset.value() << endmsg;
125 info() << "StringMap = " << m_strmap << endmsg;
126
127 info() << "PInt = " << p_int << endmsg;
128 std::ostringstream os;
129 os << p_double; // avoid read handler from printing _during_ info()!
130 info() << "PDouble = " << os.str() << endmsg;
131 info() << "PString = " << p_string << endmsg;
132 info() << "PBool = " << p_bool << endmsg;
133 info() << "PIntArray = " << p_intarray << endmsg;
134 info() << "PDoubleArray = " << p_doublearray << endmsg;
135 info() << "PStringArray = " << p_stringarray << endmsg;
136 info() << "PBoolArray = " << p_boolarray << endmsg;
137 //
138 // Checking units
139 //
140 auto& doublearrayunits = u_doublearrayunits.value();
141 auto& doublearray = u_doublearray.value();
142 for ( unsigned int i = 0; i < doublearrayunits.size(); i++ ) {
143
144 if ( !essentiallyEqual( doublearrayunits[i], doublearray[i] ) ) {
145 error() << format( "DoubleArrayWithUnits[%d] = %g and should be %g", i, doublearrayunits[i], doublearray[i] )
146 << endmsg;
147 } else {
148 info() << format( "DoubleArrayWithUnits[%d] = %g", i, doublearrayunits[i] ) << endmsg;
149 }
150 }
151
152 //
153 // Checking the Property Verifier
154 //
155 info() << "===============Checking Property Verifier ===============" << endmsg;
156
157 info() << "Playing with PropertyVerifiers..." << endmsg;
158
159 p_int.verifier().setBounds( 0, 200 );
160 p_int = 155;
161 // info() << "PInt= " << p_int << " [should be 155, bounds are " <<
162 // p_int.verifier().lower() << ", " <<
163 // p_int.verifier().upper() << " ]" << endmsg;
164 info() << format( "PInt= %d [should be 155, bounds are %d, %d]", (int)p_int, (int)p_int.verifier().lower(),
165 (int)p_int.verifier().upper() )
166 << endmsg;
167 try {
168 p_int = 255;
169 } catch ( ... ) { info() << "Got an exception when setting a value outside bounds" << endmsg; }
170 info() << "PInt= " << p_int << " [should be 155]" << endmsg;
171
172 //
173 // Checking the Property CallBacks
174 //
175 info() << "===============Checking Property CallBaks ===============" << endmsg;
176
177 double d;
178 info() << "Accessing PDouble ... " << endmsg;
179 d = p_double;
180
181 info() << "Value obtained is: " << d << endmsg;
182
183 info() << "Updating PDouble ... " << endmsg;
184 p_double = 999.;
185
186 //
187 // Checking Accessing Properties by string
188 //
189
190 info() << "==========Checking Accesing Properties by string=========" << endmsg;
191
192 auto appmgr = serviceLocator()->as<IProperty>();
193 // StatusCode sc = serviceLocator()->service("ApplicationMgr", appmgr);
194 if ( !appmgr ) {
195 error() << "Unable to locate the ApplicationMgr" << endmsg;
196 } else {
197 std::string value( "empty" );
198 appmgr->getProperty( "ExtSvc", value ).ignore();
199 info() << " Got property ApplicationMgr.ExtSvc = " << value << ";" << endmsg;
200
201 appmgr->setPropertyRepr( "ExtSvc", "[\"EvtDataSvc/EventDataSvc\", \"DetDataSvc/DetectorDataSvc\"]" ).ignore();
202 info() << " Set property ApplicationMgr.ExtSvc = "
203 << " [\"EvtDataSvc/EventDataSvc\", \"DetDataSvc/DetectorDataSvc\"]"
204 << ";" << endmsg;
205 appmgr->getProperty( "ExtSvc", value ).ignore();
206 info() << " Got property ApplicationMgr.ExtSvc = " << value << ";" << endmsg;
207
208 appmgr->setPropertyRepr( "ExtSvc", "[ 'EventDataSvc', 'DetectorDataSvc']" ).ignore();
209 info() << " Set property ApplicationMgr.ExtSvc = "
210 << " [ 'EventDataSvc', 'DetectorDataSvc']"
211 << ";" << endmsg;
212 appmgr->getProperty( "ExtSvc", value ).ignore();
213 info() << " Got property ApplicationMgr.ExtSvc = " << value << ";" << endmsg;
214 }
215 // Testing setting bool
216 std::vector<std::tuple<std::string, bool>> cases = {
217 std::make_tuple( "true", true ), std::make_tuple( "false", false ), std::make_tuple( "True", true ),
218 std::make_tuple( "False", false ), std::make_tuple( "TRUE", true ), std::make_tuple( "FALSE", false ),
219 std::make_tuple( "T", true ), // not expected to work
220 std::make_tuple( "F", false ), // not expected to work
221 std::make_tuple( "10", true ), // not expected to work
222 };
223 StatusCode sc = StatusCode::SUCCESS;
224 for ( auto& c : cases ) {
225 p_bool = m_bool = !std::get<1>( c );
226 try {
227 sc = setPropertyRepr( "PBool", std::get<0>( c ) );
228 } catch ( ... ) { sc = StatusCode::FAILURE; }
229 if ( !sc || ( p_bool != std::get<1>( c ) ) ) {
230 error() << "PBool can not be set to " << std::get<0>( c ) << endmsg;
231 }
232 try {
233 sc = setPropertyRepr( "Bool", std::get<0>( c ) );
234 } catch ( ... ) { sc = StatusCode::FAILURE; }
235 if ( !sc || ( m_bool != std::get<1>( c ) ) ) { error() << "Bool can not be set to " << std::get<0>( c ) << endmsg; }
236 }
237
238 // Testing the control of the output level directly from MessageSvc
239 MsgStream newlog( msgSvc(), "MsgTest" );
240 newlog << MSG::VERBOSE << "This should be printed if threshold is VERBOSE" << endmsg;
241 newlog << MSG::DEBUG << "This should be printed if threshold is DEBUG" << endmsg;
242 newlog << MSG::INFO << "This should be printed if threshold is INFO" << endmsg;
243 newlog << MSG::WARNING << "This should be printed if threshold is WARNING" << endmsg;
244 newlog << MSG::ERROR << "This should be printed if threshold is ERROR" << endmsg;
245 newlog << MSG::FATAL << "This should be printed if threshold is FATAL" << endmsg;
246 newlog << MSG::ALWAYS << "This should be printed ALWAYS" << endmsg;
247
248 // Testing access to the JobOptions catalogue
249 auto& opts = serviceLocator()->getOptsSvc();
250
251 // Dump of the catalogue
252 info() << "=================================================" << endmsg;
254 auto opt_items = opts.items(); // this copy is just to hide differences between gcc and clang outputs
255 ostream_joiner( info() << "Dump of the property catalogue:\n", opt_items, '\n',
256 []( MsgStream& os, const auto& item ) -> MsgStream& {
257 return os << std::get<0>( item ) << ": " << std::get<1>( item );
258 } )
259 << endmsg;
260 info() << "=================================================" << endmsg;
261
262 // Change an option of my own....
263 opts.set( name() + '.' + "PInt", "154" );
264 info() << "PInt= " << p_int << " [should be 154]" << endmsg;
265
266 auto orig_policy =
268 try {
269 info() << "Try to assign invalid value to DoubleArray" << endmsg;
270 opts.set( name() + '.' + "DoubleArray", "{\"12.12\", \"13.13\"}" );
271 } catch ( const GaudiException& exc ) { error() << "got exception: " << exc.what() << endmsg; }
272
273 try {
274 info() << "Try to assign invalid value to StringMap" << endmsg;
275 opts.set( name() + '.' + "StringMap", "{\"one\", {\"une\", \"eins\"}}" );
276 } catch ( const GaudiException& exc ) { error() << "got exception: " << exc.what() << endmsg; }
277
279
280 info() << "DoubleArray = " << m_doublearray.value() << endmsg;
281 info() << "=================================================" << endmsg;
282 return StatusCode::SUCCESS;
283}
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition MsgStream.cpp:93
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
const char * what() const override
method from std::exception
SmartIF< IFace > as()
Definition ISvcLocator.h:64
Gaudi::Interfaces::IOptionsSvc & getOptsSvc()
Direct access to Gaudi::Interfaces::IOptionsSvc implementation.
Gaudi::Property< std::map< std::string, std::string > > m_strmap
Definition PropertyAlg.h:69
Gaudi::Property< std::vector< double > > u_doublearrayunits
Definition PropertyAlg.h:59
Gaudi::Property< std::vector< double > > u_doublearray
Definition PropertyAlg.h:60
constexpr static const auto FAILURE
Definition StatusCode.h:100
ParsingErrorPolicy setParsingErrorPolicy(ParsingErrorPolicy p)
Definition Property.cpp:477
Stream & ostream_joiner(Stream &os, Iterator first, Iterator last, Separator sep, OutputElement output=OutputElement{})
@ WARNING
Definition IMessageSvc.h:22
@ FATAL
Definition IMessageSvc.h:22
@ DEBUG
Definition IMessageSvc.h:22
@ ERROR
Definition IMessageSvc.h:22
@ ALWAYS
Definition IMessageSvc.h:22
@ INFO
Definition IMessageSvc.h:22
@ VERBOSE
Definition IMessageSvc.h:22

◆ readHandler()

void PropertyAlg::readHandler ( Gaudi::Details::PropertyBase & p)

Callbacks for properties.

Definition at line 32 of file PropertyAlg.cpp.

32 {
33 // do not print messages if we are created in genconf
34 const std::string cmd = System::cmdLineArgs()[0];
35 if ( cmd.find( "genconf" ) != std::string::npos ) return;
36
37 info() << "Read handler called for property: " << p << endmsg;
38}

◆ updateHandler()

void PropertyAlg::updateHandler ( Gaudi::Details::PropertyBase & p)

Definition at line 42 of file PropertyAlg.cpp.

42 {
43 // avoid the readHandler (which writes to the _same_ MsgStream!) from writing
44 // something in the middle of the printout of this message...
45 std::ostringstream os;
46 os << p;
47 info() << "Update handler called for property: " << os.str() << endmsg;
48}

Member Data Documentation

◆ m_bool

Gaudi::Property<bool> PropertyAlg::m_bool { this, "Bool", true }
private

Definition at line 50 of file PropertyAlg.h.

50{ this, "Bool", true };

◆ m_boolarray

Gaudi::Property<std::vector<bool> > PropertyAlg::m_boolarray { this, "BoolArray" }
private

Definition at line 57 of file PropertyAlg.h.

57{ this, "BoolArray" };

◆ m_double

Gaudi::Property<double> PropertyAlg::m_double { this, "Double", 100. }
private

Definition at line 48 of file PropertyAlg.h.

48{ this, "Double", 100. };

◆ m_doublearray

Gaudi::Property<std::vector<double> > PropertyAlg::m_doublearray { this, "DoubleArray" }
private

Definition at line 55 of file PropertyAlg.h.

55{ this, "DoubleArray" };

◆ m_emptyarray

Gaudi::Property<std::vector<double> > PropertyAlg::m_emptyarray { this, "EmptyArray" }
private

Definition at line 58 of file PropertyAlg.h.

58{ this, "EmptyArray" };

◆ m_floatuset

Gaudi::Property<std::unordered_set<float> > PropertyAlg::m_floatuset { this, "FloatUnorderedSet" }
private

Definition at line 67 of file PropertyAlg.h.

67{ this, "FloatUnorderedSet" };

◆ m_int

Gaudi::Property<int> PropertyAlg::m_int { this, "Int", 100 }
private

These data members are used in the execution of this algorithm They are set in the initialization phase by the job options service.

Definition at line 45 of file PropertyAlg.h.

45{ this, "Int", 100 };

◆ m_int64

Gaudi::Property<long long> PropertyAlg::m_int64 { this, "Int64", 100 }
private

Definition at line 46 of file PropertyAlg.h.

46{ this, "Int64", 100 };

◆ m_int64array

Gaudi::Property<std::vector<long long> > PropertyAlg::m_int64array { this, "Int64Array" }
private

Definition at line 53 of file PropertyAlg.h.

53{ this, "Int64Array" };

◆ m_intarray

Gaudi::Property<std::vector<int> > PropertyAlg::m_intarray { this, "IntArray" }
private

Definition at line 52 of file PropertyAlg.h.

52{ this, "IntArray" };

◆ m_intset

Gaudi::Property<std::set<int> > PropertyAlg::m_intset { this, "IntSet" }
private

Definition at line 65 of file PropertyAlg.h.

65{ this, "IntSet" };

◆ m_string

Gaudi::Property<std::string> PropertyAlg::m_string { this, "String", "hundred" }
private

Definition at line 49 of file PropertyAlg.h.

49{ this, "String", "hundred" };

◆ m_stringarray

Gaudi::Property<std::vector<std::string> > PropertyAlg::m_stringarray { this, "StringArray" }
private

Definition at line 56 of file PropertyAlg.h.

56{ this, "StringArray" };

◆ m_stringset

Gaudi::Property<std::set<std::string> > PropertyAlg::m_stringset { this, "StringSet" }
private

Definition at line 66 of file PropertyAlg.h.

66{ this, "StringSet" };

◆ m_strmap

Gaudi::Property<std::map<std::string, std::string> > PropertyAlg::m_strmap { this, "StringMap" }
private

Definition at line 69 of file PropertyAlg.h.

69{ this, "StringMap" };

◆ m_uint64

Gaudi::Property<unsigned long long> PropertyAlg::m_uint64 { this, "UInt64", 100 }
private

Definition at line 47 of file PropertyAlg.h.

47{ this, "UInt64", 100 };

◆ m_uint64array

Gaudi::Property<std::vector<unsigned long long> > PropertyAlg::m_uint64array { this, "UInt64Array" }
private

Definition at line 54 of file PropertyAlg.h.

54{ this, "UInt64Array" };

◆ p_bool

Gaudi::Property<bool> PropertyAlg::p_bool { this, "PBool", false }
private

Definition at line 75 of file PropertyAlg.h.

75{ this, "PBool", false };

◆ p_boolarray

Gaudi::Property<std::vector<bool> > PropertyAlg::p_boolarray { this, "PBoolArray" }
private

Definition at line 80 of file PropertyAlg.h.

80{ this, "PBoolArray" };

◆ p_double

Gaudi::PropertyWithReadHandler<double> PropertyAlg::p_double { this, "PDouble", 100. }
private

Definition at line 72 of file PropertyAlg.h.

72{ this, "PDouble", 100. };

◆ p_doublearray

Gaudi::Property<std::vector<double> > PropertyAlg::p_doublearray { this, "PDoubleArray" }
private

Definition at line 78 of file PropertyAlg.h.

78{ this, "PDoubleArray" };

◆ p_int

Gaudi::CheckedProperty<int> PropertyAlg::p_int { this, "PInt", 100, "An integer property" }
private

Definition at line 71 of file PropertyAlg.h.

71{ this, "PInt", 100, "An integer property" };

◆ p_intarray

Gaudi::Property<std::vector<int> > PropertyAlg::p_intarray { this, "PIntArray" }
private

Definition at line 77 of file PropertyAlg.h.

77{ this, "PIntArray" };

◆ p_string

Gaudi::Property<std::string> PropertyAlg::p_string { this, "PString", "hundred" }
private

Definition at line 74 of file PropertyAlg.h.

74{ this, "PString", "hundred" };

◆ p_stringarray

Gaudi::Property<std::vector<std::string> > PropertyAlg::p_stringarray { this, "PStringArray" }
private

Definition at line 79 of file PropertyAlg.h.

79{ this, "PStringArray" };

◆ u_doublearray

Gaudi::Property<std::vector<double> > PropertyAlg::u_doublearray { this, "DoubleArrayWithoutUnits" }
private

Definition at line 60 of file PropertyAlg.h.

60{ this, "DoubleArrayWithoutUnits" };

◆ u_doublearrayunits

Gaudi::Property<std::vector<double> > PropertyAlg::u_doublearrayunits { this, "DoubleArrayWithUnits" }
private

Definition at line 59 of file PropertyAlg.h.

59{ this, "DoubleArrayWithUnits" };

◆ u_doublepairarray

Gaudi::Property<std::vector<std::pair<double, double> > > PropertyAlg::u_doublepairarray { this, "DoublePairArray" }
private

Definition at line 63 of file PropertyAlg.h.

63{ this, "DoublePairArray" };

◆ u_intpairarray

Gaudi::Property<std::vector<std::pair<int, int> > > PropertyAlg::u_intpairarray { this, "IntPairArray" }
private

Definition at line 62 of file PropertyAlg.h.

62{ this, "IntPairArray" };

The documentation for this class was generated from the following files: