-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResourceManager.h
113 lines (76 loc) · 2.95 KB
/
ResourceManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef RESOURCE_MANAGER_H
#define RESOURCE_MANAGER_H
#include "BaseObject.h"
#include "BaseSystem.h"
#include "BaseSimulator.h"
#include <shared/defs.h>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <iostream>
typedef std::vector< BaseObject* > ListOfObjects;
typedef std::vector< BaseSystem* > ListOfSystems;
typedef std::vector< BaseSimulator* > ListOfSimulators;
typedef std::set< BaseObject* > DisplayList;
typedef std::map< std::string, BaseObject* > DatabaseOfObjects;
const double SIMULATION_TIME_STEP = 0.01 ;
class ResourceManager
{
public:
ResourceManager(void);
~ResourceManager(void);
// use this methods to register new objects with the resource manager
bool addObject( BaseObject* newObject, bool visible = true );
bool addSystem( BaseSystem* newSystem, bool visible = false );
bool addSimulator( BaseSimulator* newSimulator, bool visible = false );
// this method simply calls the reset method for all the objects that were
// registered. You must implement the reset method for your object for this
// to have any effect
void resetAll();
// accessors
unsigned int getNumberOfSimulators() const;
unsigned int getNumberOfSystems() const;
BaseObject* getObject( const std::string& name ) const;
BaseSystem* getSystem( const std::string& name ) const;
BaseSimulator* getSimulator( const std::string& name ) const;
BaseObject* getObjectFromIndex( unsigned int index ) const;
BaseSystem* getSystemFromIndex( unsigned int index ) const;
BaseSimulator* getSimulatorFromIndex( unsigned int index ) const;
GLMouseButtonInfo getMouseButtonInfo() const;
void setMouseButtonInfo( int button, int state );
// mutators
void setSimulationTime( double time );
double getSimulationTime() const;
void setActualTime( double time );
double getActualTime() const;
// core methods
void advanceSimulationTime( double timeStep = SIMULATION_TIME_STEP );
void advanceActualTime( double timeStep = SIMULATION_TIME_STEP );
void initializeAllSimulators();
void stepAllSimulators();
void display( GLenum mode = GL_RENDER );
// remove all registered systems from the resource manager. All objects are
// also deallocated from memory, so after you call this function all the
// pointers to your objects become invalid.
void clearAll();
private:
ListOfObjects m_objectList;
ListOfSystems m_systemList;
ListOfSimulators m_simulatorList;
double m_simulationTime;
double m_actualTime;
DisplayList m_displaylist;
DatabaseOfObjects m_objectDatabase;
// graphics window params
unsigned int m_windowWidth;
unsigned int m_windowHeight;
unsigned int m_windowButton;
// the state of the resource manager
GlobalStates m_state;
GLMouseButtonInfo m_mouseButtonInfo;
bool _checkDuplicateName( const std::string& name ) const;
BaseObject* _getObjectFromDatabase( const std::string& name ) const;
void _cleanUp();
};
#endif