ATLAS Offline Software
Loading...
Searching...
No Matches
MetaObject.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef SAMPLE_HANDLER_META_OBJECT_HH
6#define SAMPLE_HANDLER_META_OBJECT_HH
7
8// - 2012.
9// Distributed under the Boost Software License, Version 1.0.
10// (See accompanying file LICENSE_1_0.txt or copy at
11// http://www.boost.org/LICENSE_1_0.txt)
12
13// Please feel free to contact me (krumnack@iastate.edu) for bug
14// reports, feature suggestions, praise and complaints.
15
16
17
20
21#include <string>
22#include <TCollection.h>
23
24namespace SH
25{
37 std::string dbg (const MetaObject& obj, unsigned verbosity = 0);
38
39
46
47
48
55 class MetaObject : public TCollection
56 {
57 //
58 // public interface
59 //
60
62 public:
80
81
82
87 public:
88 void testInvariant () const;
89
90
97 public:
99
100
107 public:
108 MetaObject (const MetaObject& that);
109
110
115 public:
116 virtual ~MetaObject ();
117
118
127 public:
129
130
135 public:
136 void swap (MetaObject& that);
137
138
146 public:
147 void remove (const std::string& name);
148
149
160 public:
161 void addReplace (TNamed *meta_swallow);
162
163
171 public:
172 TObject *get (const std::string& name);
173 const TObject *get (const std::string& name) const;
174
175
186 public:
187 [[deprecated("please use castDouble instead")]]
188 double getDouble (const std::string& name, double def_val = 0) const;
189
204 public:
205 [[deprecated("please use castString instead")]]
206 std::string getString (const std::string& name, const std::string& def_val = "") const;
207
208
219 public:
220 template<class T> T castT(const std::string& name, T def_val,
221 CastMode mode) const;
222
223
234 public:
235 double castDouble (const std::string& name, double def_val = 0,
236 CastMode mode = CAST_ERROR_THROW) const;
237
252 public:
253 std::string castString (const std::string& name, const std::string& def_val = "",
254 CastMode mode = CAST_ERROR_THROW) const;
255
256
267 public:
268 int castInteger (const std::string& name, int def_val = 0,
269 CastMode mode = CAST_ERROR_THROW) const;
270
271
282 public:
283 bool castBool (const std::string& name, bool def_val = false,
284 CastMode mode = CAST_ERROR_THROW) const;
285
294 public:
295 void setDouble (const std::string& name, double value);
296
305 public:
306 void setString (const std::string& name, const std::string& value);
307
316 public:
317 void setInteger (const std::string& name, int value);
318
327 public:
328 void setBool (const std::string& name, bool value);
329
338 public:
339 template<class T> void setT(const std::string& name, T value){
341 addReplace (new MetaData<T> (name, value));
342 }
343
357 public:
358 void fetch (const MetaObject& source);
359
360
368 public:
369 void fetchDefaults (const MetaObject& source);
370
371
383 public:
384 void fetchFromString(const std::string& source);
385
386
394 public:
395 std::string dumpToString();
396
397
398 //
399 // method inherited from TCollection
400 //
401
409 public:
410 virtual void Add (TObject *meta_swallow);
411
412
417 public:
418 virtual void Clear (Option_t *option = "");
419
420
425 public:
426 virtual void Delete (Option_t *option = "");
427
428
433 public:
434 virtual Int_t GetEntries () const;
435
436
446 public:
447 virtual TObject **GetObjectRef (const TObject *meta) const;
448
449
457 public:
458 virtual TIterator *MakeIterator (Bool_t dir = kIterForward) const;
459
460
468 public:
469 virtual TObject *Remove (TObject *meta);
470
471 //
472 // private interface
473 //
474
476 private:
478
480 };
481}
482
483#endif
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:231
static Double_t a
A class implementing a templatized version of the meta-data.
Definition MetaData.h:27
double castDouble(const std::string &name, double def_val=0, CastMode mode=CAST_ERROR_THROW) const
the meta-data double with the given name
void fetchDefaults(const MetaObject &source)
fetch the meta-data from the given sample not present in this sample.
void addReplace(TNamed *meta_swallow)
add a meta-data object and remove any existing meta-data with the same name
virtual ~MetaObject()
standard destructor
bool castBool(const std::string &name, bool def_val=false, CastMode mode=CAST_ERROR_THROW) const
the meta-data boolean with the given name
virtual void Delete(Option_t *option="")
clear out the content of the collection
CastMode
the different modes for casts
Definition MetaObject.h:64
@ CAST_NOCAST_DEFAULT
cast and return the default value if the input has the wrong type
Definition MetaObject.h:78
@ CAST_ERROR_DEFAULT
cast and return the default value if the cast fails
Definition MetaObject.h:70
@ CAST_ERROR_THROW
cast and throw if the cast fails (not if the input is not found)
Definition MetaObject.h:67
@ CAST_NOCAST_THROW
do not cast and throw if the input has the wrong type (not if the input is not found)
Definition MetaObject.h:74
std::string dumpToString()
dump the meta-data to a string
void fetch(const MetaObject &source)
fetch the meta-data from the given sample.
const TObject * get(const std::string &name) const
T castT(const std::string &name, T def_val, CastMode mode) const
the meta-data element with the given name
void swap(MetaObject &a, MetaObject &b)
standard swap
void setInteger(const std::string &name, int value)
set the meta-data integer with the given name
std::string getString(const std::string &name, const std::string &def_val="") const
the meta-data string with the given name
void remove(const std::string &name)
remove all meta-information with the given name
void setDouble(const std::string &name, double value)
set the meta-data double with the given name
void setString(const std::string &name, const std::string &value)
set the meta-data string with the given name
void fetchFromString(const std::string &source)
fetch the meta-data from a given string
MetaObject(const MetaObject &that)
standard copy constructor
virtual TObject * Remove(TObject *meta)
remove the given object from the list
virtual Int_t GetEntries() const
return the number of entries of this collection
ClassDef(MetaObject, 1)
void swap(MetaObject &that)
standard swap
std::string castString(const std::string &name, const std::string &def_val="", CastMode mode=CAST_ERROR_THROW) const
the meta-data string with the given name
std::string dbg(const MetaObject &obj, unsigned verbosity=0)
the debugging info of this object
void testInvariant() const
test the invariant of this object
MetaObject()
standard constructor
virtual TObject ** GetObjectRef(const TObject *meta) const
return pointer to pointer of object meta
virtual void Add(TObject *meta_swallow)
add another object to the collection
TList * m_dataList
the actual meta-data list
Definition MetaObject.h:477
TObject * get(const std::string &name)
the meta-data object with the given name
virtual void Clear(Option_t *option="")
clear out the content of the collection
int castInteger(const std::string &name, int def_val=0, CastMode mode=CAST_ERROR_THROW) const
the meta-data integer with the given name
MetaObject & operator=(const MetaObject &that)
standard assignment operator
void setBool(const std::string &name, bool value)
set the meta-data boolean with the given name
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
make a new iterator for this collection
double getDouble(const std::string &name, double def_val=0) const
the meta-data double with the given name
void setT(const std::string &name, T value)
set the meta-data element with the given name
Definition MetaObject.h:339
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition PrunDriver.h:15
-diff