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;
106 info() <<
"After Initialization having read the JobOptions file..." <<
endmsg;
129 std::ostringstream os;
144 for (
unsigned int i = 0; i < doublearrayunits.size(); i++ ) {
146 if ( !essentiallyEqual( doublearrayunits[i], doublearray[i] ) ) {
147 error() <<
format(
"DoubleArrayWithUnits[%d] = %g and should be %g", i, doublearrayunits[i], doublearray[i] )
150 info() <<
format(
"DoubleArrayWithUnits[%d] = %g", i, doublearrayunits[i] ) <<
endmsg;
157 info() <<
"===============Checking Property Verifier ===============" <<
endmsg;
159 info() <<
"Playing with PropertyVerifiers..." <<
endmsg;
161 p_int.verifier().setBounds( 0, 200 );
166 info() <<
format(
"PInt= %d [should be 155, bounds are %d, %d]", (
int)
p_int, (
int)
p_int.verifier().lower(),
167 (
int)
p_int.verifier().upper() )
171 }
catch ( ... ) {
info() <<
"Got an exception when setting a value outside bounds" <<
endmsg; }
177 info() <<
"===============Checking Property CallBaks ===============" <<
endmsg;
183 info() <<
"Value obtained is: " << d <<
endmsg;
192 info() <<
"==========Checking Accesing Properties by string=========" <<
endmsg;
197 error() <<
"Unable to locate the ApplicationMgr" <<
endmsg;
199 std::string value(
"empty" );
200 appmgr->getProperty(
"ExtSvc", value ).ignore();
201 info() <<
" Got property ApplicationMgr.ExtSvc = " << value <<
";" <<
endmsg;
203 appmgr->setPropertyRepr(
"ExtSvc",
"[\"EvtDataSvc/EventDataSvc\", \"DetDataSvc/DetectorDataSvc\"]" ).ignore();
204 info() <<
" Set property ApplicationMgr.ExtSvc = "
205 <<
" [\"EvtDataSvc/EventDataSvc\", \"DetDataSvc/DetectorDataSvc\"]"
207 appmgr->getProperty(
"ExtSvc", value ).ignore();
208 info() <<
" Got property ApplicationMgr.ExtSvc = " << value <<
";" <<
endmsg;
210 appmgr->setPropertyRepr(
"ExtSvc",
"[ 'EventDataSvc', 'DetectorDataSvc']" ).ignore();
211 info() <<
" Set property ApplicationMgr.ExtSvc = "
212 <<
" [ 'EventDataSvc', 'DetectorDataSvc']"
214 appmgr->getProperty(
"ExtSvc", value ).ignore();
215 info() <<
" Got property ApplicationMgr.ExtSvc = " << value <<
";" <<
endmsg;
218 std::vector<std::tuple<std::string, bool>> cases = {
219 std::make_tuple(
"true",
true ), std::make_tuple(
"false",
false ), std::make_tuple(
"True",
true ),
220 std::make_tuple(
"False",
false ), std::make_tuple(
"TRUE",
true ), std::make_tuple(
"FALSE",
false ),
221 std::make_tuple(
"T",
true ),
222 std::make_tuple(
"F",
false ),
223 std::make_tuple(
"10",
true ),
226 for (
auto& c : cases ) {
231 if ( !sc || (
p_bool != std::get<1>( c ) ) ) {
232 error() <<
"PBool can not be set to " << std::get<0>( c ) <<
endmsg;
237 if ( !sc || (
m_bool != std::get<1>( c ) ) ) {
error() <<
"Bool can not be set to " << std::get<0>( c ) <<
endmsg; }
243 newlog <<
MSG::DEBUG <<
"This should be printed if threshold is DEBUG" <<
endmsg;
244 newlog <<
MSG::INFO <<
"This should be printed if threshold is INFO" <<
endmsg;
246 newlog <<
MSG::ERROR <<
"This should be printed if threshold is ERROR" <<
endmsg;
247 newlog <<
MSG::FATAL <<
"This should be printed if threshold is FATAL" <<
endmsg;
254 info() <<
"=================================================" <<
endmsg;
256 auto opt_items = opts.items();
257 ostream_joiner(
info() <<
"Dump of the property catalogue:\n", opt_items,
'\n',
259 return os << std::get<0>( item ) <<
": " << std::get<1>( item );
262 info() <<
"=================================================" <<
endmsg;
265 opts.set(
name() +
'.' +
"PInt",
"154" );
271 info() <<
"Try to assign invalid value to DoubleArray" <<
endmsg;
272 opts.set(
name() +
'.' +
"DoubleArray",
"{\"12.12\", \"13.13\"}" );
276 info() <<
"Try to assign invalid value to StringMap" <<
endmsg;
277 opts.set(
name() +
'.' +
"StringMap",
"{\"one\", {\"une\", \"eins\"}}" );
283 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< std::string > p_string2
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.