Atlas
0.7.0
Networking protocol for the Worldforge system.
|
8 #ifndef ATLAS_OBJECTS_ROOT_H
9 #define ATLAS_OBJECTS_ROOT_H
11 #include <Atlas/Objects/BaseObject.h>
13 #include <Atlas/Message/Element.h>
15 namespace Atlas {
namespace Objects {
17 template <
class T>
class SmartPtr;
27 typedef SmartPtr<RootData> Root;
29 static const int ROOT_NO = 1;
50 static constexpr
const char* default_parent =
"root";
52 static constexpr
const char* default_objtype =
"obj";
66 void removeAttr(
const std::string& name)
override;
72 void addToMessage(Atlas::Message::MapType &)
const override;
75 void setId(std::string val);
86 const std::string&
getId()
const;
102 const std::string&
getName()
const;
119 int getAttrClass(
const std::string& name)
const override;
121 bool getAttrFlag(
const std::string& name, uint32_t& flag)
const override;
146 friend class ::Atlas::Objects::Allocator;
151 void reset()
override;
152 void free()
override;
156 static void fillDefaultObjectInstance(
RootData& data, std::map<std::string, uint32_t>& attr_data);
163 extern const std::string ID_ATTR;
164 extern const std::string PARENT_ATTR;
165 extern const std::string STAMP_ATTR;
166 extern const std::string OBJTYPE_ATTR;
167 extern const std::string NAME_ATTR;
173 const uint32_t ID_FLAG = 1u << 1u;
178 m_attrFlags |= ID_FLAG;
181 const uint32_t PARENT_FLAG = 1u << 2u;
186 m_attrFlags |= PARENT_FLAG;
189 const uint32_t STAMP_FLAG = 1u << 3u;
194 m_attrFlags |= STAMP_FLAG;
197 const uint32_t OBJTYPE_FLAG = 1u << 4u;
202 m_attrFlags |= OBJTYPE_FLAG;
205 const uint32_t NAME_FLAG = 1u << 5u;
210 m_attrFlags |= NAME_FLAG;
215 if(m_attrFlags & ID_FLAG)
223 if(!(m_attrFlags & ID_FLAG))
230 if(m_attrFlags & PARENT_FLAG)
238 if(!(m_attrFlags & PARENT_FLAG))
245 if(m_attrFlags & STAMP_FLAG)
253 if(!(m_attrFlags & STAMP_FLAG))
260 if(m_attrFlags & OBJTYPE_FLAG)
268 if(!(m_attrFlags & OBJTYPE_FLAG))
275 if(m_attrFlags & NAME_FLAG)
283 if(!(m_attrFlags & NAME_FLAG))
290 return (m_attrFlags & ID_FLAG) == 0;
295 return (m_attrFlags & PARENT_FLAG) == 0;
300 return (m_attrFlags & STAMP_FLAG) == 0;
305 return (m_attrFlags & OBJTYPE_FLAG) == 0;
310 return (m_attrFlags & NAME_FLAG) == 0;
316 #endif // ATLAS_OBJECTS_ROOT_H
void setObjtype(std::string val)
Set the "objtype" attribute.
void sendId(Atlas::Bridge &) const
Send the "id" attribute to an Atlas::Bridge.
bool isDefaultObjtype() const
Is "objtype" value default?
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
bool isDefaultStamp() const
Is "stamp" value default?
void setName(std::string val)
Set the "name" attribute.
double attr_stamp
Last time this object was modified.
void setId(std::string val)
Set the "id" attribute.
bool isDefaultParent() const
Is "parent" value default?
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
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".
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
std::string & modifyParent()
Retrieve the "parent" attribute as a non-const reference.
std::string & modifyObjtype()
Retrieve the "objtype" attribute as a non-const reference.
std::string attr_parent
The object this inherits attributes from.
void sendParent(Atlas::Bridge &) const
Send the "parent" attribute to an Atlas::Bridge.
std::string & modifyName()
Retrieve the "name" attribute as a non-const reference.
void free() override
Free an instance of this class, returning it to the memory pool.
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
bool instanceOf(int classNo) const override
Is this instance of some class?
void reset() override
Resets the object as it's returned to the pool.
void setParent(std::string val)
Set the "parent" attribute.
bool isDefaultId() const
Is "id" value default?
BaseObjectData * m_defaults
const std::string & getObjtype() const
Retrieve the "objtype" attribute.
void sendObjtype(Atlas::Bridge &) const
Send the "objtype" attribute to an Atlas::Bridge.
const std::string & getParent() const
Retrieve the "parent" attribute.
void setStamp(double val)
Set the "stamp" attribute.
std::string attr_name
Name of object.
RootData * copy() const override
Copy this object.
const std::string & getId() const
Retrieve the "id" attribute.
double getStamp() const
Retrieve the "stamp" attribute.
void sendName(Atlas::Bridge &) const
Send the "name" attribute to an Atlas::Bridge.
RootData(RootData *defaults=nullptr)
Construct a RootData class definition.
std::string attr_objtype
What kind of object this is.
~RootData() override=default
Default destructor.
std::string & modifyId()
Retrieve the "id" attribute as a non-const reference.
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
All objects inherit from this..
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
bool isDefaultName() const
Is "name" value default?
double & modifyStamp()
Retrieve the "stamp" attribute as a non-const reference.
void sendStamp(Atlas::Bridge &) const
Send the "stamp" attribute to an Atlas::Bridge.
const std::string & getName() const
Retrieve the "name" attribute.
std::string attr_id
Id of object.