Atlas 0.7.0
Networking protocol for the Worldforge system.
RootOperation.cpp
1// This file may be redistributed and modified only under the terms of
2// the GNU Lesser General Public License (See COPYING for details).
3// Copyright 2000-2001 Stefanus Du Toit and Aloril.
4// Copyright 2001-2005 Alistair Riddoch.
5// Copyright 2011-2020 Erik Ogenvik.
6// Automatically generated using gen_cpp.py. Don't edit directly.
7
8#include <Atlas/Objects/RootOperation.h>
9
11using Atlas::Message::MapType;
12
13namespace Atlas { namespace Objects { namespace Operation {
14
15const std::string SERIALNO_ATTR = "serialno";
16const std::string REFNO_ATTR = "refno";
17const std::string FROM_ATTR = "from";
18const std::string TO_ATTR = "to";
19const std::string SECONDS_ATTR = "seconds";
20const std::string FUTURE_SECONDS_ATTR = "future_seconds";
21const std::string ARGS_ATTR = "args";
22
23int RootOperationData::getAttrClass(const std::string& name) const
24{
25 if (allocator.attr_flags_Data.find(name) != allocator.attr_flags_Data.end()) {
26 return ROOT_OPERATION_NO;
27 }
28 return RootData::getAttrClass(name);
29}
30
31bool RootOperationData::getAttrFlag(const std::string& name, uint32_t& flag) const
32{
33 auto I = allocator.attr_flags_Data.find(name);
34 if (I != allocator.attr_flags_Data.end()) {
35 flag = I->second;
36 return true;
37 }
38 return RootData::getAttrFlag(name, flag);
39}
40
41int RootOperationData::copyAttr(const std::string& name, Element & attr) const
42{
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; }
48 if (name == FUTURE_SECONDS_ATTR) { attr = getFutureSeconds(); return 0; }
49 if (name == ARGS_ATTR) { attr = getArgsAsList(); return 0; }
50 return RootData::copyAttr(name, attr);
51}
52
53void RootOperationData::setAttr(std::string name, Element attr, const Atlas::Objects::Factories* factories)
54{
55 if (name == SERIALNO_ATTR) { setSerialno(attr.asInt()); return; }
56 if (name == REFNO_ATTR) { setRefno(attr.asInt()); return; }
57 if (name == FROM_ATTR) { setFrom(attr.moveString()); return; }
58 if (name == TO_ATTR) { setTo(attr.moveString()); return; }
59 if (name == SECONDS_ATTR) { setSeconds(attr.asFloat()); return; }
60 if (name == FUTURE_SECONDS_ATTR) { setFutureSeconds(attr.asFloat()); return; }
61 if (name == ARGS_ATTR) { setArgsAsList(attr.moveList(), factories); return; }
62 RootData::setAttr(std::move(name), std::move(attr), factories);
63}
64
65void RootOperationData::removeAttr(const std::string& name)
66{
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;}
73 if (name == TO_ATTR)
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;}
82}
83
85{
86 if(m_attrFlags & SERIALNO_FLAG) {
87 b.mapIntItem(SERIALNO_ATTR, attr_serialno);
88 }
89}
90
92{
93 if(m_attrFlags & REFNO_FLAG) {
94 b.mapIntItem(REFNO_ATTR, attr_refno);
95 }
96}
97
99{
100 if(m_attrFlags & FROM_FLAG) {
101 b.mapStringItem(FROM_ATTR, attr_from);
102 }
103}
104
106{
107 if(m_attrFlags & TO_FLAG) {
108 b.mapStringItem(TO_ATTR, attr_to);
109 }
110}
111
113{
114 if(m_attrFlags & SECONDS_FLAG) {
115 b.mapFloatItem(SECONDS_ATTR, attr_seconds);
116 }
117}
118
120{
121 if(m_attrFlags & FUTURE_SECONDS_FLAG) {
122 b.mapFloatItem(FUTURE_SECONDS_ATTR, attr_future_seconds);
123 }
124}
125
127{
128 if(m_attrFlags & ARGS_FLAG) {
129 b.mapListItem(ARGS_ATTR);
130 for(const auto& item : attr_args) {
131 b.listMapItem();
132 item->sendContents(b);
133 b.mapEnd();
134 }
135 b.listEnd();
136 }
137}
138
140{
141 sendSerialno(b);
142 sendRefno(b);
143 sendFrom(b);
144 sendTo(b);
145 sendSeconds(b);
147 sendArgs(b);
149}
150
151void RootOperationData::addToMessage(MapType & m) const
152{
154 if(m_attrFlags & SERIALNO_FLAG)
155 m[SERIALNO_ATTR] = attr_serialno;
156 if(m_attrFlags & REFNO_FLAG)
157 m[REFNO_ATTR] = attr_refno;
158 if(m_attrFlags & FROM_FLAG)
159 m[FROM_ATTR] = attr_from;
160 if(m_attrFlags & TO_FLAG)
161 m[TO_ATTR] = attr_to;
162 if(m_attrFlags & SECONDS_FLAG)
163 m[SECONDS_ATTR] = attr_seconds;
164 if(m_attrFlags & FUTURE_SECONDS_FLAG)
165 m[FUTURE_SECONDS_ATTR] = attr_future_seconds;
166 if(m_attrFlags & ARGS_FLAG)
167 m[ARGS_ATTR] = getArgsAsList();
168}
169
170Allocator<RootOperationData> RootOperationData::allocator;
171
172
173
175{
176 allocator.free(this);
177}
178
179
180
182{
183 attr_args.clear();
185}
186
188{
189 return copyInstance<RootOperationData>(*this);
190}
191
192bool RootOperationData::instanceOf(int classNo) const
193{
194 if(ROOT_OPERATION_NO == classNo) return true;
195 return RootData::instanceOf(classNo);
196}
197
198void RootOperationData::fillDefaultObjectInstance(RootOperationData& data, std::map<std::string, uint32_t>& attr_data)
199{
200 data.attr_objtype = default_objtype;
201 data.attr_serialno = 0;
202 data.attr_refno = 0;
203 data.attr_seconds = 0.0;
204 data.attr_future_seconds = 0.0;
205 data.attr_stamp = 0.0;
206 data.attr_parent = default_parent;
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;
214}
215
216} } } // namespace Atlas::Objects::Operation
StringType && moveString()
Definition: Element.h:467
FloatType asFloat() const
Retrieve the current value as a double.
Definition: Element.h:414
ListType && moveList()
Definition: Element.h:533
IntType asInt() const
Retrieve the current value as a int.
Definition: Element.h:404
Base operation for all operators.
Definition: RootOperation.h:42
void setFrom(std::string val)
Set the "from" attribute.
void setTo(std::string val)
Set the "to" attribute.
std::string attr_from
Source of message/operation.
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
bool instanceOf(int classNo) const override
Is this instance of some class?
const std::string & getFrom() const
Retrieve the "from" attribute.
std::vector< Root > attr_args
List of arguments this operation has.
void sendFutureSeconds(Atlas::Bridge &) const
Send the "future_seconds" attribute to an Atlas::Bridge.
std::int64_t getRefno() const
Retrieve the "refno" attribute.
void sendTo(Atlas::Bridge &) const
Send the "to" attribute to an Atlas::Bridge.
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
double getSeconds() const
Retrieve the "seconds" attribute.
const std::string & getTo() const
Retrieve the "to" attribute.
void setSerialno(std::int64_t val)
Set the "serialno" attribute.
Atlas::Message::ListType getArgsAsList() const
Retrieve the "args" attribute AsList.
double attr_future_seconds
Time in seconds to add current time.
void free() override
Free an instance of this class, returning it to the memory pool.
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
void sendFrom(Atlas::Bridge &) const
Send the "from" attribute to an Atlas::Bridge.
RootOperationData * copy() const override
Copy this object.
void setSeconds(double val)
Set the "seconds" attribute.
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.
void sendSerialno(Atlas::Bridge &) const
Send the "serialno" attribute to an Atlas::Bridge.
void setFutureSeconds(double val)
Set the "future_seconds" attribute.
void sendRefno(Atlas::Bridge &) const
Send the "refno" attribute to an Atlas::Bridge.
void reset() override
Resets the object as it's returned to the pool.
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
double getFutureSeconds() const
Retrieve 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".
std::string attr_to
Target of message/operation.
void setArgsAsList(const Atlas::Message::ListType &val, const Atlas::Objects::Factories *factories)
Set the "args" attribute AsList.
std::int64_t getSerialno() const
Retrieve the "serialno" attribute.
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
void sendArgs(Atlas::Bridge &) const
Send the "args" attribute to an Atlas::Bridge.
std::int64_t attr_serialno
Serial number.
void sendSeconds(Atlas::Bridge &) const
Send the "seconds" attribute to an Atlas::Bridge.
std::string attr_objtype
What kind of object this is.
Definition: Root.h:129
void reset() override
Resets the object as it's returned to the pool.
Definition: Root.cpp:147
std::string attr_parent
The object this inherits attributes from.
Definition: Root.h:125
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
Definition: Root.cpp:39
double attr_stamp
Last time this object was modified.
Definition: Root.h:127
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
Definition: Root.cpp:29
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
Definition: Root.cpp:119
bool instanceOf(int classNo) const override
Is this instance of some class?
Definition: Root.cpp:156
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".
Definition: Root.cpp:49
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
Definition: Root.cpp:21
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
Definition: Root.cpp:59
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
Definition: Root.cpp:109
Definition: Bridge.h:20