1 // This file may be redistributed and modified only under the terms of
2 // the GNU Lesser General Public License (See COPYING for details).
3 // Copyright 2000-2001 Stefanus Du Toit and Aloril.
4 // Copyright 2001-2005 Alistair Riddoch.
5 // Automatically generated using gen_cpp.py.
6 
7 #ifndef ATLAS_OBJECTS_ENTITY_ROOTENTITY_H
8 #define ATLAS_OBJECTS_ENTITY_ROOTENTITY_H
9 
10 #include <Atlas/Objects/Root.h>
11 #include <Atlas/Objects/SmartPtr.h>
12 
13 namespace Atlas { namespace Objects { namespace Entity {
14 
15 /** Starting point for entity hierarchy
16 
17 Later in hierarchy tree objtype changes to 'object' when actual game objects are made.
18 
19 */
20 
21 class RootEntityData;
22 typedef SmartPtr<RootEntityData> RootEntity;
23 
24 static const int ROOT_ENTITY_NO = 2;
25 
26 /// \brief Starting point for entity hierarchy.
27 ///
28 /** Later in hierarchy tree objtype changes to 'object' when actual game objects are made.
29  */
30 class RootEntityData : public RootData
31 {
32 protected:
33     /// Construct a RootEntityData class definition.
34     RootEntityData(RootEntityData *defaults = NULL) :
35         RootData((RootData*)defaults)
36     {
37         m_class_no = ROOT_ENTITY_NO;
38     }
39     /// Default destructor.
40     virtual ~RootEntityData();
41 
42 public:
43     /// Copy this object.
44     virtual RootEntityData * copy() const;
45 
46     /// Is this instance of some class?
47     virtual bool instanceOf(int classNo) const;
48 
49     /// Retrieve the attribute "name". Return non-zero if it does
50     /// not exist.
51     virtual int copyAttr(const std::string& name, Atlas::Message::Element & attr) const;
52     /// Set the attribute "name" to the value given by"attr"
53     virtual void setAttr(const std::string& name,
54                          const Atlas::Message::Element& attr);
55     /// Remove the attribute "name". This will not work for static attributes.
56     virtual void removeAttr(const std::string& name);
57 
58     /// Send the contents of this object to a Bridge.
59     virtual void sendContents(Atlas::Bridge & b) const;
60 
61     /// Write this object to an existing Element.
62     virtual void addToMessage(Atlas::Message::MapType &) const;
63 
64     /// Set the "loc" attribute.
65     inline void setLoc(const std::string& val);
66     /// Set the "pos" attribute.
67     inline void setPos(const std::vector<double>& val);
68     /// Set the "pos" attribute AsList.
69     inline void setPosAsList(const Atlas::Message::ListType& val);
70     /// Set the "velocity" attribute.
71     inline void setVelocity(const std::vector<double>& val);
72     /// Set the "velocity" attribute AsList.
73     inline void setVelocityAsList(const Atlas::Message::ListType& val);
74     /// Set the "contains" attribute.
75     inline void setContains(const std::list<std::string>& val);
76     /// Set the "contains" attribute AsList.
77     inline void setContainsAsList(const Atlas::Message::ListType& val);
78     /// Set the "stamp_contains" attribute.
79     inline void setStampContains(double val);
80 
81     /// Retrieve the "loc" attribute.
82     inline const std::string& getLoc() const;
83     /// Retrieve the "loc" attribute as a non-const reference.
84     inline std::string& modifyLoc();
85     /// Retrieve the "pos" attribute.
86     inline const std::vector<double>& getPos() const;
87     /// Retrieve the "pos" attribute as a non-const reference.
88     inline std::vector<double>& modifyPos();
89     /// Retrieve the "pos" attribute AsList.
90     inline const Atlas::Message::ListType getPosAsList() const;
91     /// Retrieve the "velocity" attribute.
92     inline const std::vector<double>& getVelocity() const;
93     /// Retrieve the "velocity" attribute as a non-const reference.
94     inline std::vector<double>& modifyVelocity();
95     /// Retrieve the "velocity" attribute AsList.
96     inline const Atlas::Message::ListType getVelocityAsList() const;
97     /// Retrieve the "contains" attribute.
98     inline const std::list<std::string>& getContains() const;
99     /// Retrieve the "contains" attribute as a non-const reference.
100     inline std::list<std::string>& modifyContains();
101     /// Retrieve the "contains" attribute AsList.
102     inline const Atlas::Message::ListType getContainsAsList() const;
103     /// Retrieve the "stamp_contains" attribute.
104     inline double getStampContains() const;
105     /// Retrieve the "stamp_contains" attribute as a non-const reference.
106     inline double& modifyStampContains();
107 
108     /// Is "loc" value default?
109     inline bool isDefaultLoc() const;
110     /// Is "pos" value default?
111     inline bool isDefaultPos() const;
112     /// Is "velocity" value default?
113     inline bool isDefaultVelocity() const;
114     /// Is "contains" value default?
115     inline bool isDefaultContains() const;
116     /// Is "stamp_contains" value default?
117     inline bool isDefaultStampContains() const;
118 
119 protected:
120     /// Find the class which contains the attribute "name".
121     virtual int getAttrClass(const std::string& name)const;
122     /// Find the flag for the attribute "name".
123     virtual int getAttrFlag(const std::string& name)const;
124     /// Reference object for coordinates (location).
125     std::string attr_loc;
126     /// Position coordinates, usually world is 3D
127     std::vector<double> attr_pos;
128     /// Velocity object is moving, usually world is 3D
129     std::vector<double> attr_velocity;
130     /// List of objects that use this object as reference system (usually same as what this object contains).
131     std::list<std::string> attr_contains;
132     /// Last time any object that uses this as reference recursively has been modified
133     double attr_stamp_contains;
134 
135     /// Send the "loc" attribute to an Atlas::Bridge.
136     void sendLoc(Atlas::Bridge&) const;
137     /// Send the "pos" attribute to an Atlas::Bridge.
138     void sendPos(Atlas::Bridge&) const;
139     /// Send the "velocity" attribute to an Atlas::Bridge.
140     void sendVelocity(Atlas::Bridge&) const;
141     /// Send the "contains" attribute to an Atlas::Bridge.
142     void sendContains(Atlas::Bridge&) const;
143     /// Send the "stamp_contains" attribute to an Atlas::Bridge.
144     void sendStampContains(Atlas::Bridge&) const;
145 
146     virtual void iterate(int& current_class, std::string& attr) const;
147 
148     //freelist related things
149 public:
150     static RootEntityData *alloc();
151     virtual void free();
152 
153     /// \brief Get the reference object that contains the default values for
154     /// attributes of instances of the same class as this object.
155     ///
156     /// @return a pointer to the default object.
157     virtual RootEntityData *getDefaultObject();
158 
159     /// \brief Get the reference object that contains the default values for
160     /// attributes of instances of this class.
161     ///
162     /// @return a pointer to the default object.
163     static RootEntityData *getDefaultObjectInstance();
164 private:
165     static RootEntityData *defaults_RootEntityData;
166     static RootEntityData *begin_RootEntityData;
167 
168     static std::map<std::string, int> * attr_flags_RootEntityData;
169 };
170 
171 //
172 // Attribute name strings follow.
173 //
174 
175 extern const std::string LOC_ATTR;
176 extern const std::string POS_ATTR;
177 extern const std::string VELOCITY_ATTR;
178 extern const std::string CONTAINS_ATTR;
179 extern const std::string STAMP_CONTAINS_ATTR;
180 
181 //
182 // Inlined member functions follow.
183 //
184 
185 const int LOC_FLAG = 1 << 6;
186 
setLoc(const std::string & val)187 void RootEntityData::setLoc(const std::string& val)
188 {
189     attr_loc = val;
190     m_attrFlags |= LOC_FLAG;
191 }
192 
193 const int POS_FLAG = 1 << 7;
194 
setPos(const std::vector<double> & val)195 void RootEntityData::setPos(const std::vector<double>& val)
196 {
197     attr_pos = val;
198     m_attrFlags |= POS_FLAG;
199 }
200 
setPosAsList(const Atlas::Message::ListType & val)201 void RootEntityData::setPosAsList(const Atlas::Message::ListType& val)
202 {
203     m_attrFlags |= POS_FLAG;
204     attr_pos.resize(0);
205     for(Atlas::Message::ListType::const_iterator I = val.begin();
206         I != val.end();
207         I++)
208     {
209         if((*I).isNum()) {
210             attr_pos.push_back((*I).asNum());
211         }
212     }
213 }
214 
215 const int VELOCITY_FLAG = 1 << 8;
216 
setVelocity(const std::vector<double> & val)217 void RootEntityData::setVelocity(const std::vector<double>& val)
218 {
219     attr_velocity = val;
220     m_attrFlags |= VELOCITY_FLAG;
221 }
222 
setVelocityAsList(const Atlas::Message::ListType & val)223 void RootEntityData::setVelocityAsList(const Atlas::Message::ListType& val)
224 {
225     m_attrFlags |= VELOCITY_FLAG;
226     attr_velocity.resize(0);
227     for(Atlas::Message::ListType::const_iterator I = val.begin();
228         I != val.end();
229         I++)
230     {
231         if((*I).isNum()) {
232             attr_velocity.push_back((*I).asNum());
233         }
234     }
235 }
236 
237 const int CONTAINS_FLAG = 1 << 9;
238 
setContains(const std::list<std::string> & val)239 void RootEntityData::setContains(const std::list<std::string>& val)
240 {
241     attr_contains = val;
242     m_attrFlags |= CONTAINS_FLAG;
243 }
244 
setContainsAsList(const Atlas::Message::ListType & val)245 void RootEntityData::setContainsAsList(const Atlas::Message::ListType& val)
246 {
247     m_attrFlags |= CONTAINS_FLAG;
248     attr_contains.resize(0);
249     for(Atlas::Message::ListType::const_iterator I = val.begin();
250         I != val.end();
251         I++)
252     {
253         if((*I).isString()) {
254             attr_contains.push_back((*I).asString());
255         }
256     }
257 }
258 
259 const int STAMP_CONTAINS_FLAG = 1 << 10;
260 
setStampContains(double val)261 void RootEntityData::setStampContains(double val)
262 {
263     attr_stamp_contains = val;
264     m_attrFlags |= STAMP_CONTAINS_FLAG;
265 }
266 
getLoc()267 const std::string& RootEntityData::getLoc() const
268 {
269     if(m_attrFlags & LOC_FLAG)
270         return attr_loc;
271     else
272         return ((RootEntityData*)m_defaults)->attr_loc;
273 }
274 
modifyLoc()275 std::string& RootEntityData::modifyLoc()
276 {
277     if(!(m_attrFlags & LOC_FLAG))
278         setLoc(((RootEntityData*)m_defaults)->attr_loc);
279     return attr_loc;
280 }
281 
getPos()282 const std::vector<double>& RootEntityData::getPos() const
283 {
284     if(m_attrFlags & POS_FLAG)
285         return attr_pos;
286     else
287         return ((RootEntityData*)m_defaults)->attr_pos;
288 }
289 
modifyPos()290 std::vector<double>& RootEntityData::modifyPos()
291 {
292     if(!(m_attrFlags & POS_FLAG))
293         setPos(((RootEntityData*)m_defaults)->attr_pos);
294     return attr_pos;
295 }
296 
getPosAsList()297 const Atlas::Message::ListType RootEntityData::getPosAsList() const
298 {
299     const std::vector<double>& lst_in = getPos();
300     Atlas::Message::ListType lst_out;
301     for(std::vector<double>::const_iterator I = lst_in.begin();
302         I != lst_in.end();
303         I++)
304     {
305         lst_out.push_back(*I);
306     }
307     return lst_out;
308 }
309 
getVelocity()310 const std::vector<double>& RootEntityData::getVelocity() const
311 {
312     if(m_attrFlags & VELOCITY_FLAG)
313         return attr_velocity;
314     else
315         return ((RootEntityData*)m_defaults)->attr_velocity;
316 }
317 
modifyVelocity()318 std::vector<double>& RootEntityData::modifyVelocity()
319 {
320     if(!(m_attrFlags & VELOCITY_FLAG))
321         setVelocity(((RootEntityData*)m_defaults)->attr_velocity);
322     return attr_velocity;
323 }
324 
getVelocityAsList()325 const Atlas::Message::ListType RootEntityData::getVelocityAsList() const
326 {
327     const std::vector<double>& lst_in = getVelocity();
328     Atlas::Message::ListType lst_out;
329     for(std::vector<double>::const_iterator I = lst_in.begin();
330         I != lst_in.end();
331         I++)
332     {
333         lst_out.push_back(*I);
334     }
335     return lst_out;
336 }
337 
getContains()338 const std::list<std::string>& RootEntityData::getContains() const
339 {
340     if(m_attrFlags & CONTAINS_FLAG)
341         return attr_contains;
342     else
343         return ((RootEntityData*)m_defaults)->attr_contains;
344 }
345 
modifyContains()346 std::list<std::string>& RootEntityData::modifyContains()
347 {
348     if(!(m_attrFlags & CONTAINS_FLAG))
349         setContains(((RootEntityData*)m_defaults)->attr_contains);
350     return attr_contains;
351 }
352 
getContainsAsList()353 const Atlas::Message::ListType RootEntityData::getContainsAsList() const
354 {
355     const std::list<std::string>& lst_in = getContains();
356     Atlas::Message::ListType lst_out;
357     for(std::list<std::string>::const_iterator I = lst_in.begin();
358         I != lst_in.end();
359         I++)
360     {
361         lst_out.push_back(std::string(*I));
362     }
363     return lst_out;
364 }
365 
getStampContains()366 double RootEntityData::getStampContains() const
367 {
368     if(m_attrFlags & STAMP_CONTAINS_FLAG)
369         return attr_stamp_contains;
370     else
371         return ((RootEntityData*)m_defaults)->attr_stamp_contains;
372 }
373 
modifyStampContains()374 double& RootEntityData::modifyStampContains()
375 {
376     if(!(m_attrFlags & STAMP_CONTAINS_FLAG))
377         setStampContains(((RootEntityData*)m_defaults)->attr_stamp_contains);
378     return attr_stamp_contains;
379 }
380 
isDefaultLoc()381 bool RootEntityData::isDefaultLoc() const
382 {
383     return (m_attrFlags & LOC_FLAG) == 0;
384 }
385 
isDefaultPos()386 bool RootEntityData::isDefaultPos() const
387 {
388     return (m_attrFlags & POS_FLAG) == 0;
389 }
390 
isDefaultVelocity()391 bool RootEntityData::isDefaultVelocity() const
392 {
393     return (m_attrFlags & VELOCITY_FLAG) == 0;
394 }
395 
isDefaultContains()396 bool RootEntityData::isDefaultContains() const
397 {
398     return (m_attrFlags & CONTAINS_FLAG) == 0;
399 }
400 
isDefaultStampContains()401 bool RootEntityData::isDefaultStampContains() const
402 {
403     return (m_attrFlags & STAMP_CONTAINS_FLAG) == 0;
404 }
405 
406 
407 } } } // namespace Atlas::Objects::Entity
408 
409 #endif // ATLAS_OBJECTS_ENTITY_ROOTENTITY_H
410