#ifndef ROOT_TEnv #define ROOT_TEnv //+SEQ,CopyRight,T=NOINCLUDE. ////////////////////////////////////////////////////////////////////////// // // // TEnv // // // // The TEnv class reads a config file, by default .rootrc. Three types // // of .rootrc files are read: global, user and local files. The global // // file resides in $ROOTSYS, the user file in ~/ and the local file in // // the current working directory. // // The format of the .rootrc file is similar to the .Xdefaults format: // // // // ..[(type)]: // // // // Where is either, Unix, Mac or Dos (anything from MS), // // the root name as given in the TROOT ctor, // // the current program name and // // is the resource name, with optionally a type specification. // // // // E.g.: // // // // Unix.rint.Root.DynamicPath: .:$ROOTSYS/lib:~/lib // // Rint.Root.Debug: FALSE // // TH.Root.Debug: YES // // *.Root.MemStat: 1 // // // // and or may be the wildcard "*". // // A # in the first column starts comment line. // // // // Currently the following resources are defined: // // Root.Debug (bool) (*) // // Root.MemStat (int) (*) // // Root.MemStat.size (int) (*) // // Root.MemStat.cnt (int) (*) // // Root.DynamicPath (string) // // Rint.Logon (string) // // Rint.Logoff (string) // // // // (*) work only with the since no is available // // at time of initialization. // // // // Note that the .rootrc config files contain the config for all ROOT // // based applications. // // // ////////////////////////////////////////////////////////////////////////// //*KEEP,TObject. #include "TObject.h" //*KEEP,TString. #include "TString.h" //*KEND. class TOrdCollection; class TEnv; class TEnvParser; class TReadEnvParser; class TWriteEnvParser; enum EEnvLevel { kEnvGlobal, kEnvUser, kEnvLocal, kEnvChange, kEnvAll }; ////////////////////////////////////////////////////////////////////////// // // // TEnvRec // // // // Individual TEnv records. // // // ////////////////////////////////////////////////////////////////////////// class TEnvRec : public TObject { friend class TEnv; friend class TEnvParser; friend class TReadEnvParser; friend class TWriteEnvParser; private: TString fName; TString fType; TString fValue; EEnvLevel fLevel; Bool_t fModified; TObject *fObject; TEnvRec() { } TEnvRec(const char *n, const char *v, const char *t, EEnvLevel l); TEnvRec(const char *n, const TString &v, const char *t, EEnvLevel l); void ChangeValue(const char *v, const char *t, EEnvLevel l); void ChangeValue(const TString &v, const char *t, EEnvLevel l); TString ExpandValue(const char *v); void Read(TObject *obj); void Read(const Text_t *name) { TObject::Read(name); } void Write(TObject *obj); void Write(const Text_t *name=0, Int_t opt=0, Int_t bufs=0) { TObject::Write(name, opt, bufs); } Int_t Compare(TObject *obj); }; ////////////////////////////////////////////////////////////////////////// // // // TEnv // // // ////////////////////////////////////////////////////////////////////////// class TEnv : public TObject { private: TOrdCollection *fTable; TString fRcName; const char *Getvalue(const char *name); public: TEnv(const char *name=""); ~TEnv(); TOrdCollection *GetTable() { return fTable; } Bool_t Defined(const char *name) { return Getvalue(name) != 0; } int GetValue(const char *name, int dflt); const char *GetValue(const char *name, const char *dflt); TObject *GetValue(const char *name, TObject *dflt); void SetValue(const char *name, const char *value, EEnvLevel level = kEnvChange, const char *type = 0); void SetValue(const char *name, const TString &value, EEnvLevel level, const char *type); void SetValue(const char *name, EEnvLevel level = kEnvChange); void SetValue(const char *name, int value); void SetValue(const char *name, double value); TEnvRec *Lookup(const char *n); void ReadFile(const char *fname, EEnvLevel level); void Save(); void SaveLevel(EEnvLevel level); void Print(Option_t *option=""); void PrintEnv(EEnvLevel level = kEnvAll); ClassDef(TEnv,0) //Handle ROOT configuration resources }; R__EXTERN TEnv *gEnv; #endif