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