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