O P A R - Open Architecture Particle in Cell Simulation - Version 3.0
Plasma simulations with dust particles
 All Classes Files Functions Variables Friends Macros Groups Pages
task.h
Go to the documentation of this file.
1 
5 #ifndef TASK_H
6 #define TASK_H
7 #include "stlpwrapper.h"
8 #include <list>
9 #include <vector>
10 #include <map>
11 #include <string>
12 #include <iostream>
13 //---------------------------------------------------------------------------------------------------------------------
14 class Task;
15 typedef std::list<PtrWrapper<Task> > TASKLIST;
16 
17 class Parameter;
19 typedef std::map<std::string,WParameter> PARAMETERMAP;
20 
21 class Process;
22 
23 class Normalization;
24 
35 class Task {
36  private:
38  static int nTaskCount;
40  std::vector<std::string> vecPredecessors;
42  int nLastCycle, nLastExecute;
43  protected:
44 
49 
50  int nStart, nEnd, nStep;
52 
53  int nNr;
55  std::string strName;
61  std::string strNorm;
65  TASKLIST plTasks;
66  public:
67  Task ();
68  virtual ~Task (); // remove from parents task list
70  int GetStep () const {return nStep;}
72  int GetEnd () const {return nEnd;}
74  bool DoNow ();
76  std::string GetName () const {return strName;}
78  virtual std::string GetClassName () const {return "Task";}
80  virtual bool IsInteractive () const {return false;}
82  void AttachTask (Task* pTask);
84  void DetachTask (Task* pTask);
85  protected:
87  void AddPredecessor (const std::string& strPred);
88  public:
89 
93  friend bool operator< (const Task& left, const Task& right) {
94  for (std::vector<std::string>::const_iterator iter = right.vecPredecessors.begin();
95  iter != right.vecPredecessors.end(); iter++) {
96  if (*iter == "*") return true;
97  if (*iter == left.strName) return true;
98  };
99  return false;
100  };
101  virtual void Init ();
102  virtual bool Execute ();
103  protected:
104  virtual PARAMETERMAP* MakeParamMap (PARAMETERMAP* pm = NULL);
105  public:
106 
111  virtual std::string Rebuild (std::istream& in);
112  public:
114  virtual void DumpTaskList (std::ostream& o, int nDepth = 0);
115 };
116 
117 typedef PtrWrapper<Task> TASK;
118 typedef std::vector<TASK> TASKVECTOR ;
119 
125 class Process : public Task {
126  protected:
128  int nCycle;
129  public:
131  TASKVECTOR vecTasks;
132  public:
134  Process ();
136  virtual ~Process ();
138  virtual std::string GetClassName () const { return "Process"; };
139  Task* GetTask (std::string strName, std::string strClass) const;
141  int GetCycle () const { return nCycle; };
143  virtual std::string Rebuild (std::istream& in);
145  virtual bool Run ();
146 };
147 #endif