Debian Codegraph @

src/property.h

raw symbols SCIP
1 /***************************************************************************
2 property.h - description
3 -------------------
4 begin : january 28th, 2007
5 copyright : (C) 2007 by Duong Khang NGUYEN
6 email : neoneurone @ gmail com
7
8 $Id: property.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_PROPERTY_H_
21 #define _OPENCITY_PROPERTY_H_ 1
22
23 #include "main.h"
24
25 #include <climits> // INT_MAX
26
27 // Useful enumerations
28 #include "opencity_direction.h"
29 #include "opencity_structure_type.h"
30
31
32 // Object's properties XPath expressions
33 #define OC_METADATA_PROPERTY_NODE "/object/property"
34 #define OC_METADATA_COST_NODE "/object/property/cost"
35
36 #define OC_METADATA_NEED_R_NODE "/object/property/r/need"
37 #define OC_METADATA_PROVIDE_R_NODE "/object/property/r/provide"
38 #define OC_METADATA_NEED_C_NODE "/object/property/c/need"
39 #define OC_METADATA_PROVIDE_C_NODE "/object/property/c/provide"
40 #define OC_METADATA_NEED_I_NODE "/object/property/i/need"
41 #define OC_METADATA_PROVIDE_I_NODE "/object/property/i/provide"
42 #define OC_METADATA_NEED_W_NODE "/object/property/w/need"
43 #define OC_METADATA_PROVIDE_W_NODE "/object/property/w/provide"
44 #define OC_METADATA_NEED_E_NODE "/object/property/e/need"
45 #define OC_METADATA_PROVIDE_E_NODE "/object/property/e/provide"
46 #define OC_METADATA_NEED_G_NODE "/object/property/g/need"
47 #define OC_METADATA_PROVIDE_G_NODE "/object/property/g/provide"
48
49 #define OC_METADATA_NEED_T_NODE "/object/property/t/need"
50 #define OC_METADATA_PROVIDE_T_NODE "/object/property/t/provide"
51 #define OC_METADATA_NEED_NATURE_NODE "/object/property/nature/need"
52 #define OC_METADATA_PROVIDE_NATURE_NODE "/object/property/nature/provide"
53
54 #define OC_METADATA_STRUCTURE_TYPE_ATTRIBUTE "/object/property/@type"
55 #define OC_METADATA_INHABITANT_ATTRIBUTE "/object/property/@inhabitant"
56 #define OC_METADATA_RADIUS_ATTRIBUTE "/object/property/@radius"
57 #define OC_METADATA_WORKER_ATTRIBUTE "/object/property/@worker"
58 #define OC_METADATA_DIRECTION_ATTRIBUTE "/object/property/direction/@value"
59
60 #define OC_METADATA_MODEL_NODE "/object/model"
61
62
63 enum OPENCITY_DIRECTION;
64 enum OPENCITY_STRUCTURE_TYPE;
65
66
67 //========================================================================
68 /** A simple min/max type */
69 class MinMax
70 {
71 public:
72 int iMin, iMax;
73
74 MinMax( int min, int max):
75 iMin(min), iMax(max)
76 {}
77 };
78
79
80 //========================================================================
81 /** Each "need", "provide" property is limited by its min and max values.
82 */
83 class NeedProvide
84 {
85 public:
86 MinMax mmNeed, mmProvide;
87
88 NeedProvide():
89 mmNeed(0, INT_MAX), mmProvide(0, 0)
90 {}
91 };
92
93
94 //========================================================================
95 /** The properties of each building (structure) in OpenCity are
96 encapsulated in this structure.
97 */
98 class Property
99 {
100 public:
101 /** The financial aspects of the object
102 */
103 uint uiBuildCost, uiDestroyCost, uiSupportCost, uiIncome;
104
105 /** The need/provide properties
106 */
107 NeedProvide sResidence, sCommerce, sIndustry;
108 NeedProvide sWater, sElectricity, sGas;
109 NeedProvide sTraffic, sNature;
110
111 /** The dimensions of the model
112 */
113 uint uiWidth, uiLength;
114 float fHeight;
115
116 /** The generated number of inhabitant, worker and the radius of the influence
117 upon the other objects
118 */
119 uint uiInhabitant, uiWorker, uiRadius;
120
121 /** The OpenCity type of the object. This type is used for un/serialization
122 */
123 OPENCITY_STRUCTURE_TYPE eStructureType;
124
125 /** The directions to which the object is connected to.
126 */
127 OPENCITY_DIRECTION eDirection;
128
129
130 //========================================================================
131 /** Default ctor. Initialize all the member variables with their default
132 values.
133 */
134 Property():
135 uiBuildCost(0), uiDestroyCost(0), uiSupportCost(0), uiIncome(0),
136 uiWidth(0), uiLength(0),
137 fHeight(0),
138 uiInhabitant(0), uiWorker(0), uiRadius(0),
139 eStructureType(OC_TYPE_UNDEFINED),
140 eDirection(OC_DIR_UNDEFINED)
141 {
142 //OPENCITY_DEBUG( "ctor" );
143 }
144
145 ~Property()
146 {
147 //OPENCITY_DEBUG( "dtor" );
148 }
149
150
151 /** Load the property XML file from mass storage
152 \return The pointer loaded property object
153 */
154 static Property*
155 LoadProperties( string filename );
156
157
158 //========================================================================
159 // Private methods
160 //========================================================================
161 static const OPENCITY_DIRECTION
162 _Str2Direction(const string& rcstrDir);
163
164
165 static const OPENCITY_STRUCTURE_TYPE
166 _Str2Type(const string& rcstrType);
167 };
168
169 #endif
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201