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

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