Atlas
0.7.0
Networking protocol for the Worldforge system.
|
8 #ifndef ATLAS_OBJECTS_ENTITY_ROOTENTITY_H
9 #define ATLAS_OBJECTS_ENTITY_ROOTENTITY_H
11 #include <Atlas/Objects/Root.h>
12 #include <Atlas/Objects/SmartPtr.h>
14 namespace Atlas {
namespace Objects {
namespace Entity {
23 typedef SmartPtr<RootEntityData> RootEntity;
25 static const int ROOT_ENTITY_NO = 2;
38 m_class_no = ROOT_ENTITY_NO;
45 static constexpr
const char* super_parent =
"root";
47 static constexpr
const char* default_parent =
"root_entity";
49 static constexpr
const char* default_objtype =
"obj";
63 void removeAttr(
const std::string& name)
override;
69 void addToMessage(Atlas::Message::MapType &)
const override;
72 void setLoc(std::string val);
74 void setPos(std::vector<double> val);
89 const std::string&
getLoc()
const;
93 const std::vector<double>&
getPos()
const;
105 const std::vector<std::string>&
getContains()
const;
128 int getAttrClass(
const std::string& name)
const override;
130 bool getAttrFlag(
const std::string& name, uint32_t& flag)
const override;
155 friend class ::Atlas::Objects::Allocator;
160 void reset()
override;
161 void free()
override;
165 static void fillDefaultObjectInstance(
RootEntityData& data, std::map<std::string, uint32_t>& attr_data);
172 extern const std::string LOC_ATTR;
173 extern const std::string POS_ATTR;
174 extern const std::string VELOCITY_ATTR;
175 extern const std::string CONTAINS_ATTR;
176 extern const std::string STAMP_CONTAINS_ATTR;
182 const uint32_t LOC_FLAG = 1u << 6u;
187 m_attrFlags |= LOC_FLAG;
190 const uint32_t POS_FLAG = 1u << 7u;
195 m_attrFlags |= POS_FLAG;
200 m_attrFlags |= POS_FLAG;
202 for (
const auto& entry : val) {
209 const uint32_t VELOCITY_FLAG = 1u << 8u;
214 m_attrFlags |= VELOCITY_FLAG;
219 m_attrFlags |= VELOCITY_FLAG;
221 for (
const auto& entry : val) {
228 const uint32_t CONTAINS_FLAG = 1u << 9u;
233 m_attrFlags |= CONTAINS_FLAG;
238 m_attrFlags |= CONTAINS_FLAG;
240 for (
const auto& entry : val) {
241 if(entry.isString()) {
247 const uint32_t STAMP_CONTAINS_FLAG = 1u << 10u;
252 m_attrFlags |= STAMP_CONTAINS_FLAG;
257 if(m_attrFlags & LOC_FLAG)
265 if(!(m_attrFlags & LOC_FLAG))
272 if(m_attrFlags & POS_FLAG)
280 if(!(m_attrFlags & POS_FLAG))
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);
297 if(m_attrFlags & VELOCITY_FLAG)
305 if(!(m_attrFlags & VELOCITY_FLAG))
313 Atlas::Message::ListType lst_out;
314 for (
const auto& entry : lst_in) {
315 lst_out.push_back(entry);
322 if(m_attrFlags & CONTAINS_FLAG)
330 if(!(m_attrFlags & CONTAINS_FLAG))
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));
347 if(m_attrFlags & STAMP_CONTAINS_FLAG)
355 if(!(m_attrFlags & STAMP_CONTAINS_FLAG))
362 return (m_attrFlags & LOC_FLAG) == 0;
367 return (m_attrFlags & POS_FLAG) == 0;
372 return (m_attrFlags & VELOCITY_FLAG) == 0;
377 return (m_attrFlags & CONTAINS_FLAG) == 0;
382 return (m_attrFlags & STAMP_CONTAINS_FLAG) == 0;
388 #endif // ATLAS_OBJECTS_ENTITY_ROOTENTITY_H
Starting point for entity hierarchy.
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
bool isDefaultVelocity() const
Is "velocity" value default?
bool instanceOf(int classNo) const override
Is this instance of some class?
std::vector< double > & modifyPos()
Retrieve the "pos" attribute as a non-const reference.
RootEntityData(RootEntityData *defaults=nullptr)
Construct a RootEntityData class definition.
bool isDefaultStampContains() const
Is "stamp_contains" value default?
const std::string & getLoc() const
Retrieve the "loc" attribute.
~RootEntityData() override=default
Default destructor.
void setPosAsList(const Atlas::Message::ListType &val)
Set the "pos" attribute AsList.
std::vector< std::string > attr_contains
List of objects that use this object as reference system (usually same as what this object contains).
bool isDefaultContains() const
Is "contains" value default?
void setContains(std::vector< std::string > val)
Set the "contains" attribute.
void setLoc(std::string val)
Set the "loc" attribute.
const std::vector< double > & getVelocity() const
Retrieve the "velocity" attribute.
RootEntityData * copy() const override
Copy this object.
void sendContains(Atlas::Bridge &) const
Send the "contains" attribute to an Atlas::Bridge.
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
double & modifyStampContains()
Retrieve the "stamp_contains" attribute as a non-const reference.
void setContainsAsList(const Atlas::Message::ListType &val)
Set the "contains" attribute AsList.
double getStampContains() const
Retrieve the "stamp_contains" attribute.
double attr_stamp_contains
Last time any object that uses this as reference recursively has been modified.
Atlas::Message::ListType getVelocityAsList() const
Retrieve the "velocity" attribute AsList.
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
void sendStampContains(Atlas::Bridge &) const
Send the "stamp_contains" attribute to an Atlas::Bridge.
std::vector< double > & modifyVelocity()
Retrieve the "velocity" attribute as a non-const reference.
std::vector< std::string > & modifyContains()
Retrieve the "contains" attribute as a non-const reference.
std::vector< double > attr_pos
Position coordinates, usually world is 3D.
void sendLoc(Atlas::Bridge &) const
Send the "loc" attribute to an Atlas::Bridge.
void setVelocity(std::vector< double > val)
Set the "velocity" attribute.
BaseObjectData * m_defaults
const std::vector< std::string > & getContains() const
Retrieve the "contains" attribute.
std::vector< double > attr_velocity
Velocity object is moving, usually world is 3D.
bool isDefaultLoc() const
Is "loc" value default?
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".
void setVelocityAsList(const Atlas::Message::ListType &val)
Set the "velocity" attribute AsList.
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
void setPos(std::vector< double > val)
Set the "pos" attribute.
Atlas::Message::ListType getPosAsList() const
Retrieve the "pos" attribute AsList.
Atlas::Message::ListType getContainsAsList() const
Retrieve the "contains" attribute AsList.
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
void reset() override
Resets the object as it's returned to the pool.
void setStampContains(double val)
Set the "stamp_contains" attribute.
std::string attr_loc
Reference object for coordinates (location).
std::string & modifyLoc()
Retrieve the "loc" attribute as a non-const reference.
void sendVelocity(Atlas::Bridge &) const
Send the "velocity" attribute to an Atlas::Bridge.
const std::vector< double > & getPos() const
Retrieve the "pos" attribute.
All objects inherit from this..
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
void free() override
Free an instance of this class, returning it to the memory pool.
void sendPos(Atlas::Bridge &) const
Send the "pos" attribute to an Atlas::Bridge.
bool isDefaultPos() const
Is "pos" value default?