29 #include "TRestManager.h"
31 #include "TInterpreter.h"
32 #include "TRestTask.h"
38 TRestManager::TRestManager() { Initialize(); }
40 TRestManager::~TRestManager() {
42 if (fMetaObjects.size() > 1) {
43 for (
unsigned int i = fMetaObjects.size() - 1; i >= 1; i--) {
44 delete fMetaObjects[i];
53 SetSectionName(this->ClassName());
55 if (fMetaObjects.size() > 1) {
56 for (
unsigned int i = fMetaObjects.size() - 1; i >= 1; i--) {
57 delete fMetaObjects[i];
62 fMetaObjects.push_back(
this);
104 if (
Count(keydeclare,
"TRest") > 0) {
106 if (meta ==
nullptr)
return -1;
108 fMetaObjects.push_back(meta);
115 else if (keydeclare ==
"addTask") {
116 string active = GetParameter(
"value", e,
"");
117 if (active !=
"ON" && active !=
"On" && active !=
"on") {
118 RESTDebug <<
"Inactived task : \"" << ElementToString(e) <<
"\"" << RESTendl;
121 RESTDebug <<
"Loading Task...";
123 const char* type = e->Attribute(
"type");
124 const char* cmd = e->Attribute(
"command");
125 if (type ==
nullptr && cmd ==
nullptr) {
126 RESTWarning <<
"command or type should be given!" << RESTendl;
129 if (type !=
nullptr) {
130 RESTDebug <<
" \"" << type <<
"\" " << RESTendl;
131 if ((
string)type ==
"processEvents") {
132 auto pr = GetProcessRunner();
133 if (pr !=
nullptr) pr->RunProcess();
134 }
else if ((
string)type ==
"analysisPlot") {
135 auto ap = GetAnaPlot();
136 if (ap !=
nullptr) ap->PlotCombinedCanvas();
137 }
else if ((
string)type ==
"saveMetadata") {
138 auto ri = GetRunInfo();
140 ri->FormOutputFile();
145 if (tsk ==
nullptr) {
146 RESTWarning <<
"REST ERROR. Task : " << type <<
" not found!!" << RESTendl;
147 RESTWarning <<
"This task will be skipped." << RESTendl;
154 }
else if (cmd !=
nullptr) {
155 RESTDebug <<
" \"" << cmd <<
"\" " << RESTendl;
157 TRestTask* tsk = TRestTask::GetTaskFromCommand(cmd);
158 if (tsk ==
nullptr) {
159 RESTWarning <<
"REST ERROR. Command : " << cmd <<
" cannot be parsed!!" << RESTendl;
160 RESTWarning <<
"This task will be skipped." << RESTendl;
171 void TRestManager::InitFromTask(
string taskName, vector<string> arguments) {
173 if (tsk ==
nullptr) {
185 for (
unsigned int i = 0; i < fMetaObjects.size(); i++) {
186 if ((
string)fMetaObjects[i]->ClassName() == type) {
187 return fMetaObjects[i];
197 for (
unsigned int i = 0; i < fMetaObjects.size(); i++) {
198 if (fMetaObjects[i]->GetName() == name) {
199 return fMetaObjects[i];
Managing applications and executing tasks.
TRestMetadata * GetMetadataClass(std::string type)
Get the application metadata class, according to the type.
void Initialize() override
Set the class name as section name during initialization.
int LoadSectionMetadata() override
This method does some preparation of xml section.
Int_t ReadConfig(std::string keydeclare, TiXmlElement *e)
Respond to the input xml element.
void PrintMetadata() override
PrintMetadata of this class.
TRestMetadata * GetMetadata(std::string name)
Get the application metadata class, according to the name.
Wrapping REST macros into tasks.
void SetArgumentValue(std::vector< std::string > arg)
Set argument directly with a list of string.
virtual void RunTask(TRestManager *)
Run the task with command line.
static TRestTask * GetTaskFromMacro(TString Name)
Static method to instantiate a TRestTask object with "MacroName".
TRestReflector Assembly(const std::string &typeName)
Assembly an object of type: typeName, returning the allocated memory address and size.
Int_t Count(std::string s, std::string sbstring)
Counts the number of occurences of substring inside the input string in.