KaliVeda
Toolkit for HIC analysis
KVBatchSystemManager.cpp
1 /*
2 $Id: KVBatchSystemManager.cpp,v 1.4 2007/11/20 16:45:22 franklan Exp $
3 $Revision: 1.4 $
4 $Date: 2007/11/20 16:45:22 $
5 */
6 
7 //Created by KVClassFactory on Mon May 7 17:29:05 2007
8 //Author: franklan
9 
10 #include "KVBatchSystemManager.h"
11 #include "KVString.h"
12 #include "TObjArray.h"
13 #include "TObjString.h"
14 #include "TEnv.h"
15 
16 using namespace std;
17 
19 
20 
21 
22 KVBatchSystemManager* gBatchSystemManager = 0;
23 
24 
27 
29 {
30  //Default constructor
31 
32  if (gBatchSystemManager) return;
33 
34  Init();
35  gBatchSystemManager = this;
36 }
37 
38 
39 
42 
44 {
45  //Destructor
46  gBatchSystemManager = 0;
47  gBatchSystem = 0;
48 }
49 
50 
51 
54 
55 void KVBatchSystemManager::Init()
56 {
57  //Set up list of available batch systems
58 
59  gBatchSystem = 0;
60 
61  KVString list = gEnv->GetValue("BatchSystem", "");
62 
63  fBatchSystems.Clear();
64 
65  unique_ptr<TObjArray> systems(list.Tokenize(" "));
66  TIter next(systems.get());
67  TObjString* batch_sys;
68  while ((batch_sys = (TObjString*)next())) {
69 
71  if(bs) fBatchSystems.Add(bs);
72  }
73 
74  //set default
75  fDefault = (KVBatchSystem*)fBatchSystems.FindObjectByName(gEnv->GetValue("Default.BatchSystem", ""));
76  // default not available - fall back to last batch system added
77  if(!fDefault)
78  fDefault = (KVBatchSystem*)fBatchSystems.Last();
79 }
80 
81 
82 
85 
87 {
88  //Get batch system by name
89  return (KVBatchSystem*)fBatchSystems.FindObjectByName(name);
90 }
91 
92 
93 
96 
98 {
99  //Get batch system by number in the list printed by Print()
100  return (KVBatchSystem*)fBatchSystems.At(index - 1);
101 }
102 
103 
104 
109 
111 {
112  //Print list of available batch systems
113  // Default is to show numbered list with title of each batch system
114  //if opt="all", print detailed information on each batch system
115  if (!strcmp(opt, "all")) {
116  for (int i = 1; i <= fBatchSystems.GetSize(); i++) {
117  fBatchSystems.At(i - 1)->Print("all");
118  }
119  }
120  else {
121  for (int i = 1; i <= fBatchSystems.GetSize(); i++) {
122  cout << "\t" << i << ". " << ((KVBatchSystem*)fBatchSystems.At(i - 1))->GetTitle() << endl;
123  }
124  }
125 }
126 
127 
int Int_t
char Char_t
const char Option_t
R__EXTERN TEnv * gEnv
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
char name[80]
Handles list of all available batch systems for processing non-interactive data analysis tasks.
virtual ~KVBatchSystemManager()
Destructor.
KVBatchSystemManager()
Default constructor.
void Print(Option_t *opt="") const
KVBatchSystem * GetBatchSystem(const Char_t *name)
Get batch system by name.
Base class for interface to a batch job management system.
Definition: KVBatchSystem.h:78
static KVBatchSystem * GetBatchSystem(const Char_t *plugin)
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
virtual const char * GetValue(const char *name, const char *dflt) const
const TString & GetString() const
const char * Data() const
TObjArray * Tokenize(const TString &delim) const
void Init()
ClassImp(TPyArg)