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 
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  fBatchSystems.Add(bs);
72  }
73 
74  //set default
75  fDefault = (KVBatchSystem*)fBatchSystems.FindObjectByName(gEnv->GetValue("Default.BatchSystem", ""));
76 }
77 
78 
79 
82 
84 {
85  //Get batch system by name
86  return (KVBatchSystem*)fBatchSystems.FindObjectByName(name);
87 }
88 
89 
90 
93 
95 {
96  //Get batch system by number in the list printed by Print()
97  return (KVBatchSystem*)fBatchSystems.At(index - 1);
98 }
99 
100 
101 
106 
108 {
109  //Print list of available batch systems
110  // Default is to show numbered list with title of each batch system
111  //if opt="all", print detailed information on each batch system
112  if (!strcmp(opt, "all")) {
113  for (int i = 1; i <= fBatchSystems.GetSize(); i++) {
114  fBatchSystems.At(i - 1)->Print("all");
115  }
116  }
117  else {
118  for (int i = 1; i <= fBatchSystems.GetSize(); i++) {
119  cout << "\t" << i << ". " << ((KVBatchSystem*)fBatchSystems.At(i - 1))->GetTitle() << endl;
120  }
121  }
122 }
123 
124 
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.
void Init()
Set up list of available batch systems.
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)