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;
54 void setAttr(
const std::string& name,
57 void removeAttr(
const std::string& name)
override;
63 void addToMessage(Atlas::Message::MapType &)
const override;
66 void setLoc(
const std::string& val);
68 void setPos(
const std::vector<double>& val);
76 void setContains(
const std::list<std::string>& val);
83 const std::string&
getLoc()
const;
87 const std::vector<double>&
getPos()
const;
122 int getAttrClass(
const std::string& name)
const override;
124 int32_t
getAttrFlag(
const std::string& name)
const override;
147 void iterate(
int& current_class, std::string& attr)
const override;
151 friend class ::Atlas::Objects::Allocator;
156 void reset()
override;
157 void free()
override;
161 static void fillDefaultObjectInstance(
RootEntityData& data, std::map<std::string, int32_t>& attr_data);
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;
178 const int32_t LOC_FLAG = 1 << 6;
183 m_attrFlags |= LOC_FLAG;
186 const int32_t POS_FLAG = 1 << 7;
191 m_attrFlags |= POS_FLAG;
196 m_attrFlags |= POS_FLAG;
198 for (
const auto& entry : val) {
205 const int32_t VELOCITY_FLAG = 1 << 8;
210 m_attrFlags |= VELOCITY_FLAG;
215 m_attrFlags |= VELOCITY_FLAG;
217 for (
const auto& entry : val) {
224 const int32_t CONTAINS_FLAG = 1 << 9;
229 m_attrFlags |= CONTAINS_FLAG;
234 m_attrFlags |= CONTAINS_FLAG;
236 for (
const auto& entry : val) {
237 if(entry.isString()) {
243 const int32_t STAMP_CONTAINS_FLAG = 1 << 10;
248 m_attrFlags |= STAMP_CONTAINS_FLAG;
253 if(m_attrFlags & LOC_FLAG)
261 if(!(m_attrFlags & LOC_FLAG))
268 if(m_attrFlags & POS_FLAG)
276 if(!(m_attrFlags & POS_FLAG))
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);
293 if(m_attrFlags & VELOCITY_FLAG)
301 if(!(m_attrFlags & VELOCITY_FLAG))
309 Atlas::Message::ListType lst_out;
310 for (
const auto& entry : lst_in) {
311 lst_out.push_back(entry);
318 if(m_attrFlags & CONTAINS_FLAG)
326 if(!(m_attrFlags & CONTAINS_FLAG))
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));
343 if(m_attrFlags & STAMP_CONTAINS_FLAG)
351 if(!(m_attrFlags & STAMP_CONTAINS_FLAG))
358 return (m_attrFlags & LOC_FLAG) == 0;
363 return (m_attrFlags & POS_FLAG) == 0;
368 return (m_attrFlags & VELOCITY_FLAG) == 0;
373 return (m_attrFlags & CONTAINS_FLAG) == 0;
378 return (m_attrFlags & STAMP_CONTAINS_FLAG) == 0;
384 #endif // ATLAS_OBJECTS_ENTITY_ROOTENTITY_H const Atlas::Message::ListType getContainsAsList() const
Retrieve the "contains" attribute AsList.
Definition: RootEntity.h:331
std::vector< double > & modifyPos()
Retrieve the "pos" attribute as a non-const reference.
Definition: RootEntity.h:274
const std::list< std::string > & getContains() const
Retrieve the "contains" attribute.
Definition: RootEntity.h:316
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".
const std::vector< double > & getVelocity() const
Retrieve the "velocity" attribute.
Definition: RootEntity.h:291
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 ¤t_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 getPosAsList() const
Retrieve the "pos" attribute AsList.
Definition: RootEntity.h:281
bool isDefaultVelocity() const
Is "velocity" value default?
Definition: RootEntity.h:366
void sendStampContains(Atlas::Bridge &) const
Send the "stamp_contains" attribute to an Atlas::Bridge.
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
double attr_stamp_contains
Last time any object that uses this as reference recursively has been modified.
Definition: RootEntity.h:134
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
void reset() override
Resets the object as it's returned to the pool.
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:36
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".
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
const Atlas::Message::ListType getVelocityAsList() const
Retrieve the "velocity" attribute AsList.
Definition: RootEntity.h:306
bool isDefaultPos() const
Is "pos" value default?
Definition: RootEntity.h:361
bool instanceOf(int classNo) const override
Is this instance of some class?
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
double getStampContains() const
Retrieve the "stamp_contains" attribute.
Definition: RootEntity.h:341
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
bool isDefaultStampContains() const
Is "stamp_contains" value default?
Definition: RootEntity.h:376
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
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
RootEntityData * copy() const override
Copy this object.
void sendLoc(Atlas::Bridge &) const
Send the "loc" attribute to an Atlas::Bridge.
~RootEntityData() override=default
Default destructor.
void sendVelocity(Atlas::Bridge &) const
Send the "velocity" attribute to an Atlas::Bridge.
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
void setVelocity(const std::vector< double > &val)
Set the "velocity" attribute.
Definition: RootEntity.h:207
const std::vector< double > & getPos() const
Retrieve the "pos" attribute.
Definition: RootEntity.h:266
bool isDefaultContains() const
Is "contains" value default?
Definition: RootEntity.h:371
void setAttr(const std::string &name, const Atlas::Message::Element &attr) override
Set the attribute "name" to the value given by"attr".