vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Scheduler.h
Go to the documentation of this file.
1 /***************************************************************************
2  Scheduler.h - description
3  -------------------
4  begin : February 2004
5  copyright : (C) 2004 by Jan Flasar
6  email : flasar@fi.muni.cz
7  ***************************************************************************/
8 
9 #ifndef SCHEDULER_H
10 #define SCHEDULER_H
11 
12 #include <vrecko/Export>
13 #include <vrecko/BaseClass.h>
14 #include <vrecko/vThread.h>
15 
16 #include <map>
17 #include <vector>
18 
19 
20 namespace vrecko {
21 
22 #define FRAME_FREQUENCY -1.0
23 
24 class World;
25 
27 class VRECKO_EXPORT Scheduler {
28  public:
29  Scheduler();
30  ~Scheduler();
31  Scheduler(Scheduler &s);
32 
33  void update(void);
34 
35  void start(void);
36  void stop(void);
37 
38 
53  void addEntity(BaseClass *ent, float frequency = FRAME_FREQUENCY);
54 
71  void addEntity(BaseClass *ent, const std::string &private_timer_name, float frequency = FRAME_FREQUENCY);
72 
74  void removeEntity(BaseClass *ent);
75 
77  bool isEntityPresent(BaseClass *ent);
78 
80  bool getState() {return state;}
81 
83  void resetObjectUpdatesCounter() { iObjectUpdatesCounter = 0; }
84 
86  int getObjectUpdatesCounter() { return iObjectUpdatesCounter; }
87 
88  protected:
89  typedef struct {
90  float frequency;
92  osg::Timer_t last_tick;
93  std::vector<BaseClass*> entity_vector;
94  } TimerStruct;
95  typedef std::map<float, TimerStruct > TimerMap;
97  typedef std::map<std::string, TimerStruct > PrivateTimerMap;
99  bool state;
100 
102 
103  struct classcomp {
104  bool operator() (const long int &lhs, const long int &rhs) const {return lhs > rhs;}
105  };
106 
110  std::multimap<long int, BaseClass*, classcomp> updateMMap;
111 
112 };
113 
114 }
115 
116 #endif
117