25 constexpr bool essentiallyEqual(
double const a,
double const b ) {
35 if ( cmd.find(
"genconf" ) != std::string::npos )
return;
37 info() <<
"Read handler called for property: " << p <<
endmsg;
45 std::ostringstream os;
47 info() <<
"Update handler called for property: " << os.str() <<
endmsg;
62 if ( cmd.find(
"genconf" ) != std::string::npos )
return;
65 info() <<
"Before Initialization......" <<
endmsg;
87 std::ostringstream os;
105 info() <<
"After Initialization having read the JobOptions file..." <<
endmsg;
128 std::ostringstream os;
142 for (
unsigned int i = 0; i < doublearrayunits.size(); i++ ) {
144 if ( !essentiallyEqual( doublearrayunits[i], doublearray[i] ) ) {
145 error() <<
format(
"DoubleArrayWithUnits[%d] = %g and should be %g", i, doublearrayunits[i], doublearray[i] )
148 info() <<
format(
"DoubleArrayWithUnits[%d] = %g", i, doublearrayunits[i] ) <<
endmsg;
155 info() <<
"===============Checking Property Verifier ===============" <<
endmsg;
157 info() <<
"Playing with PropertyVerifiers..." <<
endmsg;
159 p_int.verifier().setBounds( 0, 200 );
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() )
169 }
catch ( ... ) {
info() <<
"Got an exception when setting a value outside bounds" <<
endmsg; }
175 info() <<
"===============Checking Property CallBaks ===============" <<
endmsg;
181 info() <<
"Value obtained is: " << d <<
endmsg;
190 info() <<
"==========Checking Accesing Properties by string=========" <<
endmsg;
195 error() <<
"Unable to locate the ApplicationMgr" <<
endmsg;
197 std::string value(
"empty" );
198 appmgr->getProperty(
"ExtSvc", value ).ignore();
199 info() <<
" Got property ApplicationMgr.ExtSvc = " << value <<
";" <<
endmsg;
201 appmgr->setPropertyRepr(
"ExtSvc",
"[\"EvtDataSvc/EventDataSvc\", \"DetDataSvc/DetectorDataSvc\"]" ).ignore();
202 info() <<
" Set property ApplicationMgr.ExtSvc = "
203 <<
" [\"EvtDataSvc/EventDataSvc\", \"DetDataSvc/DetectorDataSvc\"]"
205 appmgr->getProperty(
"ExtSvc", value ).ignore();
206 info() <<
" Got property ApplicationMgr.ExtSvc = " << value <<
";" <<
endmsg;
208 appmgr->setPropertyRepr(
"ExtSvc",
"[ 'EventDataSvc', 'DetectorDataSvc']" ).ignore();
209 info() <<
" Set property ApplicationMgr.ExtSvc = "
210 <<
" [ 'EventDataSvc', 'DetectorDataSvc']"
212 appmgr->getProperty(
"ExtSvc", value ).ignore();
213 info() <<
" Got property ApplicationMgr.ExtSvc = " << value <<
";" <<
endmsg;
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 ),
220 std::make_tuple(
"F",
false ),
221 std::make_tuple(
"10",
true ),
224 for (
auto& c : cases ) {
229 if ( !sc || (
p_bool != std::get<1>( c ) ) ) {
230 error() <<
"PBool can not be set to " << std::get<0>( c ) <<
endmsg;
235 if ( !sc || (
m_bool != std::get<1>( c ) ) ) {
error() <<
"Bool can not be set to " << std::get<0>( c ) <<
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;
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;
252 info() <<
"=================================================" <<
endmsg;
254 auto opt_items = opts.items();
255 ostream_joiner(
info() <<
"Dump of the property catalogue:\n", opt_items,
'\n',
257 return os << std::get<0>( item ) <<
": " << std::get<1>( item );
260 info() <<
"=================================================" <<
endmsg;
263 opts.set(
name() +
'.' +
"PInt",
"154" );
269 info() <<
"Try to assign invalid value to DoubleArray" <<
endmsg;
270 opts.set(
name() +
'.' +
"DoubleArray",
"{\"12.12\", \"13.13\"}" );
274 info() <<
"Try to assign invalid value to StringMap" <<
endmsg;
275 opts.set(
name() +
'.' +
"StringMap",
"{\"one\", {\"une\", \"eins\"}}" );
281 info() <<
"=================================================" <<
endmsg;
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
#define DECLARE_COMPONENT(type)
Provide serialization function (output only) for some common STL classes (vectors,...
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
const std::string & name() const override
The identifying name of the algorithm object.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Define general base for Gaudi exception.
const char * what() const override
method from std::exception
The IProperty is the basic interface for all components which have properties that can be set or get.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Gaudi::Interfaces::IOptionsSvc & getOptsSvc()
Direct access to Gaudi::Interfaces::IOptionsSvc implementation.
Definition of the MsgStream class used to transmit messages.
Trivial Algorithm for tutorial purposes.
void readHandler(Gaudi::Details::PropertyBase &)
Callbacks for properties.
Gaudi::Property< double > m_double
Gaudi::Property< std::map< std::string, std::string > > m_strmap
Gaudi::Property< unsigned long long > m_uint64
Gaudi::Property< std::vector< std::pair< double, double > > > u_doublepairarray
Gaudi::Property< std::vector< std::pair< int, int > > > u_intpairarray
Gaudi::Property< std::vector< int > > p_intarray
Gaudi::Property< int > m_int
These data members are used in the execution of this algorithm They are set in the initialization pha...
Gaudi::Property< std::vector< std::string > > p_stringarray
Gaudi::Property< std::string > p_string
StatusCode finalize() override
Gaudi::Property< bool > m_bool
Gaudi::Property< std::vector< double > > u_doublearrayunits
Gaudi::Property< bool > p_bool
StatusCode initialize() override
Three mandatory member functions of any algorithm.
Gaudi::Property< std::vector< long long > > m_int64array
Gaudi::Property< std::vector< bool > > p_boolarray
Gaudi::Property< long long > m_int64
Gaudi::Property< std::vector< bool > > m_boolarray
Gaudi::PropertyWithReadHandler< double > p_double
Gaudi::Property< std::set< std::string > > m_stringset
Gaudi::Property< std::vector< int > > m_intarray
Gaudi::Property< std::vector< unsigned long long > > m_uint64array
Gaudi::CheckedProperty< int > p_int
Gaudi::Property< std::string > m_string
Gaudi::Property< std::vector< std::string > > m_stringarray
Gaudi::Property< std::unordered_set< float > > m_floatuset
Gaudi::Property< std::vector< double > > p_doublearray
PropertyAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor of this form must be provided.
StatusCode execute() override
void updateHandler(Gaudi::Details::PropertyBase &)
Gaudi::Property< std::vector< double > > m_emptyarray
Gaudi::Property< std::vector< double > > m_doublearray
Gaudi::Property< std::vector< double > > u_doublearray
Gaudi::Property< std::set< int > > m_intset
StatusCode setPropertyRepr(const std::string &n, const std::string &r) override
This class is used for returning status codes from appropriate routines.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
ParsingErrorPolicy setParsingErrorPolicy(ParsingErrorPolicy p)
Stream & ostream_joiner(Stream &os, Iterator first, Iterator last, Separator sep, OutputElement output=OutputElement{})
GAUDI_API const std::vector< std::string > cmdLineArgs()
Command line arguments including executable name as arg[0] as vector of strings.
Gaudi::ParticleID abs(const Gaudi::ParticleID &p)
Return the absolute value for a PID.