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

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