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

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