29#include "TRestManager.h"
31#include "TInterpreter.h"
40TRestManager::~TRestManager() {
43 for (
unsigned int i =
fMetaObjects.size() - 1; i >= 1; i--) {
56 for (
unsigned int i =
fMetaObjects.size() - 1; i >= 1; i--) {
104 if (
Count(keydeclare,
"TRest") > 0) {
106 if (meta ==
nullptr)
return -1;
115 else if (keydeclare ==
"addTask") {
117 if (active !=
"ON" && active !=
"On" && active !=
"on") {
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;
171void TRestManager::InitFromTask(
string taskName, vector<string> arguments) {
173 if (tsk ==
nullptr) {
185 for (
unsigned int i = 0; i <
fMetaObjects.size(); i++) {
197 for (
unsigned int i = 0; i <
fMetaObjects.size(); 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.
std::vector< TRestMetadata * > fMetaObjects
app-like metadata objects
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.