| 1 | #ifndef MARS_MParContainer | 
|---|
| 2 | #define MARS_MParContainer | 
|---|
| 3 |  | 
|---|
| 4 | ////////////////////////////////////////////////////////////////////////// | 
|---|
| 5 | //                                                                      // | 
|---|
| 6 | // MParContainer                                                        // | 
|---|
| 7 | //                                                                      // | 
|---|
| 8 | // The basis for all parameter containers                               // | 
|---|
| 9 | //                                                                      // | 
|---|
| 10 | ////////////////////////////////////////////////////////////////////////// | 
|---|
| 11 | #ifndef MARS_MAGIC | 
|---|
| 12 | #include "MAGIC.h" | 
|---|
| 13 | #endif | 
|---|
| 14 | #ifndef ROOT_TObject | 
|---|
| 15 | #include <TObject.h> | 
|---|
| 16 | #endif | 
|---|
| 17 | #ifndef ROOT_TString | 
|---|
| 18 | #include <TString.h> | 
|---|
| 19 | #endif | 
|---|
| 20 |  | 
|---|
| 21 | // gcc 3.2 | 
|---|
| 22 | #include <iosfwd> | 
|---|
| 23 | //class ofstream; | 
|---|
| 24 | //class ifstream; | 
|---|
| 25 |  | 
|---|
| 26 | class TEnv; | 
|---|
| 27 | class TArrayD; | 
|---|
| 28 | class TDataMember; | 
|---|
| 29 | class TMethodCall; | 
|---|
| 30 |  | 
|---|
| 31 | class MLog; | 
|---|
| 32 | class MStatusDisplay; | 
|---|
| 33 |  | 
|---|
| 34 | class MParContainer : public TObject | 
|---|
| 35 | { | 
|---|
| 36 | private: | 
|---|
| 37 | static TObjArray fgListMethodCall; //! | 
|---|
| 38 |  | 
|---|
| 39 | protected: | 
|---|
| 40 | TString fName;        // parameter container identifier (name) | 
|---|
| 41 | TString fTitle;       // parameter container title | 
|---|
| 42 |  | 
|---|
| 43 | MLog   *fLog;         // The general log facility for this object, initialized with the global object | 
|---|
| 44 |  | 
|---|
| 45 | // This data member was added later, because for calculating the | 
|---|
| 46 | // Checksum root (3.02/07) ignores ClassDef=0 all data members | 
|---|
| 47 | // which are not persistent (//!) are used. To make the two | 
|---|
| 48 | // class versions CheckSum-compatible (only getting rid of a | 
|---|
| 49 | // warning) this member is persistent. | 
|---|
| 50 | MStatusDisplay *fDisplay; //! | 
|---|
| 51 |  | 
|---|
| 52 | private: | 
|---|
| 53 | enum { | 
|---|
| 54 | kIsSavedAsPrimitive = BIT(15) | 
|---|
| 55 | }; | 
|---|
| 56 |  | 
|---|
| 57 | Bool_t  fReadyToSave; // should be set to true if the contents of the container is changed somehow | 
|---|
| 58 |  | 
|---|
| 59 | TClass *GetConstructor(const char *name) const; | 
|---|
| 60 |  | 
|---|
| 61 | public: | 
|---|
| 62 | enum { | 
|---|
| 63 | kEnableGraphicalOutput = BIT(16) | 
|---|
| 64 | }; | 
|---|
| 65 |  | 
|---|
| 66 | MParContainer(const char *name="", const char *title=""); | 
|---|
| 67 | MParContainer(const TString &name, const TString &title); | 
|---|
| 68 | MParContainer(const MParContainer &named); | 
|---|
| 69 | MParContainer& operator=(const MParContainer& rhs); | 
|---|
| 70 | virtual ~MParContainer(); | 
|---|
| 71 |  | 
|---|
| 72 | virtual TObject    *Clone(const char *newname="") const; | 
|---|
| 73 | virtual Int_t       Compare(const TObject *obj) const; | 
|---|
| 74 | virtual void        Copy(TObject &named) | 
|---|
| 75 | #if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01) | 
|---|
| 76 | const | 
|---|
| 77 | #endif | 
|---|
| 78 | ; | 
|---|
| 79 | virtual void        FillBuffer(char *&buffer); | 
|---|
| 80 |  | 
|---|
| 81 | static const TString GetDescriptor(const TObject &o); | 
|---|
| 82 |  | 
|---|
| 83 | virtual const TString GetDescriptor() const; | 
|---|
| 84 | virtual const TString GetUniqueName() const; | 
|---|
| 85 | virtual const char   *GetName() const       { return fName.Data(); } | 
|---|
| 86 | virtual const char   *GetTitle() const      { return fTitle.Data(); } | 
|---|
| 87 | virtual ULong_t       Hash() const          { return fName.Hash(); } | 
|---|
| 88 | virtual Bool_t        IsSortable() const    { return kTRUE; } | 
|---|
| 89 |  | 
|---|
| 90 | virtual void   SetName(const char *name); // *MENU* | 
|---|
| 91 | virtual void   SetObject(const char *name, const char *title); | 
|---|
| 92 | virtual void   SetTitle(const char *title=""); // *MENU* | 
|---|
| 93 | virtual void   ls(Option_t *option="") const; | 
|---|
| 94 | virtual void   Print(Option_t *option="") const; | 
|---|
| 95 | virtual Int_t  Sizeof() const; | 
|---|
| 96 | virtual void   SavePrimitive(ostream &out, Option_t *o=""); | 
|---|
| 97 | virtual void   SavePrimitive(ofstream &out, Option_t *o=""); | 
|---|
| 98 |  | 
|---|
| 99 | virtual MParContainer *New() const; | 
|---|
| 100 | virtual void   SetLogStream(MLog *lg) { fLog = lg; } | 
|---|
| 101 | virtual void   Reset(); | 
|---|
| 102 | virtual Bool_t IsReadyToSave() const             { return fReadyToSave; } | 
|---|
| 103 | virtual void   SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; } | 
|---|
| 104 | virtual Bool_t IsSavedAsPrimitive() const        { return TestBit(kIsSavedAsPrimitive); } | 
|---|
| 105 | virtual void   EnableGraphicalOutput(Bool_t flag=kTRUE) { flag ? SetBit(kEnableGraphicalOutput) : ResetBit(kEnableGraphicalOutput);} | 
|---|
| 106 | virtual Bool_t IsGraphicalOutputEnabled() const  { return TestBit(kEnableGraphicalOutput); } | 
|---|
| 107 | virtual void   SetVariables(const TArrayD &)     { AbstractMethod("SetVariables(const TArrayD&)"); } | 
|---|
| 108 |  | 
|---|
| 109 | virtual void SetDisplay(MStatusDisplay *d) { fDisplay = d; } | 
|---|
| 110 |  | 
|---|
| 111 | virtual void StreamPrimitive(ostream &out) const; | 
|---|
| 112 |  | 
|---|
| 113 | TMethodCall *GetterMethod(const char *name) const; | 
|---|
| 114 |  | 
|---|
| 115 | Bool_t WriteDataMember(ostream &out, const char *member, Double_t scale=1) const; | 
|---|
| 116 | Bool_t WriteDataMember(ostream &out, const TDataMember *member, Double_t scale=1) const; | 
|---|
| 117 | Bool_t WriteDataMember(ostream &out, const TList *list) const; | 
|---|
| 118 |  | 
|---|
| 119 | virtual void AsciiRead(istream &fin); | 
|---|
| 120 | virtual Bool_t AsciiWrite(ostream &out) const; | 
|---|
| 121 |  | 
|---|
| 122 | Int_t Read(const char *name=NULL); | 
|---|
| 123 |  | 
|---|
| 124 | virtual void GetNames(TObjArray &arr) const; | 
|---|
| 125 | virtual void SetNames(TObjArray &arr); | 
|---|
| 126 |  | 
|---|
| 127 | virtual Int_t  TestEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE); | 
|---|
| 128 | virtual Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE); | 
|---|
| 129 | virtual Bool_t WriteEnv(TEnv &env, TString prefix, Bool_t print=kFALSE) const; | 
|---|
| 130 |  | 
|---|
| 131 | Bool_t ReadEnv(const TEnv &env, Bool_t print=kFALSE) { return ReadEnv(env, "", print); } | 
|---|
| 132 | Bool_t WriteEnv(TEnv &env, Bool_t print=kFALSE) const { return WriteEnv(env, "", print); } | 
|---|
| 133 |  | 
|---|
| 134 | Bool_t IsEnvDefined(const TEnv &env, TString prefix, TString postfix, Bool_t print) const; | 
|---|
| 135 | Bool_t IsEnvDefined(const TEnv &env, TString name, Bool_t print) const; | 
|---|
| 136 |  | 
|---|
| 137 | Int_t       GetEnvValue(const TEnv &env, TString prefix, TString postfix, Int_t dflt) const; | 
|---|
| 138 | Double_t    GetEnvValue(const TEnv &env, TString prefix, TString postfix, Double_t dflt) const; | 
|---|
| 139 | const char *GetEnvValue(const TEnv &env, TString prefix, TString postfix, const char *dflt) const; | 
|---|
| 140 |  | 
|---|
| 141 | Int_t       GetEnvValue(const TEnv &env, TString prefix, Int_t dflt) const; | 
|---|
| 142 | Double_t    GetEnvValue(const TEnv &env, TString prefix, Double_t dflt) const; | 
|---|
| 143 | const char *GetEnvValue(const TEnv &env, TString prefix, const char *dflt) const; | 
|---|
| 144 |  | 
|---|
| 145 | template <class T> T GetEnvValue2Imp(const TEnv &env, const TString &prefix, const TString &postfix, T dflt, Bool_t print=kFALSE) const; | 
|---|
| 146 | Int_t       GetEnvValue2(const TEnv &env, const TString &prefix, const TString &postfix, Int_t dflt, Bool_t print=kFALSE) const; | 
|---|
| 147 | Double_t    GetEnvValue2(const TEnv &env, const TString &prefix, const TString &postfix, Double_t dflt, Bool_t print=kFALSE) const; | 
|---|
| 148 | const char *GetEnvValue2(const TEnv &env, const TString &prefix, const TString &postfix, const char *dflt, Bool_t print=kFALSE) const; | 
|---|
| 149 |  | 
|---|
| 150 | MParContainer *GetNewObject(const char *name, const char *base) const; | 
|---|
| 151 | MParContainer *GetNewObject(const char *name, TClass *base=MParContainer::Class()) const; | 
|---|
| 152 |  | 
|---|
| 153 | void RecursiveRemove(TObject *obj); | 
|---|
| 154 |  | 
|---|
| 155 | ClassDef(MParContainer, 0)  //The basis for all parameter containers | 
|---|
| 156 | }; | 
|---|
| 157 |  | 
|---|
| 158 | //! | 
|---|
| 159 | //! Maybe we can add a static parameter list to MEvtLoop | 
|---|
| 160 | //! Also we can derive MEvtLoop from MTaskList to have a static tasklist, too | 
|---|
| 161 | //! | 
|---|
| 162 |  | 
|---|
| 163 | // FIXME: Move as (persistent) static data member to MParContainer | 
|---|
| 164 | R__EXTERN TList *gListOfPrimitives; // instantiation in MEvtLoop | 
|---|
| 165 |  | 
|---|
| 166 | /* | 
|---|
| 167 | class MParContainer : public TNamed | 
|---|
| 168 | { | 
|---|
| 169 | protected: | 
|---|
| 170 | MLog    *fLog;         //! The general log facility for this object, initialized with the global object | 
|---|
| 171 |  | 
|---|
| 172 | private: | 
|---|
| 173 | Bool_t   fReadyToSave; //! should be set to true if the contents of the container is changed somehow | 
|---|
| 174 |  | 
|---|
| 175 | public: | 
|---|
| 176 | MParContainer(const char *name="", const char *title="") : TNamed(name, title), fLog(&gLog), fReadyToSave(kFALSE) { } | 
|---|
| 177 | MParContainer(const TString &name, const TString &title) : TNamed(name, title), fLog(&gLog), fReadyToSave(kFALSE) { } | 
|---|
| 178 |  | 
|---|
| 179 | void SetLogStream(MLog *lg)                      { fLog = lg; } | 
|---|
| 180 |  | 
|---|
| 181 | virtual void   Reset()                           {  } | 
|---|
| 182 |  | 
|---|
| 183 | virtual Bool_t IsReadyToSave()                   { return fReadyToSave; } | 
|---|
| 184 | virtual void   SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; } | 
|---|
| 185 |  | 
|---|
| 186 | virtual void AsciiRead(ifstream &fin); | 
|---|
| 187 | virtual void AsciiWrite(ofstream &fout) const; | 
|---|
| 188 |  | 
|---|
| 189 | ClassDef(MParContainer, 0)  //The basis for all parameter containers | 
|---|
| 190 | }; | 
|---|
| 191 | */ | 
|---|
| 192 | #endif | 
|---|
| 193 |  | 
|---|
| 194 |  | 
|---|