Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JetScapeTask.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file JetScapeTask.h
1 /*******************************************************************************
2  * Copyright (c) The JETSCAPE Collaboration, 2018
3  *
4  * Modular, task-based framework for simulating all aspects of heavy-ion collisions
5  *
6  * For the list of contributors see AUTHORS.
7  *
8  * Report issues at https://github.com/JETSCAPE/JETSCAPE/issues
9  *
10  * or via email to bugs.jetscape@gmail.com
11  *
12  * Distributed under the GNU General Public License 3.0 (GPLv3 or later).
13  * See COPYING for details.
14  ******************************************************************************/
15 
16 // JetScapeTask class
17 // \TODO: Implement truly recursively (not yet done)
18 // (see https://root.cern.ch/doc/v608/TTask_8cxx_source.html l248)
19 // (not really though ...)
20 
21 #ifndef JETSCAPETASK_H
22 #define JETSCAPETASK_H
23 
24 #include <list>
25 #include <vector>
26 #include <string>
27 #include <memory>
28 
29 using std::vector;
30 using std::string;
31 using std::weak_ptr;
32 using std::shared_ptr;
33 
34 namespace Jetscape {
35 
36 // need forward declaration
37 class JetScapeWriter;
38 class JetScapeModuleMutex;
39 class Parton;
40 
41 class JetScapeTask {
42 
43 public:
46  JetScapeTask();
47 
50  virtual ~JetScapeTask();
51 
54  virtual void Init();
55 
58  virtual void Exec();
59 
62  virtual void Finish(){};
63 
66  virtual void Clear(){};
67 
68  // Extensions for "recursive" handling ...
71  virtual void ExecuteTasks();
72 
75  virtual void ExecuteTask(){};
76 
79  virtual void InitTask(){};
80 
83  virtual void InitTasks();
84 
85  // really decide and think what is the best way (workflow ...)
88  virtual void ClearTasks();
89 
92  virtual void ClearTask(){};
93 
96  virtual void FinishTask(){};
97 
100  virtual void FinishTasks(){};
101 
105  virtual void WriteTasks(weak_ptr<JetScapeWriter> w);
106 
107  //add here a write task (depending on if JetScapeWriter is initiallized and active) ...
108  // Think about workflow ...
123  virtual void WriteTask(weak_ptr<JetScapeWriter> w){};
124 
128  virtual void CollectHeader(weak_ptr<JetScapeWriter> w){};
129 
133  virtual void CollectHeaders(weak_ptr<JetScapeWriter> w);
134 
137  virtual void Add(shared_ptr<JetScapeTask> m_tasks);
138 
141  virtual const inline int GetMyTaskNumber() const { return my_task_number_; };
142 
145  const vector<shared_ptr<JetScapeTask>> GetTaskList() const { return tasks; }
146 
148  shared_ptr<JetScapeTask> GetTaskAt(int i) { return tasks.at(i); }
149 
151  void EraseTaskLast() { tasks.erase(tasks.begin() + (tasks.size() - 1)); }
152  //funny syntax (why last() not working here!?)
153 
156  void EraseTaskAt(int i) { tasks.erase((tasks.begin() + i)); }
157 
160  void ResizeTaskList(int i) { tasks.resize(i); }
161 
164  void ClearTaskList() { tasks.clear(); }
165 
168  int GetNumberOfTasks() { return (int)tasks.size(); }
169 
172  const bool GetActive() const { return active_exec; }
173 
176  void SetActive(bool m_active_exec) { active_exec = m_active_exec; }
177  // needed to access tasks not recursively by default but individually ...
178  // also usefull to prevent hydro if multiple read ins of the same event ...
179 
182  void SetId(string m_id) { id = m_id; }
183 
186  const string GetId() const { return id; }
187 
191 
194  void SetMutex(shared_ptr<JetScapeModuleMutex> m_mutex) { mutex = m_mutex; }
195 
196 private:
197  // can be made sortabele to put in correct oder or via xml file ...
198  vector<shared_ptr<JetScapeTask>> tasks;
199  //list<shared_ptr<JetScapeTask>> tasks; // list vs vector any advantage of list?
200 
202  string id;
203  // if for example a search rather position ... (or always sort with predefined order!?)
204 
207 };
208 
209 } // end namespace Jetscape
210 
211 #endif