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