Debian Codegraph @

src/simulator/mainsim.h

raw symbols SCIP
1 /***************************************************************************
2 mainsim.h - description
3 -------------------
4 begin : february 21th, 2006
5 copyright : (C) 2006-2007 by Duong Khang NGUYEN
6 email : neoneurone @ gmail com
7
8 $Id: mainsim.h 450 2010-11-21 19:11:43Z neoneurone $
9 ***************************************************************************/
10
11 /***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * any later version. *
17 * *
18 ***************************************************************************/
19
20 #ifndef _OPENCITY_MAINSIM_H_
21 #define _OPENCITY_MAINSIM_H_ 1
22
23 #include "main.h"
24 #include "simulator.h"
25
26
27 //========================================================================
28 /** Handles the simulation of the commercial sub-system.
29 */
30 class MainSim : public Simulator
31 {
32
33 public:
34
35
36 //========================================================================
37 /** Constructs a new MainSim object.
38 \param mutex A pointer to a SDL_mutex which should be used to prevent
39 that the gobal simulator's data is overwritten by multiple micro simulators
40 \param pblayer A pointer to the BuildingLayer
41 \param pmap A pointer to the gobal Map object
42 \todo Remove pblayer and pmap. Use global pointer for them
43 */
44 MainSim(
45 SDL_mutex* mutex,
46 BuildingLayer* pblayer,
47 Map* pmap );
48
49
50 //========================================================================
51 /** Destructs a MainSim object.
52 */
53 ~MainSim();
54
55
56 //========================================================================
57 /** Overload the base method in order to call all other microsims' method
58 \param rfs A reference to a file stream which is ready for writing
59 */
60 void
61 SaveTo( std::fstream& rfs );
62
63
64 //========================================================================
65 /** Overload the base method in order to call all other microsims' method
66 \param rfs A reference to a file stream which is ready for reading
67 */
68 void
69 LoadFrom( std::fstream& rfs );
70
71
72 //========================================================================
73 /** The main method of the simulator
74 */
75 int
76 Main();
77
78
79 //========================================================================
80 /** Notifies the micro simulators that a new structure has been added to the
81 system
82 \param w1,l1,w2,l2 The area used by the new structure
83 \param sim The optional microsim identifier
84 */
85 void
86 AddStructure(
87 const uint w1, const uint l1,
88 const uint w2, const uint l2,
89 const OPENCITY_SIMULATOR sim = OC_SIMULATOR_DEFAULT );
90
91
92 //========================================================================
93 /** Notify the micro simulators that a structure has been removed from the
94 system
95 \param w1,l1,w2,l2 The area used by the structure
96 \param sim The optional microsim identifier
97 */
98 void
99 RemoveStructure(
100 const uint w1, const uint l1,
101 const uint w2, const uint l2,
102 const OPENCITY_SIMULATOR sim = OC_SIMULATOR_DEFAULT );
103
104
105 //========================================================================
106 /** Overload the parent's method
107 \see Simulator::Run()
108 */
109 void
110 Run();
111
112
113 //========================================================================
114 /** Overload the parent's method
115 \see Simulator::Stop()
116 */
117 void
118 Stop();
119
120
121 //========================================================================
122 /** Overload the parent's method
123 \see Simulator::Return()
124 */
125 void
126 Return();
127
128
129 //========================================================================
130 /** Refresh the values of all the micro simulators. This method is called
131 automatically by Run() every 3 turns
132 \see Run()
133 */
134 void
135 RefreshSimValue();
136
137
138 //========================================================================
139 /** Return the global total value of the micro simulator
140 \param sim The micro simulator to query the information
141 \return The value
142 */
143 const int
144 GetValue( const OPENCITY_SIMULATOR sim ) const;
145
146
147 //========================================================================
148 /** Return the possible maximum value of the micro simulator.
149 \param sim The micro simulator to query the information
150 \return The value
151 \note Currently, this method only works for the electricity micro
152 simulator.
153 */
154 const int
155 GetMaxValue( const OPENCITY_SIMULATOR sim ) const;
156
157
158 private:
159 /** Table of pointers to Simulator object */
160 Simulator* _tpSimulator[Simulator::OC_SIMULATOR_NUMBER];
161 };
162
163 #endif