Logo ROOT   6.16/01
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
33typedef void (*TPackMgrLog_t)(const char *);
34
35class TList;
36class THashList;
37class TPackMgr : public TNamed {
38public:
40
41private:
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
51private:
52 TPackMgr(const TPackMgr&); // Not implemented
53 TPackMgr& operator=(const TPackMgr&); // Not implemented
54
55 void Log(const char *msg);
56
57public:
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 &&
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
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:324
void(* TPackMgrLog_t)(const char *)
Definition: TPackMgr.h:33
typedef void((*Func_t)())
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
A doubly linked list.
Definition: TList.h:44
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
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
The PROOF package manager contains tools to manage packages.
Definition: TPackMgr.h:37
void SetLogger(TPackMgrLog_t logger)
Definition: TPackMgr.h:67
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 SetName(const char *name)
Set the name of the TNamed.
Definition: TPackMgr.h:62
ECheckVersionOpt
Definition: TPackMgr.h:39
@ kDontCheck
Definition: TPackMgr.h:39
@ kCheckGIT
Definition: TPackMgr.h:39
@ kCheckROOT
Definition: TPackMgr.h:39
TString fDir
Definition: TPackMgr.h:44
void Show(const char *title=0)
Show available packages.
Definition: TPackMgr.cxx:548
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
Int_t GetPackDir(const char *pack, TString &pdir)
Method to get the path of the dir for package 'pack'.
Definition: TPackMgr.cxx:487
const char * GetName() const
Returns name of object.
Definition: TPackMgr.h:61
static THashList * fgGlobalPackMgrList
Definition: TPackMgr.h:49
Int_t Build(const char *pack, Int_t opt=TPackMgr::kCheckROOT)
Method to build a package.
Definition: TPackMgr.cxx:87
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
Int_t GetParPath(const char *pack, TString &path)
Method to get the path of the PAR file for package 'pack'.
Definition: TPackMgr.cxx:521
TString fName
Definition: TPackMgr.h:43
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
Bool_t Has(const char *pack)
Method to check if this package manager has package 'pack'.
Definition: TPackMgr.cxx:458
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
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 ShowEnabled(const char *title=0)
Show enabled packages.
Definition: TPackMgr.cxx:662
void Log(const char *msg)
Wrapper to notofuer / logger.
Definition: TPackMgr.cxx:73
TLockPath fLock
Definition: TPackMgr.h:45
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
TList * GetList() const
Get list of available packages Returns a pointer to a TList object, transferring ownership to the cal...
Definition: TPackMgr.cxx:621
TPackMgr(const TPackMgr &)
Int_t Clean(const char *pack)
Clean dir for package 'pack' Return -1 in case of error, 0 otherwise.
Definition: TPackMgr.cxx:576
TPackMgr & operator=(const TPackMgr &)
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
Bool_t IsPackageEnabled(const char *pack)
Definition: TPackMgr.h:82
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
Int_t Unload(const char *pack)
Method to unload a package.
Definition: TPackMgr.cxx:411
TLockPath * GetLock()
Definition: TPackMgr.h:65
TPackMgrLog_t fLogger
Definition: TPackMgr.h:42
TList * fEnabledPackages
Definition: TPackMgr.h:47
TList * GetListOfEnabled() const
Get list of enabled packages Returns a pointer to a TList object, transferring ownership to the calle...
Definition: TPackMgr.cxx:644
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
void SetPrefix(const char *pfx)
Definition: TPackMgr.h:68
const char * GetDir() const
Definition: TPackMgr.h:77
TString fPfx
Definition: TPackMgr.h:46
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
virtual ~TPackMgr()
Destroy a TPackMgr instance.
Definition: TPackMgr.cxx:64
TMD5 * ReadMD5(const char *pack)
Read MD5 checksum of the PAR file from the PROOF-INF/md5.txt file.
Definition: TPackMgr.cxx:708
const char * GetTitle() const
Returns title of object.
Definition: TPackMgr.h:63
Basic string class.
Definition: TString.h:131
const char * Data() const
Definition: TString.h:364
static long int sum(long int i)
Definition: Factory.cxx:2258