source: trunk/MagicSoft/Mars/mbase/MParContainer.h@ 6226

Last change on this file since 6226 was 5994, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 7.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 TEnv;
27class TArrayD;
28class TDataMember;
29class TMethodCall;
30
31class MLog;
32class MStatusDisplay;
33
34class MParContainer : public TObject
35{
36protected:
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
49private:
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 TClass *GetConstructor(const char *name) const;
57
58public:
59 enum {
60 kEnableGraphicalOutput = BIT(16)
61 };
62
63 MParContainer(const char *name="", const char *title="");
64 MParContainer(const TString &name, const TString &title);
65 MParContainer(const MParContainer &named);
66 MParContainer& operator=(const MParContainer& rhs);
67 virtual ~MParContainer();
68
69 virtual TObject *Clone(const char *newname="") const;
70 virtual Int_t Compare(const TObject *obj) const;
71 virtual void Copy(TObject &named)
72#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
73const
74#endif
75 ;
76 virtual void FillBuffer(char *&buffer);
77
78 static const TString GetDescriptor(const TObject &o);
79
80 virtual const TString GetDescriptor() const;
81 virtual const TString GetUniqueName() const;
82 virtual const char *GetName() const { return fName.Data(); }
83 virtual const char *GetTitle() const { return fTitle.Data(); }
84 virtual ULong_t Hash() const { return fName.Hash(); }
85 virtual Bool_t IsSortable() const { return kTRUE; }
86
87 virtual void SetName(const char *name); // *MENU*
88 virtual void SetObject(const char *name, const char *title);
89 virtual void SetTitle(const char *title=""); // *MENU*
90 virtual void ls(Option_t *option="") const;
91 virtual void Print(Option_t *option="") const;
92 virtual Int_t Sizeof() const;
93 virtual void SavePrimitive(ofstream &out, Option_t *o="");
94
95 virtual MParContainer *New() const;
96 virtual void SetLogStream(MLog *lg) { fLog = lg; }
97 virtual void Reset();
98 virtual Bool_t IsReadyToSave() const { return fReadyToSave; }
99 virtual void SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; }
100 virtual Bool_t IsSavedAsPrimitive() const { return TestBit(kIsSavedAsPrimitive); }
101 virtual void EnableGraphicalOutput(Bool_t flag=kTRUE) { flag ? SetBit(kEnableGraphicalOutput) : ResetBit(kEnableGraphicalOutput);}
102 virtual Bool_t IsGraphicalOutputEnabled() const { return TestBit(kEnableGraphicalOutput); }
103 virtual void SetVariables(const TArrayD &) { AbstractMethod("SetVariables(const TArrayD&)"); }
104
105 virtual void SetDisplay(MStatusDisplay *d) { fDisplay = d; }
106
107 // FIXME: Change to ostream! Seems to be difficult, because
108 // MTaskListStreamPrimitive calls SavePrimitive(ofstream&).
109 // Maybe with a cast?
110 virtual void StreamPrimitive(ofstream &out) const;
111
112 TMethodCall *GetterMethod(const char *name) const;
113
114 Bool_t WriteDataMember(ostream &out, const char *member, Double_t scale=1) const;
115 Bool_t WriteDataMember(ostream &out, const TDataMember *member, Double_t scale=1) const;
116 Bool_t WriteDataMember(ostream &out, const TList *list) const;
117
118 virtual void AsciiRead(istream &fin);
119 virtual Bool_t AsciiWrite(ostream &out) const;
120
121 Int_t Read(const char *name=NULL) { return TObject::Read(name?name:(const char*)fName); }
122
123 virtual void GetNames(TObjArray &arr) const;
124 virtual void SetNames(TObjArray &arr);
125
126 virtual Int_t TestEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
127 virtual Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
128 virtual Bool_t WriteEnv(TEnv &env, TString prefix, Bool_t print=kFALSE) const;
129
130 Bool_t ReadEnv(const TEnv &env, Bool_t print=kFALSE) { return ReadEnv(env, "", print); }
131 Bool_t WriteEnv(TEnv &env, Bool_t print=kFALSE) const { return WriteEnv(env, "", print); }
132
133 Bool_t IsEnvDefined(const TEnv &env, TString prefix, TString postfix, Bool_t print) const;
134 Bool_t IsEnvDefined(const TEnv &env, TString name, Bool_t print) const;
135
136 Int_t GetEnvValue(const TEnv &env, TString prefix, TString postfix, Int_t dflt) const;
137 Double_t GetEnvValue(const TEnv &env, TString prefix, TString postfix, Double_t dflt) const;
138 const char *GetEnvValue(const TEnv &env, TString prefix, TString postfix, const char *dflt) const;
139
140 Int_t GetEnvValue(const TEnv &env, TString prefix, Int_t dflt) const;
141 Double_t GetEnvValue(const TEnv &env, TString prefix, Double_t dflt) const;
142 const char *GetEnvValue(const TEnv &env, TString prefix, const char *dflt) const;
143
144 MParContainer *GetNewObject(const char *name, const char *base) const;
145 MParContainer *GetNewObject(const char *name, TClass *base=MParContainer::Class()) const;
146
147 ClassDef(MParContainer, 0) //The basis for all parameter containers
148};
149
150//!
151//! Maybe we can add a static parameter list to MEvtLoop
152//! Also we can derive MEvtLoop from MTaskList to have a static tasklist, too
153//!
154
155// FIXME: Move as (persistent) static data member to MParContainer
156R__EXTERN TList *gListOfPrimitives; // instantiation in MEvtLoop
157
158/*
159class MParContainer : public TNamed
160{
161protected:
162 MLog *fLog; //! The general log facility for this object, initialized with the global object
163
164private:
165 Bool_t fReadyToSave; //! should be set to true if the contents of the container is changed somehow
166
167public:
168 MParContainer(const char *name="", const char *title="") : TNamed(name, title), fLog(&gLog), fReadyToSave(kFALSE) { }
169 MParContainer(const TString &name, const TString &title) : TNamed(name, title), fLog(&gLog), fReadyToSave(kFALSE) { }
170
171 void SetLogStream(MLog *lg) { fLog = lg; }
172
173 virtual void Reset() { }
174
175 virtual Bool_t IsReadyToSave() { return fReadyToSave; }
176 virtual void SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; }
177
178 virtual void AsciiRead(ifstream &fin);
179 virtual void AsciiWrite(ofstream &fout) const;
180
181 ClassDef(MParContainer, 0) //The basis for all parameter containers
182};
183*/
184#endif
185
186
Note: See TracBrowser for help on using the repository browser.