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

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