Logo ROOT   6.08/07
Reference Guide
XrdROOT.h
Go to the documentation of this file.
1 // @(#)root/proofd:$Id$
2 // Author: G. Ganis June 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_XrdROOT
13 #define ROOT_XrdROOT
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // XrdProofdProtocol //
18 // //
19 // Authors: G. Ganis, CERN, 2007 //
20 // //
21 // Class describing a ROOT version //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 #include <list>
25 
26 #include "Xrd/XrdProtocol.hh"
27 #include "XProofProtocol.h"
28 #include "XrdOuc/XrdOucString.hh"
29 
30 #include "XrdProofdConfig.h"
31 
32 class XrdProofdManager;
33 class XrdSysLogger;
34 
35 class XrdROOT {
36 friend class XrdROOTMgr;
37 private:
38  int fStatus;
39  XrdOucString fDir;
40  XrdOucString fBinDir;
41  XrdOucString fDataDir;
42  XrdOucString fIncDir;
43  XrdOucString fLibDir;
44  XrdOucString fTag;
45  XrdOucString fExport;
46  XrdOucString fPrgmSrv;
47  kXR_int16 fSrvProtVers;
48 
49  XrdOucString fRelease;
50  XrdOucString fGitCommit;
52 
53  int fVrsMajor;
54  int fVrsMinor;
55  int fVrsPatch;
56 
57  int CheckDir(const char *dir);
59 
60 public:
61  XrdROOT(const char *dir, const char *tag, const char *bindir = 0,
62  const char *incdir = 0, const char *libdir = 0, const char *datadir = 0);
63  ~XrdROOT() { }
64 
65  const char *Dir() const { return fDir.c_str(); }
66  const char *BinDir() const { return fBinDir.c_str(); }
67  const char *DataDir() const { return fDataDir.c_str(); }
68  const char *IncDir() const { return fIncDir.c_str(); }
69  const char *LibDir() const { return fLibDir.c_str(); }
70  const char *Export() const { return fExport.c_str(); }
71  const char *GitCommit() const { return fGitCommit.c_str(); }
72  bool IsParked() const { return ((fStatus == 2) ? 1: 0); }
73  bool IsValid() const { return ((fStatus == 1) ? 1: 0); }
74  bool IsInvalid() const { return ((fStatus == -1) ? 1: 0); }
75  bool Match(const char *dir, const char *tag)
76  { return ((fTag == tag && fDir == dir) ? 1 : 0); }
77  bool MatchTag(const char *tag) { return ((fTag == tag) ? 1 : 0); }
78  void Park() { fStatus = 2; }
79  const char *PrgmSrv() const { return fPrgmSrv.c_str(); }
80  const char *Release() const { return fRelease.c_str(); }
81  void SetValid(kXR_int16 vers = -1);
82  kXR_int16 SrvProtVers() const { return fSrvProtVers; }
83  const char *Tag() const { return fTag.c_str(); }
84  int VersionCode() const { return fVersionCode; }
85  int VrsMajor() const { return fVrsMajor; }
86  int VrsMinor() const { return fVrsMinor; }
87  int VrsPatch() const { return fVrsPatch; }
88 
89  static int GetVersionCode(const char *release);
90  static int GetVersionCode(int maj, int min, int patch);
91  static int ParseReleaseString(const char *release, int &maj, int &min, int &patch);
92 };
93 
94 //
95 // Manage XrdROOT instances
96 
97 class XrdROOTMgr : public XrdProofdConfig {
98 
100  XrdSysLogger *fLogger; // Error logger
101  XrdOucString fLogDir; // Path to dir with validation logs
102 
103  std::list<XrdROOT *> fROOT; // ROOT versions; the first is the default
104 
105  int Validate(XrdROOT *r, XrdScheduler *sched);
106 
107  void RegisterDirectives();
108  int DoDirectiveRootSys(char *, XrdOucStream *, bool);
109 
110 public:
111  XrdROOTMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e);
112  virtual ~XrdROOTMgr() { }
113 
114  int Config(bool rcf = 0);
115  int DoDirective(XrdProofdDirective *d,
116  char *val, XrdOucStream *cfg, bool rcf);
117 
118  XrdROOT *DefaultVersion() const { return fROOT.front(); }
119  XrdOucString ExportVersions(XrdROOT *def);
120  XrdROOT *GetVersion(const char *tag);
121  void SetLogDir(const char *d);
122 };
123 
124 
125 #endif
XrdROOT(const char *dir, const char *tag, const char *bindir=0, const char *incdir=0, const char *libdir=0, const char *datadir=0)
Constructor: validates &#39;dir&#39;, gets the version and defines the tag.
Definition: XrdROOT.cxx:40
#define XrdSysLogger
Definition: XpdSysLogger.h:8
XrdOucString fRelease
Definition: XrdROOT.h:49
~XrdROOT()
Definition: XrdROOT.h:63
const double pi
XrdOucString fBinDir
Definition: XrdROOT.h:40
XrdROOT * DefaultVersion() const
Definition: XrdROOT.h:118
bool IsValid() const
Definition: XrdROOT.h:73
friend class XrdROOTMgr
Definition: XrdROOT.h:36
XrdOucString fGitCommit
Definition: XrdROOT.h:50
int fVersionCode
Definition: XrdROOT.h:51
const char * IncDir() const
Definition: XrdROOT.h:68
const char * LibDir() const
Definition: XrdROOT.h:69
virtual ~XrdROOTMgr()
Definition: XrdROOT.h:112
kXR_int16 SrvProtVers() const
Definition: XrdROOT.h:82
XrdOucString fDir
Definition: XrdROOT.h:39
static int GetVersionCode(const char *release)
Translate &#39;release&#39; into a version code integer following the rules in $ROOTSYS/include/RVersion.h.
Definition: XrdROOT.cxx:275
int fVrsMajor
Definition: XrdROOT.h:53
void SetValid(kXR_int16 vers=-1)
Set valid, save protocol and finalize the export string.
Definition: XrdROOT.cxx:149
bool IsInvalid() const
Definition: XrdROOT.h:74
int VrsPatch() const
Definition: XrdROOT.h:87
const char * DataDir() const
Definition: XrdROOT.h:67
XrdOucString fLogDir
Definition: XrdROOT.h:101
XrdOucString fExport
Definition: XrdROOT.h:45
XrdSysLogger * fLogger
Definition: XrdROOT.h:100
std::list< XrdROOT * > fROOT
Definition: XrdROOT.h:103
XrdOucString fTag
Definition: XrdROOT.h:44
const char * Release() const
Definition: XrdROOT.h:80
int VrsMajor() const
Definition: XrdROOT.h:85
XrdOucString fDataDir
Definition: XrdROOT.h:41
int fVrsMinor
Definition: XrdROOT.h:54
TRandom2 r(17)
#define XrdSysError
Definition: XpdSysError.h:8
int VrsMinor() const
Definition: XrdROOT.h:86
const char * Tag() const
Definition: XrdROOT.h:83
bool MatchTag(const char *tag)
Definition: XrdROOT.h:77
const char * GitCommit() const
Definition: XrdROOT.h:71
XrdOucString fLibDir
Definition: XrdROOT.h:43
int fStatus
Definition: XrdROOT.h:38
int ParseROOTVersionInfo()
Extract ROOT version information associated with &#39;dir&#39;.
Definition: XrdROOT.cxx:171
kXR_int16 fSrvProtVers
Definition: XrdROOT.h:47
void Park()
Definition: XrdROOT.h:78
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
XrdOucString fPrgmSrv
Definition: XrdROOT.h:46
const char * Export() const
Definition: XrdROOT.h:70
static int ParseReleaseString(const char *release, int &maj, int &min, int &patch)
Extract from &#39;release&#39; its major, minor and patch numerical components; &#39;release&#39; must be in the form...
Definition: XrdROOT.cxx:296
XrdProofdManager * fMgr
Definition: XrdROOT.h:99
int CheckDir(const char *dir)
Check if &#39;dir&#39; exists Return 0 on succes, -1 on failure.
Definition: XrdROOT.cxx:123
XrdOucString fIncDir
Definition: XrdROOT.h:42
bool IsParked() const
Definition: XrdROOT.h:72
const char * BinDir() const
Definition: XrdROOT.h:66
int fVrsPatch
Definition: XrdROOT.h:55
const char * Dir() const
Definition: XrdROOT.h:65
const char * PrgmSrv() const
Definition: XrdROOT.h:79
bool Match(const char *dir, const char *tag)
Definition: XrdROOT.h:75
int VersionCode() const
Definition: XrdROOT.h:84