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

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