| 1 |
#ifndef _CSEQUENCEDEVENT_ |
| 2 |
#define _CSEQUENCEDEVENT_ |
| 3 |
|
| 4 |
#include "CSurface.h" |
| 5 |
#include "CEventData.h" |
| 6 |
#include <deque> |
| 7 |
#include <list> |
| 8 |
|
| 9 |
using namespace std; |
| 10 |
|
| 11 |
class CSequencedEvent |
| 12 |
{ |
| 13 |
public: |
| 14 |
CSequencedEvent(bool c); |
| 15 |
CSequencedEvent(const CSequencedEvent &e); |
| 16 |
const CSequencedEvent& operator=(const CSequencedEvent &s); |
| 17 |
|
| 18 |
virtual ~CSequencedEvent(); |
| 19 |
|
| 20 |
virtual CSequencedEvent* getCopy() = 0; |
| 21 |
|
| 22 |
virtual void start() { running = true; } //! Start the event |
| 23 |
virtual void stop() { running = false; } //! Stop the event |
| 24 |
virtual void doUpdate() = 0; |
| 25 |
virtual void initialize() { }; |
| 26 |
void update(); //! Call this every frame |
| 27 |
|
| 28 |
virtual bool hasImage() { return false; } |
| 29 |
virtual CSurface* getImage() { return NULL; } |
| 30 |
virtual bool hasDraw() { return false; } |
| 31 |
virtual void draw(CSurface &s, int x, int y) { } |
| 32 |
|
| 33 |
virtual CEventData* getEventData() { return NULL; } |
| 34 |
void passEventData(CEventData* d); |
| 35 |
|
| 36 |
bool isDone() { return done; } |
| 37 |
bool isConcurrent() { return concurrent; } //! Allow other sequenced events to execute while this one is executing? (the value of this may change i.e. concurrent events may be allowed after 1 second, 50 frames, etc) |
| 38 |
bool isRunning() { return running; } |
| 39 |
int minusRef() { return --refCount; } |
| 40 |
int plusRef() { return ++refCount; } |
| 41 |
int getRef() { return refCount; } |
| 42 |
|
| 43 |
typedef list<CSequencedEvent*> Container; |
| 44 |
typedef Container::iterator Iter; |
| 45 |
typedef Container::const_iterator ConstIter; |
| 46 |
|
| 47 |
protected: |
| 48 |
void setDone(bool d = true) { done = d; if (done) stop(); } |
| 49 |
void setConcurrent(bool c = true) { concurrent = c; } |
| 50 |
virtual void gotEventData() { } |
| 51 |
CEventData* d; |
| 52 |
|
| 53 |
private: |
| 54 |
bool running; |
| 55 |
bool done; |
| 56 |
bool concurrent; |
| 57 |
bool init; |
| 58 |
int refCount; |
| 59 |
}; |
| 60 |
|
| 61 |
#endif |