Atlas
0.7.0
Networking protocol for the Worldforge system.
|
8 #include <Atlas/Objects/RootOperation.h>
11 using Atlas::Message::MapType;
13 namespace Atlas {
namespace Objects {
namespace Operation {
15 const std::string SERIALNO_ATTR =
"serialno";
16 const std::string REFNO_ATTR =
"refno";
17 const std::string FROM_ATTR =
"from";
18 const std::string TO_ATTR =
"to";
19 const std::string SECONDS_ATTR =
"seconds";
20 const std::string FUTURE_SECONDS_ATTR =
"future_seconds";
21 const std::string ARGS_ATTR =
"args";
25 if (allocator.attr_flags_Data.find(name) != allocator.attr_flags_Data.end()) {
26 return ROOT_OPERATION_NO;
33 auto I = allocator.attr_flags_Data.find(name);
34 if (I != allocator.attr_flags_Data.end()) {
43 if (name == SERIALNO_ATTR) { attr =
getSerialno();
return 0; }
44 if (name == REFNO_ATTR) { attr =
getRefno();
return 0; }
45 if (name == FROM_ATTR) { attr =
getFrom();
return 0; }
46 if (name == TO_ATTR) { attr =
getTo();
return 0; }
47 if (name == SECONDS_ATTR) { attr =
getSeconds();
return 0; }
67 if (name == SERIALNO_ATTR)
68 { m_attrFlags &= ~SERIALNO_FLAG;
return;}
69 if (name == REFNO_ATTR)
70 { m_attrFlags &= ~REFNO_FLAG;
return;}
71 if (name == FROM_ATTR)
72 { m_attrFlags &= ~FROM_FLAG;
return;}
74 { m_attrFlags &= ~TO_FLAG;
return;}
75 if (name == SECONDS_ATTR)
76 { m_attrFlags &= ~SECONDS_FLAG;
return;}
77 if (name == FUTURE_SECONDS_ATTR)
78 { m_attrFlags &= ~FUTURE_SECONDS_FLAG;
return;}
79 if (name == ARGS_ATTR)
80 { m_attrFlags &= ~ARGS_FLAG;
return;}
86 if(m_attrFlags & SERIALNO_FLAG) {
93 if(m_attrFlags & REFNO_FLAG) {
100 if(m_attrFlags & FROM_FLAG) {
107 if(m_attrFlags & TO_FLAG) {
108 b.mapStringItem(TO_ATTR,
attr_to);
114 if(m_attrFlags & SECONDS_FLAG) {
121 if(m_attrFlags & FUTURE_SECONDS_FLAG) {
128 if(m_attrFlags & ARGS_FLAG) {
129 b.mapListItem(ARGS_ATTR);
132 item->sendContents(b);
154 if(m_attrFlags & SERIALNO_FLAG)
156 if(m_attrFlags & REFNO_FLAG)
158 if(m_attrFlags & FROM_FLAG)
160 if(m_attrFlags & TO_FLAG)
162 if(m_attrFlags & SECONDS_FLAG)
164 if(m_attrFlags & FUTURE_SECONDS_FLAG)
166 if(m_attrFlags & ARGS_FLAG)
176 allocator.free(
this);
189 return copyInstance<RootOperationData>(*
this);
194 if(ROOT_OPERATION_NO == classNo)
return true;
198 void RootOperationData::fillDefaultObjectInstance(
RootOperationData& data, std::map<std::string, uint32_t>& attr_data)
207 attr_data[SERIALNO_ATTR] = SERIALNO_FLAG;
208 attr_data[REFNO_ATTR] = REFNO_FLAG;
209 attr_data[FROM_ATTR] = FROM_FLAG;
210 attr_data[TO_ATTR] = TO_FLAG;
211 attr_data[SECONDS_ATTR] = SECONDS_FLAG;
212 attr_data[FUTURE_SECONDS_ATTR] = FUTURE_SECONDS_FLAG;
213 attr_data[ARGS_ATTR] = ARGS_FLAG;
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
std::int64_t getRefno() const
Retrieve the "refno" attribute.
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
const std::string & getTo() const
Retrieve the "to" attribute.
const std::string & getFrom() const
Retrieve the "from" attribute.
double attr_stamp
Last time this object was modified.
double attr_seconds
Time in seconds.
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
std::int64_t attr_serialno
Serial number.
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::vector< Root > attr_args
List of arguments this operation has.
StringType && moveString()
void setArgsAsList(const Atlas::Message::ListType &val, const Atlas::Objects::Factories *factories)
Set the "args" attribute AsList.
std::string attr_to
Target of message/operation.
std::string attr_parent
The object this inherits attributes from.
void sendFrom(Atlas::Bridge &) const
Send the "from" attribute to an Atlas::Bridge.
void sendFutureSeconds(Atlas::Bridge &) const
Send the "future_seconds" attribute to an Atlas::Bridge.
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
IntType asInt() const
Retrieve the current value as a int.
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
void free() override
Free an instance of this class, returning it to the memory pool.
void sendArgs(Atlas::Bridge &) const
Send the "args" attribute to an Atlas::Bridge.
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 setFutureSeconds(double val)
Set the "future_seconds" attribute.
std::int64_t attr_refno
Reference to serial number.
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 reset() override
Resets the object as it's returned to the pool.
void setSeconds(double val)
Set the "seconds" attribute.
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
std::int64_t getSerialno() const
Retrieve the "serialno" attribute.
double attr_future_seconds
Time in seconds to add current time.
std::string attr_from
Source of message/operation.
void setTo(std::string val)
Set the "to" attribute.
void setSerialno(std::int64_t val)
Set the "serialno" attribute.
void sendSeconds(Atlas::Bridge &) const
Send the "seconds" attribute to an Atlas::Bridge.
void setRefno(std::int64_t val)
Set the "refno" attribute.
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
double getSeconds() const
Retrieve the "seconds" attribute.
RootOperationData * copy() const override
Copy this object.
void setFrom(std::string val)
Set the "from" attribute.
FloatType asFloat() const
Retrieve the current value as a double.
bool instanceOf(int classNo) const override
Is this instance of some class?
void sendSerialno(Atlas::Bridge &) const
Send the "serialno" attribute to an Atlas::Bridge.
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.
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.
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
void sendTo(Atlas::Bridge &) const
Send the "to" attribute to an Atlas::Bridge.
void sendRefno(Atlas::Bridge &) const
Send the "refno" attribute to an Atlas::Bridge.
double getFutureSeconds() const
Retrieve the "future_seconds" attribute.
Base operation for all operators.
Atlas::Message::ListType getArgsAsList() const
Retrieve the "args" attribute AsList.