Debian Codegraph @

src/structure/structure.h

raw symbols SCIP
1 /***************************************************************************
2 structure.h - description
3 -------------------
4 begin : june 16th, 2003
5 copyright : (C) 2003-2007 by Duong Khang NGUYEN
6 email : neoneurone @ gmail com
7
8 $Id: structure.h 375 2008-10-28 14:47:15Z 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_STRUCTURE_H_
21 #define _OPENCITY_STRUCTURE_H_ 1
22
23 #include "main.h"
24 #include "persistence.h"
25
26
27 // Structure relative attributes
28 #define OC_STRUCTURE_X 0x00 // Unknown
29 #define OC_STRUCTURE_R 0x01
30 #define OC_STRUCTURE_C 0x02
31 #define OC_STRUCTURE_I 0x04
32 #define OC_STRUCTURE_W 0x08
33 #define OC_STRUCTURE_E 0x10
34 #define OC_STRUCTURE_G 0x20
35 #define OC_STRUCTURE_P 0x40
36 #define OC_STRUCTURE_MARK 0x80
37
38 // Do _not_ change the values below if you don't know what you are doing
39 #define OC_STRUCTURE_LEVEL_START 0
40 #define OC_STRUCTURE_LEVEL_MAX 99
41 #define OC_STRUCTURE_LEVEL_MIN 0
42 #define OC_STRUCTURE_LEVEL_RATIO 10
43
44
45 /** The base class for all stuctures including roads, rails, buildings, etc ...
46 */
47 class Structure : public Persistence {
48 public:
49 //========================================================================
50 // STATIC METHODS
51 //========================================================================
52 //========================================================================
53 /** Return the number of structures created so far
54 \return The number of structures created
55 */
56 static const uint &
57 GetNumber();
58
59 //========================================================================
60 /** Set the number of created structures
61 \param rcuiNb Number of structures
62 */
63 static void
64 SetNumber( const uint & rcuiNb );
65
66
67 Structure( );
68 Structure( const OPENCITY_STRUCTURE_CODE enumStructCode );
69 Structure(
70 const OPENCITY_STRUCTURE_CODE enumStructCode,
71 Structure* pMain
72 );
73
74
75 virtual ~Structure( );
76
77
78 //========================================================================
79 /** Save the data to the specified fstream
80 \note The pointer to the main structured is _not_ saved. It's up to the
81 user to remap the pointer to the main structured correctly.
82 \param rfs A reference to a file stream which is ready for writing
83 \see Persistence
84 */
85 void
86 SaveTo( std::fstream& rfs );
87
88
89 //========================================================================
90 /** Load the data from the specified stream
91 \note The pointer to the main structured is _not_ loaded. It's up to the
92 user to remap the pointer to the main structured correctly.
93 \param rfs A reference to a file stream which is ready for reading
94 \see Persistence
95 */
96 void
97 LoadFrom( std::fstream& rfs );
98
99
100 //========================================================================
101 /** Set the properties of the structure to wegBit
102 \param wegBit The desired properties. You can combine them by using the OR
103 operator.
104 */
105 void
106 Set( const uint wegBit );
107
108 void
109 Unset( const uint wegBit );
110
111 const bool
112 IsSet( const uint wegBit ) const;
113
114
115 //========================================================================
116 /** Returns the current GRAPHIC_CODE of the structure
117 */
118 const OPENCITY_GRAPHIC_CODE
119 GetGraphicCode() const;
120
121
122 //========================================================================
123 /** Returns the first base GRAPHIC_CODE of the structure depending on its
124 structure type
125 */
126 const OPENCITY_GRAPHIC_CODE
127 GetBaseGraphicCode() const;
128
129
130 //========================================================================
131 /** Returns the GRAPHIC_CODE of the next level
132 */
133 virtual const OPENCITY_GRAPHIC_CODE
134 GetNextLevelGraphicCode() const;
135
136
137 //========================================================================
138 /** Returns the GRAPHIC_CODE of the previous level
139 */
140 virtual const OPENCITY_GRAPHIC_CODE
141 GetPreviousLevelGraphicCode() const;
142
143
144 //========================================================================
145 /** Returns the current STRUCTURE_CODE of the structure. This is
146 different from the GRAPHIC_CODE. The structure code is the _type_ of
147 the structure where as the graphic code defines the model which is
148 displayed by the renderer.
149 */
150 const OPENCITY_STRUCTURE_CODE
151 GetCode() const;
152
153
154 //========================================================================
155 /** Get the pointer to main structure. NULL if unavailable
156 */
157 Structure*
158 GetMain() const;
159
160
161 void
162 SetMain( Structure* const pstruct );
163
164
165 virtual const bool
166 LevelUp();
167
168 virtual const bool
169 LevelDown();
170
171
172 const uint
173 GetLevel() const;
174
175 void
176 SetLevel( const uint uiLevel );
177
178
179 //========================================================================
180 /** The type of the structure is useful for un/serialization
181 */
182 const OPENCITY_STRUCTURE_TYPE
183 GetType() const;
184
185
186 protected:
187 OPENCITY_GRAPHIC_CODE _eGC; ///< Graphic code
188 OPENCITY_STRUCTURE_CODE _eSC; ///< Structure code
189 OPENCITY_STRUCTURE_TYPE _eType; ///< Structure type
190 uint _uiStatus;
191 uint _uiLevel;
192
193 /** Pointer of the main structure
194 IF this is just a part of a bigger structure
195 ELSE equal to NULL
196 */
197 Structure* _pstructureMain;
198
199
200 private:
201 /// The total of the structures created so far
202 static uint uiNumberStructure;
203
204 };
205
206 #endif
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235