source: branches/MarsMoreSimulationTruth/mbase/MParContainer.h@ 20051

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