Atlas
0.7.0
Networking protocol for the Worldforge system.
|
8 #include <Atlas/Objects/Root.h>
11 using Atlas::Message::MapType;
13 namespace Atlas {
namespace Objects {
15 const std::string ID_ATTR =
"id";
16 const std::string PARENT_ATTR =
"parent";
17 const std::string STAMP_ATTR =
"stamp";
18 const std::string OBJTYPE_ATTR =
"objtype";
19 const std::string NAME_ATTR =
"name";
23 if (allocator.attr_flags_Data.find(name) != allocator.attr_flags_Data.end()) {
31 auto I = allocator.attr_flags_Data.find(name);
32 if (I != allocator.attr_flags_Data.end()) {
41 if (name == ID_ATTR) { attr =
getId();
return 0; }
42 if (name == PARENT_ATTR) { attr =
getParent();
return 0; }
43 if (name == STAMP_ATTR) { attr =
getStamp();
return 0; }
44 if (name == OBJTYPE_ATTR) { attr =
getObjtype();
return 0; }
45 if (name == NAME_ATTR) { attr =
getName();
return 0; }
62 { m_attrFlags &= ~ID_FLAG;
return;}
63 if (name == PARENT_ATTR)
64 { m_attrFlags &= ~PARENT_FLAG;
return;}
65 if (name == STAMP_ATTR)
66 { m_attrFlags &= ~STAMP_FLAG;
return;}
67 if (name == OBJTYPE_ATTR)
68 { m_attrFlags &= ~OBJTYPE_FLAG;
return;}
69 if (name == NAME_ATTR)
70 { m_attrFlags &= ~NAME_FLAG;
return;}
76 if(m_attrFlags & ID_FLAG) {
77 b.mapStringItem(ID_ATTR,
attr_id);
84 b.mapStringItem(PARENT_ATTR,
getParent());
90 if(m_attrFlags & STAMP_FLAG) {
104 if(m_attrFlags & NAME_FLAG) {
122 if(m_attrFlags & ID_FLAG)
124 const std::string& l_attr_parent =
getParent();
125 if (!l_attr_parent.empty())
126 m[PARENT_ATTR] = l_attr_parent;
127 if(m_attrFlags & STAMP_FLAG)
129 const std::string& l_attr_objtype =
getObjtype();
130 if (!l_attr_objtype.empty())
131 m[OBJTYPE_ATTR] = l_attr_objtype;
132 if(m_attrFlags & NAME_FLAG)
142 allocator.free(
this);
153 return copyInstance<RootData>(*
this);
158 if(ROOT_NO == classNo)
return true;
162 void RootData::fillDefaultObjectInstance(
RootData& data, std::map<std::string, uint32_t>& attr_data)
167 attr_data[ID_ATTR] = ID_FLAG;
168 attr_data[PARENT_ATTR] = PARENT_FLAG;
169 attr_data[STAMP_ATTR] = STAMP_FLAG;
170 attr_data[OBJTYPE_ATTR] = OBJTYPE_FLAG;
171 attr_data[NAME_ATTR] = NAME_FLAG;
void setObjtype(std::string val)
Set the "objtype" attribute.
void sendId(Atlas::Bridge &) const
Send the "id" attribute to an Atlas::Bridge.
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
virtual int getAttrClass(const std::string &name) const
Find the class which contains the attribute "name".
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.
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".
StringType && moveString()
std::string attr_parent
The object this inherits attributes from.
void sendParent(Atlas::Bridge &) const
Send the "parent" attribute to an Atlas::Bridge.
virtual void sendContents(Atlas::Bridge &b) const
Send the contents of this object to a Bridge.
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?
virtual bool instanceOf(int classNo) const
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.
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.
virtual bool getAttrFlag(const std::string &name, uint32_t &flag) const
Find the flag for the attribute "name".
void setStamp(double val)
Set the "stamp" attribute.
std::string attr_name
Name of object.
virtual void setAttr(std::string name, Atlas::Message::Element attr, const Atlas::Objects::Factories *factories=nullptr)
Set the attribute "name" to the value given by "attr".
RootData * copy() const override
Copy this object.
const std::string & getId() const
Retrieve the "id" attribute.
FloatType asFloat() const
Retrieve the current value as a double.
double getStamp() const
Retrieve the "stamp" attribute.
void sendName(Atlas::Bridge &) const
Send the "name" attribute to an Atlas::Bridge.
std::string attr_objtype
What kind of object this is.
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.
virtual int copyAttr(const std::string &name, Atlas::Message::Element &attr) const
virtual void removeAttr(const std::string &name)
Remove the attribute "name".
virtual void addToMessage(Atlas::Message::MapType &) const
Write this object to an existing Element.
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.