Atlas-C++
RootEntity.h
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 
21 class RootEntityData;
22 typedef SmartPtr<RootEntityData> RootEntity;
23 
24 static const int ROOT_ENTITY_NO = 2;
25 
28 
30 class RootEntityData : public RootData
31 {
32 protected:
34  RootEntityData(RootEntityData *defaults = NULL) :
35  RootData((RootData*)defaults)
36  {
37  m_class_no = ROOT_ENTITY_NO;
38  }
40  virtual ~RootEntityData();
41 
42 public:
44  virtual RootEntityData * copy() const;
45 
47  virtual bool instanceOf(int classNo) const;
48 
51  virtual int copyAttr(const std::string& name, Atlas::Message::Element & attr) const;
53  virtual void setAttr(const std::string& name,
54  const Atlas::Message::Element& attr);
56  virtual void removeAttr(const std::string& name);
57 
59  virtual void sendContents(Atlas::Bridge & b) const;
60 
62  virtual void addToMessage(Atlas::Message::MapType &) const;
63 
65  inline void setLoc(const std::string& val);
67  inline void setPos(const std::vector<double>& val);
69  inline void setPosAsList(const Atlas::Message::ListType& val);
71  inline void setVelocity(const std::vector<double>& val);
73  inline void setVelocityAsList(const Atlas::Message::ListType& val);
75  inline void setContains(const std::list<std::string>& val);
77  inline void setContainsAsList(const Atlas::Message::ListType& val);
79  inline void setStampContains(double val);
80 
82  inline const std::string& getLoc() const;
84  inline std::string& modifyLoc();
86  inline const std::vector<double>& getPos() const;
88  inline std::vector<double>& modifyPos();
90  inline const Atlas::Message::ListType getPosAsList() const;
92  inline const std::vector<double>& getVelocity() const;
94  inline std::vector<double>& modifyVelocity();
96  inline const Atlas::Message::ListType getVelocityAsList() const;
98  inline const std::list<std::string>& getContains() const;
100  inline std::list<std::string>& modifyContains();
102  inline const Atlas::Message::ListType getContainsAsList() const;
104  inline double getStampContains() const;
106  inline double& modifyStampContains();
107 
109  inline bool isDefaultLoc() const;
111  inline bool isDefaultPos() const;
113  inline bool isDefaultVelocity() const;
115  inline bool isDefaultContains() const;
117  inline bool isDefaultStampContains() const;
118 
119 protected:
121  virtual int getAttrClass(const std::string& name)const;
123  virtual int getAttrFlag(const std::string& name)const;
125  std::string attr_loc;
127  std::vector<double> attr_pos;
129  std::vector<double> attr_velocity;
131  std::list<std::string> attr_contains;
134 
136  void sendLoc(Atlas::Bridge&) const;
138  void sendPos(Atlas::Bridge&) const;
140  void sendVelocity(Atlas::Bridge&) const;
142  void sendContains(Atlas::Bridge&) const;
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 
157  virtual RootEntityData *getDefaultObject();
158 
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 
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 
195 void RootEntityData::setPos(const std::vector<double>& val)
196 {
197  attr_pos = val;
198  m_attrFlags |= POS_FLAG;
199 }
200 
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 
217 void RootEntityData::setVelocity(const std::vector<double>& val)
218 {
219  attr_velocity = val;
220  m_attrFlags |= VELOCITY_FLAG;
221 }
222 
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 
239 void RootEntityData::setContains(const std::list<std::string>& val)
240 {
241  attr_contains = val;
242  m_attrFlags |= CONTAINS_FLAG;
243 }
244 
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 
262 {
263  attr_stamp_contains = val;
264  m_attrFlags |= STAMP_CONTAINS_FLAG;
265 }
266 
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 
276 {
277  if(!(m_attrFlags & LOC_FLAG))
278  setLoc(((RootEntityData*)m_defaults)->attr_loc);
279  return attr_loc;
280 }
281 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
375 {
376  if(!(m_attrFlags & STAMP_CONTAINS_FLAG))
378  return attr_stamp_contains;
379 }
380 
382 {
383  return (m_attrFlags & LOC_FLAG) == 0;
384 }
385 
387 {
388  return (m_attrFlags & POS_FLAG) == 0;
389 }
390 
392 {
393  return (m_attrFlags & VELOCITY_FLAG) == 0;
394 }
395 
397 {
398  return (m_attrFlags & CONTAINS_FLAG) == 0;
399 }
400 
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
virtual ~RootEntityData()
Default destructor.
const Atlas::Message::ListType getContainsAsList() const
Retrieve the "contains" attribute AsList.
Definition: RootEntity.h:353
std::vector< double > & modifyPos()
Retrieve the "pos" attribute as a non-const reference.
Definition: RootEntity.h:290
const std::list< std::string > & getContains() const
Retrieve the "contains" attribute.
Definition: RootEntity.h:338
void setVelocityAsList(const Atlas::Message::ListType &val)
Set the "velocity" attribute AsList.
Definition: RootEntity.h:223
const std::vector< double > & getVelocity() const
Retrieve the "velocity" attribute.
Definition: RootEntity.h:310
RootEntityData(RootEntityData *defaults=NULL)
Construct a RootEntityData class definition.
Definition: RootEntity.h:34
Atlas stream bridge.
Definition: Bridge.h:35
virtual bool instanceOf(int classNo) const
Is this instance of some class?
std::vector< double > attr_pos
Position coordinates, usually world is 3D.
Definition: RootEntity.h:127
const Atlas::Message::ListType getPosAsList() const
Retrieve the "pos" attribute AsList.
Definition: RootEntity.h:297
bool isDefaultVelocity() const
Is "velocity" value default?
Definition: RootEntity.h:391
void sendStampContains(Atlas::Bridge &) const
Send the "stamp_contains" attribute to an Atlas::Bridge.
bool isDefaultLoc() const
Is "loc" value default?
Definition: RootEntity.h:381
virtual void iterate(int &current_class, std::string &attr) const
Iterate over the attributes of this instance.
double attr_stamp_contains
Last time any object that uses this as reference recursively has been modified.
Definition: RootEntity.h:133
Multi-type container.
Definition: Element.h:60
virtual void setAttr(const std::string &name, const Atlas::Message::Element &attr)
Set the attribute "name" to the value given by"attr".
virtual int copyAttr(const std::string &name, Atlas::Message::Element &attr) const
Retrieve the attribute "name".
std::vector< double > & modifyVelocity()
Retrieve the "velocity" attribute as a non-const reference.
Definition: RootEntity.h:318
The Atlas namespace.
Definition: Bridge.h:20
void sendContains(Atlas::Bridge &) const
Send the "contains" attribute to an Atlas::Bridge.
void sendPos(Atlas::Bridge &) const
Send the "pos" attribute to an Atlas::Bridge.
All objects inherit from this.
Definition: Root.h:35
void setContainsAsList(const Atlas::Message::ListType &val)
Set the "contains" attribute AsList.
Definition: RootEntity.h:245
virtual RootEntityData * getDefaultObject()
Get the reference object that contains the default values for attributes of instances of the same cla...
void setPos(const std::vector< double > &val)
Set the "pos" attribute.
Definition: RootEntity.h:195
const Atlas::Message::ListType getVelocityAsList() const
Retrieve the "velocity" attribute AsList.
Definition: RootEntity.h:325
bool isDefaultPos() const
Is "pos" value default?
Definition: RootEntity.h:386
double & modifyStampContains()
Retrieve the "stamp_contains" attribute as a non-const reference.
Definition: RootEntity.h:374
virtual void sendContents(Atlas::Bridge &b) const
Send the contents of this object to a Bridge.
std::vector< double > attr_velocity
Velocity object is moving, usually world is 3D.
Definition: RootEntity.h:129
void setPosAsList(const Atlas::Message::ListType &val)
Set the "pos" attribute AsList.
Definition: RootEntity.h:201
std::string & modifyLoc()
Retrieve the "loc" attribute as a non-const reference.
Definition: RootEntity.h:275
double getStampContains() const
Retrieve the "stamp_contains" attribute.
Definition: RootEntity.h:366
virtual void free()
Free an instance of this class, returning it to the memory pool.
bool isDefaultStampContains() const
Is "stamp_contains" value default?
Definition: RootEntity.h:401
std::list< std::string > & modifyContains()
Retrieve the "contains" attribute as a non-const reference.
Definition: RootEntity.h:346
std::list< std::string > attr_contains
List of objects that use this object as reference system (usually same as what this object contains)...
Definition: RootEntity.h:131
virtual void addToMessage(Atlas::Message::MapType &) const
Write this object to an existing Element.
void setContains(const std::list< std::string > &val)
Set the "contains" attribute.
Definition: RootEntity.h:239
Starting point for entity hierarchy.
Definition: RootEntity.h:30
virtual int getAttrFlag(const std::string &name) const
Find the flag for the attribute "name".
std::string attr_loc
Reference object for coordinates (location).
Definition: RootEntity.h:125
void setLoc(const std::string &val)
Set the "loc" attribute.
Definition: RootEntity.h:187
void setStampContains(double val)
Set the "stamp_contains" attribute.
Definition: RootEntity.h:261
virtual RootEntityData * copy() const
Copy this object.
const std::string & getLoc() const
Retrieve the "loc" attribute.
Definition: RootEntity.h:267
void sendLoc(Atlas::Bridge &) const
Send the "loc" attribute to an Atlas::Bridge.
void sendVelocity(Atlas::Bridge &) const
Send the "velocity" attribute to an Atlas::Bridge.
static RootEntityData * getDefaultObjectInstance()
Get the reference object that contains the default values for attributes of instances of this class...
virtual void removeAttr(const std::string &name)
Remove the attribute "name". This will not work for static attributes.
virtual int getAttrClass(const std::string &name) const
Find the class which contains the attribute "name".
void setVelocity(const std::vector< double > &val)
Set the "velocity" attribute.
Definition: RootEntity.h:217
const std::vector< double > & getPos() const
Retrieve the "pos" attribute.
Definition: RootEntity.h:282
bool isDefaultContains() const
Is "contains" value default?
Definition: RootEntity.h:396

Copyright 2000-2004 the respective authors.

This document can be licensed under the terms of the GNU Free Documentation License or the GNU General Public License and may be freely distributed under the terms given by one of these licenses.