Logo ROOT   6.08/07
Reference Guide
TPackMgr.h
Go to the documentation of this file.
1 // @(#)root/proof:$Id$
2 // Author: G. Ganis, Oct 2011
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_TPackMgr
13 #define ROOT_TPackMgr
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TPackMgr //
19 // //
20 // The PROOF manager interacts with the PROOF server coordinator to //
21 // create or destroy a PROOF session, attach to or detach from //
22 // existing one, and to monitor any client activity on the cluster. //
23 // At most one manager instance per server is allowed. //
24 // //
25 //////////////////////////////////////////////////////////////////////////
26 
27 #ifndef ROOT_TLockPath
28 #include "TLockPath.h"
29 #endif
30 #ifndef ROOT_TNamed
31 #include "TNamed.h"
32 #endif
33 #ifndef ROOT_TMD5
34 #include "TMD5.h"
35 #endif
36 #ifndef ROOT_TList
37 #include "TList.h"
38 #endif
39 #ifndef ROOT_TString
40 #include "TString.h"
41 #endif
42 
43 typedef void (*TPackMgrLog_t)(const char *);
44 
45 class TList;
46 class THashList;
47 class TPackMgr : public TNamed {
48 public:
50 
51 private:
53  TString fName; // Key identifying this package manager
54  TString fDir; // Directory with packages
55  TLockPath fLock; // Locker
56  TString fPfx; // Prefix for notifications, if any
57  TList *fEnabledPackages; // List of packages enabled
58 
59  static THashList *fgGlobalPackMgrList; // list of package managers for global packages
60 
61 private:
62  TPackMgr(const TPackMgr&); // Not implemented
63  TPackMgr& operator=(const TPackMgr&); // Not implemented
64 
65  void Log(const char *msg);
66 
67 public:
68  TPackMgr(const char *dir, const char *key = "L0");
69  virtual ~TPackMgr();
70 
71  const char *GetName() const { return fName.Data(); }
72  void SetName(const char *name) { fName = name; }
73  const char *GetTitle() const { return GetDir(); }
74 
75  TLockPath *GetLock() { return &fLock; }
76 
77  void SetLogger(TPackMgrLog_t logger) { fLogger = logger; }
78  void SetPrefix(const char *pfx) { fPfx = pfx; }
79 
80  Int_t Build(const char *pack, Int_t opt = TPackMgr::kCheckROOT);
81  Int_t Load(const char *pack, TList *optls = 0);
82  Int_t Load(const char *pack, const char *opts);
83  Int_t Unload(const char *pack);
84 
85  Bool_t Has(const char *pack);
86  Bool_t IsInDir(const char *path);
87  const char *GetDir() const { return fDir.Data(); }
88  Int_t GetPackDir(const char *pack, TString &pdir);
89  Int_t GetParPath(const char *pack, TString &path);
91  void GetEnabledPackages(TString &packlist);
92  Bool_t IsPackageEnabled(const char *pack) {
93  return (fEnabledPackages &&
94  fEnabledPackages->FindObject(pack) ? kTRUE : kFALSE); }
95 
96  void Show(const char *title = 0);
97  Int_t Clean(const char *pack);
98  Int_t Remove(const char *pack = 0, Bool_t dolock = kTRUE);
99  TList *GetList() const;
100 
101  void ShowEnabled(const char *title = 0);
102  TList* GetListOfEnabled() const;
103 
104  TMD5 *GetMD5(const char *pack);
105  TMD5 *ReadMD5(const char *pack);
106 
107  Int_t Install(const char *par, Bool_t rmold = kFALSE);
108  Int_t Unpack(const char *pack, TMD5 *sum = 0);
109 
110  // Static methods
111  static TPackMgr *GetPackMgr(const char *pack, TPackMgr *packmgr = nullptr);
112  static Int_t RegisterGlobalPath(const char *paths);
113  static Int_t FindParPath(TPackMgr *packmgr, const char *pack, TString &par);
114  static Bool_t IsEnabled(const char *pack, TPackMgr *packmgr = nullptr);
115 
116  ClassDef(TPackMgr,0) // Package manager interface
117 };
118 
119 #endif
static Int_t FindParPath(TPackMgr *packmgr, const char *pack, TString &par)
Get the full path to PAR, looking also in the global dirs.
Definition: TPackMgr.cxx:944
static THashList * fgGlobalPackMgrList
Definition: TPackMgr.h:59
double par[1]
Definition: unuranDistr.cxx:38
Bool_t IsPackageEnabled(const char *pack)
Definition: TPackMgr.h:92
TMD5 * ReadMD5(const char *pack)
Read MD5 checksum of the PAR file from the PROOF-INF/md5.txt file.
Definition: TPackMgr.cxx:722
The PROOF package manager contains tools to manage packages.
Definition: TPackMgr.h:47
static long int sum(long int i)
Definition: Factory.cxx:1786
void GetEnabledPackages(TString &packlist)
Method to get a semi-colon separated list with the names of the enabled packages. ...
Definition: TPackMgr.cxx:515
static Bool_t IsEnabled(const char *pack, TPackMgr *packmgr=nullptr)
Check if the package is enabled; priority is given to packmgr, if defined.
Definition: TPackMgr.cxx:971
TString fName
Definition: TPackMgr.h:53
virtual ~TPackMgr()
Destroy a TPackMgr instance.
Definition: TPackMgr.cxx:78
Int_t Unload(const char *pack)
Method to unload a package.
Definition: TPackMgr.cxx:425
Int_t GetParPath(const char *pack, TString &path)
Method to get the path of the PAR file for package 'pack'.
Definition: TPackMgr.cxx:535
static TPackMgr * GetPackMgr(const char *pack, TPackMgr *packmgr=nullptr)
Get the package manager having 'pack'; priority is given to packmgr, if defined.
Definition: TPackMgr.cxx:922
Basic string class.
Definition: TString.h:137
Int_t Clean(const char *pack)
Clean dir for package 'pack' Return -1 in case of error, 0 otherwise.
Definition: TPackMgr.cxx:590
Int_t GetPackDir(const char *pack, TString &pdir)
Method to get the path of the dir for package 'pack'.
Definition: TPackMgr.cxx:501
int Int_t
Definition: RtypesCore.h:41
Int_t Load(const char *pack, TList *optls=0)
Method to load a package taking an option list Return -1 on error, 0 otherwise.
Definition: TPackMgr.cxx:234
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
TList * fEnabledPackages
Definition: TPackMgr.h:57
TString fPfx
Definition: TPackMgr.h:56
TPackMgr(const TPackMgr &)
void Show(const char *title=0)
Show available packages.
Definition: TPackMgr.cxx:562
Int_t Unpack(const char *pack, TMD5 *sum=0)
Read MD5 checksum of the PAR file from the PROOF-INF/md5.txt file.
Definition: TPackMgr.cxx:737
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:497
Path locking class allowing shared and exclusive locks.
Definition: TLockPath.h:30
Int_t Install(const char *par, Bool_t rmold=kFALSE)
Install package from par (unpack the file in the directory); par can be an URL for remote retrieval...
Definition: TPackMgr.cxx:780
TList * GetListOfEnabled() const
Get list of enabled packages Returns a pointer to a TList object, transferring ownership to the calle...
Definition: TPackMgr.cxx:658
TString fDir
Definition: TPackMgr.h:54
#define ClassDef(name, id)
Definition: Rtypes.h:254
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:36
This code implements the MD5 message-digest algorithm.
Definition: TMD5.h:46
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
void SetName(const char *name)
Set the name of the TNamed.
Definition: TPackMgr.h:72
void ShowEnabled(const char *title=0)
Show enabled packages.
Definition: TPackMgr.cxx:676
TLockPath * GetLock()
Definition: TPackMgr.h:75
TLockPath fLock
Definition: TPackMgr.h:55
const char * GetTitle() const
Returns title of object.
Definition: TPackMgr.h:73
A doubly linked list.
Definition: TList.h:47
TList * GetList() const
Get list of available packages Returns a pointer to a TList object, transferring ownership to the cal...
Definition: TPackMgr.cxx:635
const char * GetDir() const
Definition: TPackMgr.h:87
Int_t Build(const char *pack, Int_t opt=TPackMgr::kCheckROOT)
Method to build a package.
Definition: TPackMgr.cxx:101
Bool_t IsInDir(const char *path)
Method to check if 'path' is in the managed directory Return kTRUE or kFALSE.
Definition: TPackMgr.cxx:492
void SetPrefix(const char *pfx)
Definition: TPackMgr.h:78
const char * GetName() const
Returns name of object.
Definition: TPackMgr.h:71
TPackMgr & operator=(const TPackMgr &)
TPackMgrLog_t fLogger
Definition: TPackMgr.h:52
static Int_t RegisterGlobalPath(const char *paths)
Parse one or more paths as possible sources of packages Returns number of paths added; or -1 in case ...
Definition: TPackMgr.cxx:882
void SetLogger(TPackMgrLog_t logger)
Definition: TPackMgr.h:77
Bool_t Has(const char *pack)
Method to check if this package manager has package 'pack'.
Definition: TPackMgr.cxx:472
ECheckVersionOpt
Definition: TPackMgr.h:49
typedef void((*Func_t)())
Int_t GetDownloadDir(TString &dldir)
Method to get the download dir; create if not existing Return -1 in case of error (not found; not cre...
Definition: TPackMgr.cxx:548
void Log(const char *msg)
Wrapper to notofuer / logger.
Definition: TPackMgr.cxx:87
Int_t Remove(const char *pack=0, Bool_t dolock=kTRUE)
Remove package 'pack' If 'pack' is null or empty all packages are cleared.
Definition: TPackMgr.cxx:607
TMD5 * GetMD5(const char *pack)
Get MD5 checksum of the PAR file corresponding to given package Returns a pointer to a TMD5 object...
Definition: TPackMgr.cxx:706
void(* TPackMgrLog_t)(const char *)
Definition: TPackMgr.h:43
const Bool_t kTRUE
Definition: Rtypes.h:91
char name[80]
Definition: TGX11.cxx:109
const char * Data() const
Definition: TString.h:349