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 // Copyright 2011 Erik Ogenvik.
6 // Automatically generated using gen_cpp.py.
7 
8 #ifndef ATLAS_OBJECTS_ENTITY_ROOTENTITY_H
9 #define ATLAS_OBJECTS_ENTITY_ROOTENTITY_H
10 
11 #include <Atlas/Objects/Root.h>
12 #include <Atlas/Objects/SmartPtr.h>
13 
14 namespace Atlas { namespace Objects { namespace Entity {
15 
22 class RootEntityData;
23 typedef SmartPtr<RootEntityData> RootEntity;
24 
25 static const int ROOT_ENTITY_NO = 2;
26 
29 
31 class RootEntityData : public RootData
32 {
33 protected:
35  RootEntityData(RootEntityData *defaults = nullptr) :
36  RootData((RootData*)defaults)
37  {
38  m_class_no = ROOT_ENTITY_NO;
39  }
41  ~RootEntityData() override = default;
42 
43 public:
45  RootEntityData * copy() const override;
46 
48  bool instanceOf(int classNo) const override;
49 
52  int copyAttr(const std::string& name, Atlas::Message::Element & attr) const override;
54  void setAttr(const std::string& name,
55  const Atlas::Message::Element& attr) override;
57  void removeAttr(const std::string& name) override;
58 
60  void sendContents(Atlas::Bridge & b) const override;
61 
63  void addToMessage(Atlas::Message::MapType &) const override;
64 
66  void setLoc(const std::string& val);
68  void setPos(const std::vector<double>& val);
70  void setPosAsList(const Atlas::Message::ListType& val);
72  void setVelocity(const std::vector<double>& val);
74  void setVelocityAsList(const Atlas::Message::ListType& val);
76  void setContains(const std::list<std::string>& val);
78  void setContainsAsList(const Atlas::Message::ListType& val);
80  void setStampContains(double val);
81 
83  const std::string& getLoc() const;
85  std::string& modifyLoc();
87  const std::vector<double>& getPos() const;
89  std::vector<double>& modifyPos();
91  const Atlas::Message::ListType getPosAsList() const;
93  const std::vector<double>& getVelocity() const;
95  std::vector<double>& modifyVelocity();
97  const Atlas::Message::ListType getVelocityAsList() const;
99  const std::list<std::string>& getContains() const;
101  std::list<std::string>& modifyContains();
103  const Atlas::Message::ListType getContainsAsList() const;
105  double getStampContains() const;
107  double& modifyStampContains();
108 
110  bool isDefaultLoc() const;
112  bool isDefaultPos() const;
114  bool isDefaultVelocity() const;
116  bool isDefaultContains() const;
118  bool isDefaultStampContains() const;
119 
120 protected:
122  int getAttrClass(const std::string& name)const override;
124  int32_t getAttrFlag(const std::string& name)const override;
126  std::string attr_loc;
128  std::vector<double> attr_pos;
130  std::vector<double> attr_velocity;
132  std::list<std::string> attr_contains;
135 
137  void sendLoc(Atlas::Bridge&) const;
139  void sendPos(Atlas::Bridge&) const;
141  void sendVelocity(Atlas::Bridge&) const;
143  void sendContains(Atlas::Bridge&) const;
145  void sendStampContains(Atlas::Bridge&) const;
146 
147  void iterate(int& current_class, std::string& attr) const override;
148 
149 public:
150  template <typename>
151  friend class ::Atlas::Objects::Allocator;
152  static Allocator<RootEntityData> allocator;
153 
154 protected:
156  void reset() override;
157  void free() override;
158 
159 private:
160 
161  static void fillDefaultObjectInstance(RootEntityData& data, std::map<std::string, int32_t>& attr_data);
162 };
163 
164 //
165 // Attribute name strings follow.
166 //
167 
168 extern const std::string LOC_ATTR;
169 extern const std::string POS_ATTR;
170 extern const std::string VELOCITY_ATTR;
171 extern const std::string CONTAINS_ATTR;
172 extern const std::string STAMP_CONTAINS_ATTR;
173 
174 //
175 // Inlined member functions follow.
176 //
177 
178 const int32_t LOC_FLAG = 1 << 6;
179 
180 inline void RootEntityData::setLoc(const std::string& val)
181 {
182  attr_loc = val;
183  m_attrFlags |= LOC_FLAG;
184 }
185 
186 const int32_t POS_FLAG = 1 << 7;
187 
188 inline void RootEntityData::setPos(const std::vector<double>& val)
189 {
190  attr_pos = val;
191  m_attrFlags |= POS_FLAG;
192 }
193 
194 inline void RootEntityData::setPosAsList(const Atlas::Message::ListType& val)
195 {
196  m_attrFlags |= POS_FLAG;
197  attr_pos.resize(0);
198  for (const auto& entry : val) {
199  if(entry.isNum()) {
200  attr_pos.push_back(entry.asNum());
201  }
202  }
203 }
204 
205 const int32_t VELOCITY_FLAG = 1 << 8;
206 
207 inline void RootEntityData::setVelocity(const std::vector<double>& val)
208 {
209  attr_velocity = val;
210  m_attrFlags |= VELOCITY_FLAG;
211 }
212 
213 inline void RootEntityData::setVelocityAsList(const Atlas::Message::ListType& val)
214 {
215  m_attrFlags |= VELOCITY_FLAG;
216  attr_velocity.resize(0);
217  for (const auto& entry : val) {
218  if(entry.isNum()) {
219  attr_velocity.push_back(entry.asNum());
220  }
221  }
222 }
223 
224 const int32_t CONTAINS_FLAG = 1 << 9;
225 
226 inline void RootEntityData::setContains(const std::list<std::string>& val)
227 {
228  attr_contains = val;
229  m_attrFlags |= CONTAINS_FLAG;
230 }
231 
232 inline void RootEntityData::setContainsAsList(const Atlas::Message::ListType& val)
233 {
234  m_attrFlags |= CONTAINS_FLAG;
235  attr_contains.resize(0);
236  for (const auto& entry : val) {
237  if(entry.isString()) {
238  attr_contains.push_back(entry.asString());
239  }
240  }
241 }
242 
243 const int32_t STAMP_CONTAINS_FLAG = 1 << 10;
244 
245 inline void RootEntityData::setStampContains(double val)
246 {
247  attr_stamp_contains = val;
248  m_attrFlags |= STAMP_CONTAINS_FLAG;
249 }
250 
251 inline const std::string& RootEntityData::getLoc() const
252 {
253  if(m_attrFlags & LOC_FLAG)
254  return attr_loc;
255  else
256  return ((RootEntityData*)m_defaults)->attr_loc;
257 }
258 
259 inline std::string& RootEntityData::modifyLoc()
260 {
261  if(!(m_attrFlags & LOC_FLAG))
263  return attr_loc;
264 }
265 
266 inline const std::vector<double>& RootEntityData::getPos() const
267 {
268  if(m_attrFlags & POS_FLAG)
269  return attr_pos;
270  else
271  return ((RootEntityData*)m_defaults)->attr_pos;
272 }
273 
274 inline std::vector<double>& RootEntityData::modifyPos()
275 {
276  if(!(m_attrFlags & POS_FLAG))
278  return attr_pos;
279 }
280 
281 inline const Atlas::Message::ListType RootEntityData::getPosAsList() const
282 {
283  const std::vector<double>& lst_in = getPos();
284  Atlas::Message::ListType lst_out;
285  for (const auto& entry : lst_in) {
286  lst_out.push_back(entry);
287  }
288  return lst_out;
289 }
290 
291 inline const std::vector<double>& RootEntityData::getVelocity() const
292 {
293  if(m_attrFlags & VELOCITY_FLAG)
294  return attr_velocity;
295  else
296  return ((RootEntityData*)m_defaults)->attr_velocity;
297 }
298 
299 inline std::vector<double>& RootEntityData::modifyVelocity()
300 {
301  if(!(m_attrFlags & VELOCITY_FLAG))
303  return attr_velocity;
304 }
305 
306 inline const Atlas::Message::ListType RootEntityData::getVelocityAsList() const
307 {
308  const std::vector<double>& lst_in = getVelocity();
309  Atlas::Message::ListType lst_out;
310  for (const auto& entry : lst_in) {
311  lst_out.push_back(entry);
312  }
313  return lst_out;
314 }
315 
316 inline const std::list<std::string>& RootEntityData::getContains() const
317 {
318  if(m_attrFlags & CONTAINS_FLAG)
319  return attr_contains;
320  else
321  return ((RootEntityData*)m_defaults)->attr_contains;
322 }
323 
324 inline std::list<std::string>& RootEntityData::modifyContains()
325 {
326  if(!(m_attrFlags & CONTAINS_FLAG))
328  return attr_contains;
329 }
330 
331 inline const Atlas::Message::ListType RootEntityData::getContainsAsList() const
332 {
333  const std::list<std::string>& lst_in = getContains();
334  Atlas::Message::ListType lst_out;
335  for (const auto& entry : lst_in) {
336  lst_out.push_back(std::string(entry));
337  }
338  return lst_out;
339 }
340 
341 inline double RootEntityData::getStampContains() const
342 {
343  if(m_attrFlags & STAMP_CONTAINS_FLAG)
344  return attr_stamp_contains;
345  else
346  return ((RootEntityData*)m_defaults)->attr_stamp_contains;
347 }
348 
350 {
351  if(!(m_attrFlags & STAMP_CONTAINS_FLAG))
353  return attr_stamp_contains;
354 }
355 
356 inline bool RootEntityData::isDefaultLoc() const
357 {
358  return (m_attrFlags & LOC_FLAG) == 0;
359 }
360 
361 inline bool RootEntityData::isDefaultPos() const
362 {
363  return (m_attrFlags & POS_FLAG) == 0;
364 }
365 
367 {
368  return (m_attrFlags & VELOCITY_FLAG) == 0;
369 }
370 
372 {
373  return (m_attrFlags & CONTAINS_FLAG) == 0;
374 }
375 
377 {
378  return (m_attrFlags & STAMP_CONTAINS_FLAG) == 0;
379 }
380 
381 
382 } } } // namespace Atlas::Objects::Entity
383 
384 #endif // ATLAS_OBJECTS_ENTITY_ROOTENTITY_H
bool isDefaultContains() const
Is "contains" value default?
Definition: RootEntity.h:371
std::vector< double > & modifyPos()
Retrieve the "pos" attribute as a non-const reference.
Definition: RootEntity.h:274
const std::vector< double > & getPos() const
Retrieve the "pos" attribute.
Definition: RootEntity.h:266
void setVelocityAsList(const Atlas::Message::ListType &val)
Set the "velocity" attribute AsList.
Definition: RootEntity.h:213
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
Retrieve the attribute "name".
bool isDefaultPos() const
Is "pos" value default?
Definition: RootEntity.h:361
const Atlas::Message::ListType getPosAsList() const
Retrieve the "pos" attribute AsList.
Definition: RootEntity.h:281
Atlas stream bridge.
Definition: Bridge.h:35
void free() override
Free an instance of this class, returning it to the memory pool.
void iterate(int &current_class, std::string &attr) const override
Iterate over the attributes of this instance.
std::vector< double > attr_pos
Position coordinates, usually world is 3D.
Definition: RootEntity.h:128
const Atlas::Message::ListType getContainsAsList() const
Retrieve the "contains" attribute AsList.
Definition: RootEntity.h:331
bool isDefaultLoc() const
Is "loc" value default?
Definition: RootEntity.h:356
BaseObjectData * m_defaults
The default instance, acting as a prototype for all other instances.
Definition: BaseObject.h:440
bool isDefaultStampContains() const
Is "stamp_contains" value default?
Definition: RootEntity.h:376
double attr_stamp_contains
Last time any object that uses this as reference recursively has been modified.
Definition: RootEntity.h:134
void sendPos(Atlas::Bridge &) const
Send the "pos" attribute to an Atlas::Bridge.
Multi-type container.
Definition: Element.h:60
RootEntityData(RootEntityData *defaults=nullptr)
Construct a RootEntityData class definition.
Definition: RootEntity.h:35
std::vector< double > & modifyVelocity()
Retrieve the "velocity" attribute as a non-const reference.
Definition: RootEntity.h:299
const std::vector< double > & getVelocity() const
Retrieve the "velocity" attribute.
Definition: RootEntity.h:291
void reset() override
Resets the object as it&#39;s returned to the pool.
The Atlas namespace.
Definition: Bridge.h:20
All objects inherit from this.
Definition: Root.h:36
const Atlas::Message::ListType getVelocityAsList() const
Retrieve the "velocity" attribute AsList.
Definition: RootEntity.h:306
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
int32_t getAttrFlag(const std::string &name) const override
Find the flag for the attribute "name".
const std::list< std::string > & getContains() const
Retrieve the "contains" attribute.
Definition: RootEntity.h:316
void setContainsAsList(const Atlas::Message::ListType &val)
Set the "contains" attribute AsList.
Definition: RootEntity.h:232
void setPos(const std::vector< double > &val)
Set the "pos" attribute.
Definition: RootEntity.h:188
bool instanceOf(int classNo) const override
Is this instance of some class?
void sendStampContains(Atlas::Bridge &) const
Send the "stamp_contains" attribute to an Atlas::Bridge.
double & modifyStampContains()
Retrieve the "stamp_contains" attribute as a non-const reference.
Definition: RootEntity.h:349
std::vector< double > attr_velocity
Velocity object is moving, usually world is 3D.
Definition: RootEntity.h:130
void setPosAsList(const Atlas::Message::ListType &val)
Set the "pos" attribute AsList.
Definition: RootEntity.h:194
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
std::string & modifyLoc()
Retrieve the "loc" attribute as a non-const reference.
Definition: RootEntity.h:259
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
std::list< std::string > & modifyContains()
Retrieve the "contains" attribute as a non-const reference.
Definition: RootEntity.h:324
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:132
void setContains(const std::list< std::string > &val)
Set the "contains" attribute.
Definition: RootEntity.h:226
Starting point for entity hierarchy.
Definition: RootEntity.h:31
void sendContains(Atlas::Bridge &) const
Send the "contains" attribute to an Atlas::Bridge.
std::string attr_loc
Reference object for coordinates (location).
Definition: RootEntity.h:126
void setLoc(const std::string &val)
Set the "loc" attribute.
Definition: RootEntity.h:180
Trait which handles allocation of instances of BaseObject.
Definition: BaseObject.h:63
void setStampContains(double val)
Set the "stamp_contains" attribute.
Definition: RootEntity.h:245
const std::string & getLoc() const
Retrieve the "loc" attribute.
Definition: RootEntity.h:251
void sendVelocity(Atlas::Bridge &) const
Send the "velocity" attribute to an Atlas::Bridge.
RootEntityData * copy() const override
Copy this object.
~RootEntityData() override=default
Default destructor.
bool isDefaultVelocity() const
Is "velocity" value default?
Definition: RootEntity.h:366
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
void sendLoc(Atlas::Bridge &) const
Send the "loc" attribute to an Atlas::Bridge.
double getStampContains() const
Retrieve the "stamp_contains" attribute.
Definition: RootEntity.h:341
void setVelocity(const std::vector< double > &val)
Set the "velocity" attribute.
Definition: RootEntity.h:207
void setAttr(const std::string &name, const Atlas::Message::Element &attr) override
Set the attribute "name" to the value given by"attr".

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.