LRT14  1.0
 All Classes Namespaces Functions Variables Enumerations Enumerator
Automation.h
1 #ifndef AUTOMATION_H_
2 #define AUTOMATION_H_
3 
4 #include <vector>
5 #include <set>
6 #include <map>
7 #include "../ControlResource.h"
8 
9 class Event;
10 
15 {
16 public:
24  Automation(const char* name, bool requiresAbortCycles = false, bool queueIfBlocked = false, bool restartable = false);
25  virtual ~Automation();
26 
31  bool Update();
32 
38  bool StartAutomation(Event* trigger = NULL);
39 
45  bool AbortAutomation(Event* trigger = NULL);
46 
51  void ContinueAutomation(Event* trigger);
52 
57  bool CheckResources();
58 
62  virtual void AllocateResources() = 0;
63 
67  void DeallocateResources();
68 
74  static bool GetAllocation(ControlResource::Enum resource);
75 
80  bool IsRestartable();
81 
86  bool QueueIfBlocked();
87 
92  bool RequiresAbortCycles();
93 
98  const char* GetName();
99 
100  static std::vector<Automation*> automation_vector;
101 
102 protected:
107  virtual bool Start() = 0;
108 
113  virtual bool Abort() = 0;
114 
119  virtual bool Run() = 0;
120 
126  bool AllocateResource(ControlResource::Enum resource);
127 
132  bool Aborting();
133 
138  bool Continued();
139 
144  Event* GetStartEvent();
145 
150  Event* GetAbortEvent();
151 
157 
158 private:
159  static std::map<ControlResource::Enum, int> allocated;
160  std::vector<ControlResource::Enum> resources;
161  Event* m_startEvent;
162  Event* m_abortEvent;
163  Event* m_continueEvent;
164  bool m_aborting;
165  bool m_restartable;
166  bool m_queueIfBlocked;
167  bool m_requiresAbortCycles;
168  const char* m_name;
169 };
170 
171 #endif