ATLAS Offline Software
Loading...
Searching...
No Matches
MetaObject.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#ifndef SAMPLE_HANDLER_META_OBJECT_HH
8#define SAMPLE_HANDLER_META_OBJECT_HH
9
12
13#include <string>
14#include <TCollection.h>
15
16namespace SH
17{
29 std::string dbg (const MetaObject& obj, unsigned verbosity = 0);
30
31
38
39
40
47 class MetaObject : public TCollection
48 {
49 //
50 // public interface
51 //
52
54 public:
72
73
74
79 public:
80 void testInvariant () const;
81
82
89 public:
91
92
99 public:
100 MetaObject (const MetaObject& that);
101
102
107 public:
108 virtual ~MetaObject ();
109
110
119 public:
121
122
127 public:
128 void swap (MetaObject& that);
129
130
138 public:
139 void remove (const std::string& name);
140
141
152 public:
153 void addReplace (TNamed *meta_swallow);
154
155
163 public:
164 TObject *get (const std::string& name);
165 const TObject *get (const std::string& name) const;
166
167
178 public:
179 [[deprecated("please use castDouble instead")]]
180 double getDouble (const std::string& name, double def_val = 0) const;
181
196 public:
197 [[deprecated("please use castString instead")]]
198 std::string getString (const std::string& name, const std::string& def_val = "") const;
199
200
211 public:
212 template<class T> T castT(const std::string& name, T def_val,
213 CastMode mode) const;
214
215
226 public:
227 double castDouble (const std::string& name, double def_val = 0,
228 CastMode mode = CAST_ERROR_THROW) const;
229
244 public:
245 std::string castString (const std::string& name, const std::string& def_val = "",
246 CastMode mode = CAST_ERROR_THROW) const;
247
248
259 public:
260 int castInteger (const std::string& name, int def_val = 0,
261 CastMode mode = CAST_ERROR_THROW) const;
262
263
274 public:
275 bool castBool (const std::string& name, bool def_val = false,
276 CastMode mode = CAST_ERROR_THROW) const;
277
286 public:
287 void setDouble (const std::string& name, double value);
288
297 public:
298 void setString (const std::string& name, const std::string& value);
299
308 public:
309 void setInteger (const std::string& name, int value);
310
319 public:
320 void setBool (const std::string& name, bool value);
321
330 public:
331 template<class T> void setT(const std::string& name, T value){
333 addReplace (new MetaData<T> (name, value));
334 }
335
349 public:
350 void fetch (const MetaObject& source);
351
352
360 public:
361 void fetchDefaults (const MetaObject& source);
362
363
375 public:
376 void fetchFromString(const std::string& source);
377
378
386 public:
387 std::string dumpToString() const;
388
389
390 //
391 // method inherited from TCollection
392 //
393
401 public:
402 virtual void Add (TObject *meta_swallow) override;
403 virtual void Add (TObject *meta_swallow, Option_t*) override;
404
405
410 public:
411 virtual void Clear (Option_t *option = "") override;
412
413
418 public:
419 virtual void Delete (Option_t *option = "") override;
420
421
426 public:
427 virtual Int_t GetEntries () const override;
428
429
434 public:
435 virtual Int_t GetSize () const override;
436
437
447 public:
448 virtual TObject **GetObjectRef (const TObject *meta) const override;
449
450
458 public:
459 virtual TIterator *MakeIterator (Bool_t dir = kIterForward) const override;
460
461
469 public:
470 virtual TObject *Remove (TObject *meta) override;
471
472 //
473 // private interface
474 //
475
477 private:
479
481 };
482}
483
484#endif
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:219
static Double_t a
A class implementing a templatized version of the meta-data.
Definition MetaData.h:19
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.
virtual void Delete(Option_t *option="") override
clear out the content of the collection
void addReplace(TNamed *meta_swallow)
add a meta-data object and remove any existing meta-data with the same name
virtual TObject * Remove(TObject *meta) override
remove the given object from the list
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
CastMode
the different modes for casts
Definition MetaObject.h:56
@ CAST_NOCAST_DEFAULT
cast and return the default value if the input has the wrong type
Definition MetaObject.h:70
@ CAST_ERROR_DEFAULT
cast and return the default value if the cast fails
Definition MetaObject.h:62
@ CAST_ERROR_THROW
cast and throw if the cast fails (not if the input is not found)
Definition MetaObject.h:59
@ 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:66
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
virtual void Add(TObject *meta_swallow) override
add another object to the collection
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
ClassDefOverride(MetaObject, 1)
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
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const override
make a new iterator for this collection
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 void Add(TObject *meta_swallow, Option_t *) override
virtual Int_t GetEntries() const override
return the number of entries of this collection
virtual void Clear(Option_t *option="") override
clear out the content of the collection
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
std::string dumpToString() const
dump the meta-data to a string
TList * m_dataList
the actual meta-data list
Definition MetaObject.h:478
TObject * get(const std::string &name)
the meta-data object with the given name
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
double getDouble(const std::string &name, double def_val=0) const
the meta-data double with the given name
virtual Int_t GetSize() const override
return the size of this collection
virtual TObject ** GetObjectRef(const TObject *meta) const override
return pointer to pointer of object meta
void setT(const std::string &name, T value)
set the meta-data element with the given name
Definition MetaObject.h:331
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition PrunDriver.h:15
-diff