Logo ROOT   6.14/05
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 #include "TLockPath.h"
28 #include "TNamed.h"
29 #include "TMD5.h"
30 #include "TList.h"
31 #include "TString.h"
32 
33 typedef void (*TPackMgrLog_t)(const char *);
34 
35 class TList;
36 class THashList;
37 class TPackMgr : public TNamed {
38 public:
40 
41 private:
43  TString fName; // Key identifying this package manager
44  TString fDir; // Directory with packages
45  TLockPath fLock; // Locker
46  TString fPfx; // Prefix for notifications, if any
47  TList *fEnabledPackages; // List of packages enabled
48 
49  static THashList *fgGlobalPackMgrList; // list of package managers for global packages
50 
51 private:
52  TPackMgr(const TPackMgr&); // Not implemented
53  TPackMgr& operator=(const TPackMgr&); // Not implemented
54 
55  void Log(const char *msg);
56 
57 public:
58  TPackMgr(const char *dir, const char *key = "L0");
59  virtual ~TPackMgr();
60 
61  const char *GetName() const { return fName.Data(); }
62  void SetName(const char *name) { fName = name; }
63  const char *GetTitle() const { return GetDir(); }
64 
65  TLockPath *GetLock() { return &fLock; }
66 
67  void SetLogger(TPackMgrLog_t logger) { fLogger = logger; }
68  void SetPrefix(const char *pfx) { fPfx = pfx; }
69 
70  Int_t Build(const char *pack, Int_t opt = TPackMgr::kCheckROOT);
71  Int_t Load(const char *pack, TList *optls = 0);
72  Int_t Load(const char *pack, const char *opts);
73  Int_t Unload(const char *pack);
74 
75  Bool_t Has(const char *pack);
76  Bool_t IsInDir(const char *path);
77  const char *GetDir() const { return fDir.Data(); }
78  Int_t GetPackDir(const char *pack, TString &pdir);
79  Int_t GetParPath(const char *pack, TString &path);
81  void GetEnabledPackages(TString &packlist);
82  Bool_t IsPackageEnabled(const char *pack) {
83  return (fEnabledPackages &&
84  fEnabledPackages->FindObject(pack) ? kTRUE : kFALSE); }
85 
86  void Show(const char *title = 0);
87  Int_t Clean(const char *pack);
88  Int_t Remove(const char *pack = 0, Bool_t dolock = kTRUE);
89  TList *GetList() const;
90 
91  void ShowEnabled(const char *title = 0);
92  TList* GetListOfEnabled() const;
93 
94  TMD5 *GetMD5(const char *pack);
95  TMD5 *ReadMD5(const char *pack);
96 
97  Int_t Install(const char *par, Bool_t rmold = kFALSE);
98  Int_t Unpack(const char *pack, TMD5 *sum = 0);
99 
100  // Static methods
101  static TPackMgr *GetPackMgr(const char *pack, TPackMgr *packmgr = nullptr);
102  static Int_t RegisterGlobalPath(const char *paths);
103  static Int_t FindParPath(TPackMgr *packmgr, const char *pack, TString &par);
104  static Bool_t IsEnabled(const char *pack, TPackMgr *packmgr = nullptr);
105 
106  ClassDef(TPackMgr,0) // Package manager interface
107 };
108 
109 #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:933
static THashList * fgGlobalPackMgrList
Definition: TPackMgr.h:49
Bool_t IsPackageEnabled(const char *pack)
Definition: TPackMgr.h:82
TMD5 * ReadMD5(const char *pack)
Read MD5 checksum of the PAR file from the PROOF-INF/md5.txt file.
Definition: TPackMgr.cxx:708
The PROOF package manager contains tools to manage packages.
Definition: TPackMgr.h:37
static long int sum(long int i)
Definition: Factory.cxx:2258
void GetEnabledPackages(TString &packlist)
Method to get a semi-colon separated list with the names of the enabled packages. ...
Definition: TPackMgr.cxx:501
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:960
TString fName
Definition: TPackMgr.h:43
virtual ~TPackMgr()
Destroy a TPackMgr instance.
Definition: TPackMgr.cxx:64
Int_t Unload(const char *pack)
Method to unload a package.
Definition: TPackMgr.cxx:411
Int_t GetParPath(const char *pack, TString &path)
Method to get the path of the PAR file for package 'pack'.
Definition: TPackMgr.cxx:521
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:911
Basic string class.
Definition: TString.h:131
Int_t Clean(const char *pack)
Clean dir for package 'pack' Return -1 in case of error, 0 otherwise.
Definition: TPackMgr.cxx:576
Int_t GetPackDir(const char *pack, TString &pdir)
Method to get the path of the dir for package 'pack'.
Definition: TPackMgr.cxx:487
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:220
bool Bool_t
Definition: RtypesCore.h:59
TList * fEnabledPackages
Definition: TPackMgr.h:47
TString fPfx
Definition: TPackMgr.h:46
TPackMgr(const TPackMgr &)
void Show(const char *title=0)
Show available packages.
Definition: TPackMgr.cxx:548
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:723
virtual TObject * FindObject(const char *name) const
Delete a TObjLink object.
Definition: TList.cxx:574
Path locking class allowing shared and exclusive locks.
Definition: TLockPath.h:26
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:766
TList * GetListOfEnabled() const
Get list of enabled packages Returns a pointer to a TList object, transferring ownership to the calle...
Definition: TPackMgr.cxx:644
TString fDir
Definition: TPackMgr.h:44
#define ClassDef(name, id)
Definition: Rtypes.h:320
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
This code implements the MD5 message-digest algorithm.
Definition: TMD5.h:44
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
void SetName(const char *name)
Set the name of the TNamed.
Definition: TPackMgr.h:62
void ShowEnabled(const char *title=0)
Show enabled packages.
Definition: TPackMgr.cxx:662
TLockPath * GetLock()
Definition: TPackMgr.h:65
TLockPath fLock
Definition: TPackMgr.h:45
const char * GetTitle() const
Returns title of object.
Definition: TPackMgr.h:63
A doubly linked list.
Definition: TList.h:44
TList * GetList() const
Get list of available packages Returns a pointer to a TList object, transferring ownership to the cal...
Definition: TPackMgr.cxx:621
const char * GetDir() const
Definition: TPackMgr.h:77
Int_t Build(const char *pack, Int_t opt=TPackMgr::kCheckROOT)
Method to build a package.
Definition: TPackMgr.cxx:87
Bool_t IsInDir(const char *path)
Method to check if 'path' is in the managed directory Return kTRUE or kFALSE.
Definition: TPackMgr.cxx:478
void SetPrefix(const char *pfx)
Definition: TPackMgr.h:68
const char * GetName() const
Returns name of object.
Definition: TPackMgr.h:61
const Bool_t kFALSE
Definition: RtypesCore.h:88
TPackMgr & operator=(const TPackMgr &)
TPackMgrLog_t fLogger
Definition: TPackMgr.h:42
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:871
void SetLogger(TPackMgrLog_t logger)
Definition: TPackMgr.h:67
Bool_t Has(const char *pack)
Method to check if this package manager has package 'pack'.
Definition: TPackMgr.cxx:458
ECheckVersionOpt
Definition: TPackMgr.h:39
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:534
void Log(const char *msg)
Wrapper to notofuer / logger.
Definition: TPackMgr.cxx:73
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:593
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:692
void(* TPackMgrLog_t)(const char *)
Definition: TPackMgr.h:33
const Bool_t kTRUE
Definition: RtypesCore.h:87
char name[80]
Definition: TGX11.cxx:109
const char * Data() const
Definition: TString.h:364