Emergency 20 Dokumentation  4.2.0
Cleanup.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/Export.h"
14 
16 #include <qsf/job/JobProxy.h>
17 
18 
19 //[-------------------------------------------------------]
20 //[ Namespace ]
21 //[-------------------------------------------------------]
22 namespace em5
23 {
24 
25 
26  //[-------------------------------------------------------]
27  //[ Classes ]
28  //[-------------------------------------------------------]
38  {
39 
40 
41  //[-------------------------------------------------------]
42  //[ Public definitions ]
43  //[-------------------------------------------------------]
44  public:
46  {
47  RESULT_OK, // Cleanup is allowed
48  RESULT_FAILED, // CleanUp is not allowed
49  RESULT_RESETTIMER // CleanUp is not allowed and the timer is reset
50  };
51 
53  {
55  EXECUTE_DELETEOWNER
56  };
57 
58 
59  //[-------------------------------------------------------]
60  //[ Public methods ]
61  //[-------------------------------------------------------]
62  public:
67  void executeCleanup();
68 
69 
70  //[-------------------------------------------------------]
71  //[ Public virtual qsf::GameLogic methods ]
72  //[-------------------------------------------------------]
73  public:
74  virtual bool onStartup() override;
75  virtual void onShutdown() override;
76  virtual void serialize(qsf::BinarySerializer& serializer) override;
77 
78 
79  //[-------------------------------------------------------]
80  //[ Protected methods ]
81  //[-------------------------------------------------------]
82  protected:
87  explicit Cleanup(uint32 typeId, const qsf::Time& startWaitTime = qsf::Time::fromSeconds(300.0f), const qsf::Time& resetWaitTime = qsf::Time::fromSeconds(20.0f));
88 
93  virtual CleanupResult readyForCleanupCheap() const;
94 
99  virtual CleanupResult onReadyForCleanupCheap() const;
100 
105  virtual CleanupResult readyForCleanupExpensive() const;
106 
111  virtual CleanupResult onReadyForCleanupExpensive() const;
112 
117  virtual ExecuteResult onExecuteCleanup();
118 
119 
120  //[-------------------------------------------------------]
121  //[ Private methods ]
122  //[-------------------------------------------------------]
123  private:
124  void updateCleanup(const qsf::JobArguments& jobArguments);
125 
126 
127  //[-------------------------------------------------------]
128  //[ Private methods ]
129  //[-------------------------------------------------------]
130  private:
131  qsf::Time mWaitTimeLeft;
132  qsf::Time mResetWaitTime;
133  qsf::JobProxy mCleanupProxy;
134 
135 
136  //[-------------------------------------------------------]
137  //[ CAMP reflection system ]
138  //[-------------------------------------------------------]
139  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
140 
141 
142  };
143 
144 
145 //[-------------------------------------------------------]
146 //[ Namespace ]
147 //[-------------------------------------------------------]
148 } // em5
149 
150 
151 //[-------------------------------------------------------]
152 //[ CAMP reflection system ]
153 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
Definition: Cleanup.h:48
unsigned int uint32
Definition: PlatformTypes.h:181
CleanupResult
Definition: Cleanup.h:45
ExecuteResult
Definition: Cleanup.h:52
#define EM5_API_EXPORT
Definition: Export.h:28
Definition: Cleanup.h:47
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
Cleanup base class.
Definition: Cleanup.h:37
Game logic base class.
Definition: GameLogic.h:44
static Time fromSeconds(float seconds)
Definition: Time-inl.h:74
Binary serializer class.
Definition: BinarySerializer.h:35
Definition: Cleanup.h:54
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32