00001 #ifndef SAMPLE_HANDLER_META_OBJECT_HH
00002 #define SAMPLE_HANDLER_META_OBJECT_HH
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <SampleHandler/Global.h>
00015 #include <RootCoreUtils/Assert.h>
00016 #include <RootCoreUtils/Deprecated.h>
00017
00018 #include <string>
00019 #include <TCollection.h>
00020
00021 namespace SH
00022 {
00034 std::string dbg (const MetaObject& obj, unsigned verbosity = 0);
00035
00036
00042 void swap (MetaObject& a, MetaObject& b);
00043
00044
00045
00052 class MetaObject : public TCollection
00053 {
00054
00055
00056
00057
00059 public:
00060 enum CastMode
00061 {
00064 CAST_ERROR_THROW,
00065
00067 CAST_ERROR_DEFAULT,
00068
00071 CAST_NOCAST_THROW,
00072
00075 CAST_NOCAST_DEFAULT
00076 };
00077
00078
00079
00084 public:
00085 void testInvariant () const;
00086
00087
00094 public:
00095 MetaObject ();
00096
00097
00104 public:
00105 MetaObject (const MetaObject& that);
00106
00107
00112 public:
00113 virtual ~MetaObject ();
00114
00115
00124 public:
00125 MetaObject& operator = (const MetaObject& that);
00126
00127
00132 public:
00133 void swap (MetaObject& that);
00134
00135
00143 public:
00144 void remove (const std::string& name);
00145
00146
00157 public:
00158 void addReplace (TNamed *meta_swallow);
00159
00160
00168 public:
00169 TObject *get (const std::string& name);
00170 const TObject *get (const std::string& name) const;
00171
00172
00183 public:
00184 RCU_DEPRECATED ("please use castDouble instead")
00185 double getDouble (const std::string& name, double def_val = 0) const;
00186
00201 public:
00202 RCU_DEPRECATED ("please use castString instead")
00203 std::string getString (const std::string& name, const std::string& def_val = "") const;
00204
00205
00216 public:
00217 template<class T> T castT(const std::string& name, T def_val,
00218 CastMode mode) const;
00219
00220
00231 public:
00232 double castDouble (const std::string& name, double def_val = 0,
00233 CastMode mode = CAST_ERROR_THROW) const;
00234
00249 public:
00250 std::string castString (const std::string& name, const std::string& def_val = "",
00251 CastMode mode = CAST_ERROR_THROW) const;
00252
00253
00264 public:
00265 int castInteger (const std::string& name, int def_val = 0,
00266 CastMode mode = CAST_ERROR_THROW) const;
00267
00268
00279 public:
00280 bool castBool (const std::string& name, bool def_val = false,
00281 CastMode mode = CAST_ERROR_THROW) const;
00282
00291 public:
00292 void setDouble (const std::string& name, double value);
00293
00302 public:
00303 void setString (const std::string& name, const std::string& value);
00304
00313 public:
00314 void setInteger (const std::string& name, int value);
00315
00324 public:
00325 void setBool (const std::string& name, bool value);
00326
00335 public:
00336 template<class T> void setT(const std::string& name, T value){
00337 RCU_CHANGE_INVARIANT (this);
00338 addReplace (new MetaData<T> (name, value));
00339 }
00340
00354 public:
00355 void fetch (const MetaObject& source);
00356
00357
00365 public:
00366 void fetchDefaults (const MetaObject& source);
00367
00368
00380 public:
00381 void fetchFromString(const std::string& source);
00382
00383
00391 public:
00392 std::string dumpToString();
00393
00394
00395
00396
00397
00398
00406 public:
00407 virtual void Add (TObject *meta_swallow);
00408
00409
00414 public:
00415 virtual void Clear (Option_t *option = "");
00416
00417
00422 public:
00423 virtual void Delete (Option_t *option = "");
00424
00425
00430 public:
00431 virtual Int_t GetEntries () const;
00432
00433
00443 public:
00444 virtual TObject **GetObjectRef (const TObject *meta) const;
00445
00446
00454 public:
00455 virtual TIterator *MakeIterator (Bool_t dir = kIterForward) const;
00456
00457
00465 public:
00466 virtual TObject *Remove (TObject *meta);
00467
00468
00469
00470
00471
00473 private:
00474 TList *m_dataList;
00475
00476 ClassDef(MetaObject, 1);
00477 };
00478 }
00479
00480 #endif