Atlas 0.7.0
Networking protocol for the Worldforge system.
Root.h
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#ifndef ATLAS_OBJECTS_ROOT_H
9#define ATLAS_OBJECTS_ROOT_H
10
11#include <Atlas/Objects/BaseObject.h>
12
13#include <Atlas/Message/Element.h>
14
15namespace Atlas { namespace Objects {
16
17template <class T> class SmartPtr;
18
26class RootData;
27typedef SmartPtr<RootData> Root;
28
29static const int ROOT_NO = 1;
30
33
37{
38protected:
40 explicit RootData(RootData *defaults = nullptr) :
42 {
43 m_class_no = ROOT_NO;
44 }
46 ~RootData() override = default;
47
48public:
49 // The default parent type for this object
50 static constexpr const char* default_parent = "root";
51 // The default objtype for this object
52 static constexpr const char* default_objtype = "obj";
54 RootData * copy() const override;
55
57 bool instanceOf(int classNo) const override;
58
61 int copyAttr(const std::string& name, Atlas::Message::Element & attr) const override;
63 void setAttr(std::string name,
64 Atlas::Message::Element attr, const Atlas::Objects::Factories* factories = nullptr) override;
66 void removeAttr(const std::string& name) override;
67
69 void sendContents(Atlas::Bridge & b) const override;
70
72 void addToMessage(Atlas::Message::MapType &) const override;
73
75 void setId(std::string val);
77 void setParent(std::string val);
79 void setStamp(double val);
81 void setObjtype(std::string val);
83 void setName(std::string val);
84
86 const std::string& getId() const;
88 std::string& modifyId();
90 const std::string& getParent() const;
92 std::string& modifyParent();
94 double getStamp() const;
96 double& modifyStamp();
98 const std::string& getObjtype() const;
100 std::string& modifyObjtype();
102 const std::string& getName() const;
104 std::string& modifyName();
105
107 bool isDefaultId() const;
109 bool isDefaultParent() const;
111 bool isDefaultStamp() const;
113 bool isDefaultObjtype() const;
115 bool isDefaultName() const;
116
117protected:
119 int getAttrClass(const std::string& name)const override;
121 bool getAttrFlag(const std::string& name, uint32_t& flag)const override;
123 std::string attr_id;
125 std::string attr_parent;
129 std::string attr_objtype;
131 std::string attr_name;
132
134 void sendId(Atlas::Bridge&) const;
136 void sendParent(Atlas::Bridge&) const;
138 void sendStamp(Atlas::Bridge&) const;
140 void sendObjtype(Atlas::Bridge&) const;
142 void sendName(Atlas::Bridge&) const;
143
144public:
145 template <typename>
146 friend class ::Atlas::Objects::Allocator;
147 static Allocator<RootData> allocator;
148
149protected:
151 void reset() override;
152 void free() override;
153
154private:
155
156 static void fillDefaultObjectInstance(RootData& data, std::map<std::string, uint32_t>& attr_data);
157};
158
159//
160// Attribute name strings follow.
161//
162
163extern const std::string ID_ATTR;
164extern const std::string PARENT_ATTR;
165extern const std::string STAMP_ATTR;
166extern const std::string OBJTYPE_ATTR;
167extern const std::string NAME_ATTR;
168
169//
170// Inlined member functions follow.
171//
172
173const uint32_t ID_FLAG = 1u << 1u;
174
175inline void RootData::setId(std::string val)
176{
177 attr_id = std::move(val);
178 m_attrFlags |= ID_FLAG;
179}
180
181const uint32_t PARENT_FLAG = 1u << 2u;
182
183inline void RootData::setParent(std::string val)
184{
185 attr_parent = std::move(val);
186 m_attrFlags |= PARENT_FLAG;
187}
188
189const uint32_t STAMP_FLAG = 1u << 3u;
190
191inline void RootData::setStamp(double val)
192{
193 attr_stamp = val;
194 m_attrFlags |= STAMP_FLAG;
195}
196
197const uint32_t OBJTYPE_FLAG = 1u << 4u;
198
199inline void RootData::setObjtype(std::string val)
200{
201 attr_objtype = std::move(val);
202 m_attrFlags |= OBJTYPE_FLAG;
203}
204
205const uint32_t NAME_FLAG = 1u << 5u;
206
207inline void RootData::setName(std::string val)
208{
209 attr_name = std::move(val);
210 m_attrFlags |= NAME_FLAG;
211}
212
213inline const std::string& RootData::getId() const
214{
215 if(m_attrFlags & ID_FLAG)
216 return attr_id;
217 else
218 return ((RootData*)m_defaults)->attr_id;
219}
220
221inline std::string& RootData::modifyId()
222{
223 if(!(m_attrFlags & ID_FLAG))
225 return attr_id;
226}
227
228inline const std::string& RootData::getParent() const
229{
230 if(m_attrFlags & PARENT_FLAG)
231 return attr_parent;
232 else
233 return ((RootData*)m_defaults)->attr_parent;
234}
235
236inline std::string& RootData::modifyParent()
237{
238 if(!(m_attrFlags & PARENT_FLAG))
240 return attr_parent;
241}
242
243inline double RootData::getStamp() const
244{
245 if(m_attrFlags & STAMP_FLAG)
246 return attr_stamp;
247 else
248 return ((RootData*)m_defaults)->attr_stamp;
249}
250
251inline double& RootData::modifyStamp()
252{
253 if(!(m_attrFlags & STAMP_FLAG))
255 return attr_stamp;
256}
257
258inline const std::string& RootData::getObjtype() const
259{
260 if(m_attrFlags & OBJTYPE_FLAG)
261 return attr_objtype;
262 else
263 return ((RootData*)m_defaults)->attr_objtype;
264}
265
266inline std::string& RootData::modifyObjtype()
267{
268 if(!(m_attrFlags & OBJTYPE_FLAG))
270 return attr_objtype;
271}
272
273inline const std::string& RootData::getName() const
274{
275 if(m_attrFlags & NAME_FLAG)
276 return attr_name;
277 else
278 return ((RootData*)m_defaults)->attr_name;
279}
280
281inline std::string& RootData::modifyName()
282{
283 if(!(m_attrFlags & NAME_FLAG))
285 return attr_name;
286}
287
288inline bool RootData::isDefaultId() const
289{
290 return (m_attrFlags & ID_FLAG) == 0;
291}
292
293inline bool RootData::isDefaultParent() const
294{
295 return (m_attrFlags & PARENT_FLAG) == 0;
296}
297
298inline bool RootData::isDefaultStamp() const
299{
300 return (m_attrFlags & STAMP_FLAG) == 0;
301}
302
303inline bool RootData::isDefaultObjtype() const
304{
305 return (m_attrFlags & OBJTYPE_FLAG) == 0;
306}
307
308inline bool RootData::isDefaultName() const
309{
310 return (m_attrFlags & NAME_FLAG) == 0;
311}
312
313
314} } // namespace Atlas::Objects
315
316#endif // ATLAS_OBJECTS_ROOT_H
BaseObjectData * m_defaults
Definition: BaseObject.h:330
All objects inherit from this..
Definition: Root.h:37
RootData(RootData *defaults=nullptr)
Construct a RootData class definition.
Definition: Root.h:40
const std::string & getId() const
Retrieve the "id" attribute.
Definition: Root.h:213
void sendId(Atlas::Bridge &) const
Send the "id" attribute to an Atlas::Bridge.
Definition: Root.cpp:74
std::string attr_objtype
What kind of object this is.
Definition: Root.h:129
const std::string & getObjtype() const
Retrieve the "objtype" attribute.
Definition: Root.h:258
std::string & modifyObjtype()
Retrieve the "objtype" attribute as a non-const reference.
Definition: Root.h:266
std::string & modifyId()
Retrieve the "id" attribute as a non-const reference.
Definition: Root.h:221
void setObjtype(std::string val)
Set the "objtype" attribute.
Definition: Root.h:199
void setParent(std::string val)
Set the "parent" attribute.
Definition: Root.h:183
bool isDefaultObjtype() const
Is "objtype" value default?
Definition: Root.h:303
void reset() override
Resets the object as it's returned to the pool.
Definition: Root.cpp:147
void setName(std::string val)
Set the "name" attribute.
Definition: Root.h:207
std::string & modifyParent()
Retrieve the "parent" attribute as a non-const reference.
Definition: Root.h:236
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
void sendObjtype(Atlas::Bridge &) const
Send the "objtype" attribute to an Atlas::Bridge.
Definition: Root.cpp:95
double attr_stamp
Last time this object was modified.
Definition: Root.h:127
double getStamp() const
Retrieve the "stamp" attribute.
Definition: Root.h:243
bool isDefaultId() const
Is "id" value default?
Definition: Root.h:288
std::string attr_name
Name of object.
Definition: Root.h:131
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 isDefaultStamp() const
Is "stamp" value default?
Definition: Root.h:298
bool isDefaultName() const
Is "name" value default?
Definition: Root.h:308
std::string attr_id
Id of object.
Definition: Root.h:123
void sendStamp(Atlas::Bridge &) const
Send the "stamp" attribute to an Atlas::Bridge.
Definition: Root.cpp:88
const std::string & getName() const
Retrieve the "name" attribute.
Definition: Root.h:273
bool instanceOf(int classNo) const override
Is this instance of some class?
Definition: Root.cpp:156
~RootData() override=default
Default destructor.
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
void sendParent(Atlas::Bridge &) const
Send the "parent" attribute to an Atlas::Bridge.
Definition: Root.cpp:81
void sendName(Atlas::Bridge &) const
Send the "name" attribute to an Atlas::Bridge.
Definition: Root.cpp:102
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
bool isDefaultParent() const
Is "parent" value default?
Definition: Root.h:293
void free() override
Free an instance of this class, returning it to the memory pool.
Definition: Root.cpp:140
RootData * copy() const override
Copy this object.
Definition: Root.cpp:151
void setId(std::string val)
Set the "id" attribute.
Definition: Root.h:175
const std::string & getParent() const
Retrieve the "parent" attribute.
Definition: Root.h:228
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
Definition: Root.cpp:109
void setStamp(double val)
Set the "stamp" attribute.
Definition: Root.h:191
double & modifyStamp()
Retrieve the "stamp" attribute as a non-const reference.
Definition: Root.h:251
std::string & modifyName()
Retrieve the "name" attribute as a non-const reference.
Definition: Root.h:281
Definition: Bridge.h:20