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