Atlas-C++
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 Erik Ogenvik.
6 // Automatically generated using gen_cpp.py.
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 
15 namespace Atlas { namespace Objects {
16 
17 template <class T> class SmartPtr;
18 
26 class RootData;
27 typedef SmartPtr<RootData> Root;
28 
29 static const int ROOT_NO = 1;
30 
33 
36 class RootData : public BaseObjectData
37 {
38 protected:
40  RootData(RootData *defaults = nullptr) :
41  BaseObjectData((BaseObjectData*)defaults)
42  {
43  m_class_no = ROOT_NO;
44  }
46  ~RootData() override = default;
47 
48 public:
50  RootData * copy() const override;
51 
53  bool instanceOf(int classNo) const override;
54 
57  int copyAttr(const std::string& name, Atlas::Message::Element & attr) const override;
59  void setAttr(const std::string& name,
60  const Atlas::Message::Element& attr) override;
62  void removeAttr(const std::string& name) override;
63 
65  void sendContents(Atlas::Bridge & b) const override;
66 
68  void addToMessage(Atlas::Message::MapType &) const override;
69 
71  void setId(const std::string& val);
73  void setParent(const std::string& val);
75  void setStamp(double val);
77  void setObjtype(const std::string& val);
79  void setName(const std::string& val);
80 
82  const std::string& getId() const;
84  std::string& modifyId();
86  const std::string& getParent() const;
88  std::string& modifyParent();
90  double getStamp() const;
92  double& modifyStamp();
94  const std::string& getObjtype() const;
96  std::string& modifyObjtype();
98  const std::string& getName() const;
100  std::string& modifyName();
101 
103  bool isDefaultId() const;
105  bool isDefaultParent() const;
107  bool isDefaultStamp() const;
109  bool isDefaultObjtype() const;
111  bool isDefaultName() const;
112 
113 protected:
115  int getAttrClass(const std::string& name)const override;
117  int32_t getAttrFlag(const std::string& name)const override;
119  std::string attr_id;
121  std::string attr_parent;
123  double attr_stamp;
125  std::string attr_objtype;
127  std::string attr_name;
128 
130  void sendId(Atlas::Bridge&) const;
132  void sendParent(Atlas::Bridge&) const;
134  void sendStamp(Atlas::Bridge&) const;
136  void sendObjtype(Atlas::Bridge&) const;
138  void sendName(Atlas::Bridge&) const;
139 
140  void iterate(int& current_class, std::string& attr) const override;
141 
142 public:
143  template <typename>
144  friend class ::Atlas::Objects::Allocator;
145  static Allocator<RootData> allocator;
146 
147 protected:
149  void reset() override;
150  void free() override;
151 
152 private:
153 
154  static void fillDefaultObjectInstance(RootData& data, std::map<std::string, int32_t>& attr_data);
155 };
156 
157 //
158 // Attribute name strings follow.
159 //
160 
161 extern const std::string ID_ATTR;
162 extern const std::string PARENT_ATTR;
163 extern const std::string STAMP_ATTR;
164 extern const std::string OBJTYPE_ATTR;
165 extern const std::string NAME_ATTR;
166 
167 //
168 // Inlined member functions follow.
169 //
170 
171 const int32_t ID_FLAG = 1 << 1;
172 
173 inline void RootData::setId(const std::string& val)
174 {
175  attr_id = val;
176  m_attrFlags |= ID_FLAG;
177 }
178 
179 const int32_t PARENT_FLAG = 1 << 2;
180 
181 inline void RootData::setParent(const std::string& val)
182 {
183  attr_parent = val;
184  m_attrFlags |= PARENT_FLAG;
185 }
186 
187 const int32_t STAMP_FLAG = 1 << 3;
188 
189 inline void RootData::setStamp(double val)
190 {
191  attr_stamp = val;
192  m_attrFlags |= STAMP_FLAG;
193 }
194 
195 const int32_t OBJTYPE_FLAG = 1 << 4;
196 
197 inline void RootData::setObjtype(const std::string& val)
198 {
199  attr_objtype = val;
200  m_attrFlags |= OBJTYPE_FLAG;
201 }
202 
203 const int32_t NAME_FLAG = 1 << 5;
204 
205 inline void RootData::setName(const std::string& val)
206 {
207  attr_name = val;
208  m_attrFlags |= NAME_FLAG;
209 }
210 
211 inline const std::string& RootData::getId() const
212 {
213  if(m_attrFlags & ID_FLAG)
214  return attr_id;
215  else
216  return ((RootData*)m_defaults)->attr_id;
217 }
218 
219 inline std::string& RootData::modifyId()
220 {
221  if(!(m_attrFlags & ID_FLAG))
223  return attr_id;
224 }
225 
226 inline const std::string& RootData::getParent() const
227 {
228  if(m_attrFlags & PARENT_FLAG)
229  return attr_parent;
230  else
231  return ((RootData*)m_defaults)->attr_parent;
232 }
233 
234 inline std::string& RootData::modifyParent()
235 {
236  if(!(m_attrFlags & PARENT_FLAG))
238  return attr_parent;
239 }
240 
241 inline double RootData::getStamp() const
242 {
243  if(m_attrFlags & STAMP_FLAG)
244  return attr_stamp;
245  else
246  return ((RootData*)m_defaults)->attr_stamp;
247 }
248 
249 inline double& RootData::modifyStamp()
250 {
251  if(!(m_attrFlags & STAMP_FLAG))
253  return attr_stamp;
254 }
255 
256 inline const std::string& RootData::getObjtype() const
257 {
258  if(m_attrFlags & OBJTYPE_FLAG)
259  return attr_objtype;
260  else
261  return ((RootData*)m_defaults)->attr_objtype;
262 }
263 
264 inline std::string& RootData::modifyObjtype()
265 {
266  if(!(m_attrFlags & OBJTYPE_FLAG))
268  return attr_objtype;
269 }
270 
271 inline const std::string& RootData::getName() const
272 {
273  if(m_attrFlags & NAME_FLAG)
274  return attr_name;
275  else
276  return ((RootData*)m_defaults)->attr_name;
277 }
278 
279 inline std::string& RootData::modifyName()
280 {
281  if(!(m_attrFlags & NAME_FLAG))
283  return attr_name;
284 }
285 
286 inline bool RootData::isDefaultId() const
287 {
288  return (m_attrFlags & ID_FLAG) == 0;
289 }
290 
291 inline bool RootData::isDefaultParent() const
292 {
293  return (m_attrFlags & PARENT_FLAG) == 0;
294 }
295 
296 inline bool RootData::isDefaultStamp() const
297 {
298  return (m_attrFlags & STAMP_FLAG) == 0;
299 }
300 
301 inline bool RootData::isDefaultObjtype() const
302 {
303  return (m_attrFlags & OBJTYPE_FLAG) == 0;
304 }
305 
306 inline bool RootData::isDefaultName() const
307 {
308  return (m_attrFlags & NAME_FLAG) == 0;
309 }
310 
311 
312 } } // namespace Atlas::Objects
313 
314 #endif // ATLAS_OBJECTS_ROOT_H
bool isDefaultId() const
Is "id" value default?
Definition: Root.h:286
void sendObjtype(Atlas::Bridge &) const
Send the "objtype" attribute to an Atlas::Bridge.
const std::string & getId() const
Retrieve the "id" attribute.
Definition: Root.h:211
void setName(const std::string &val)
Set the "name" attribute.
Definition: Root.h:205
Atlas stream bridge.
Definition: Bridge.h:35
std::string & modifyParent()
Retrieve the "parent" attribute as a non-const reference.
Definition: Root.h:234
~RootData() override=default
Default destructor.
void setStamp(double val)
Set the "stamp" attribute.
Definition: Root.h:189
void sendName(Atlas::Bridge &) const
Send the "name" attribute to an Atlas::Bridge.
void setObjtype(const std::string &val)
Set the "objtype" attribute.
Definition: Root.h:197
BaseObjectData * m_defaults
The default instance, acting as a prototype for all other instances.
Definition: BaseObject.h:440
void sendParent(Atlas::Bridge &) const
Send the "parent" attribute to an Atlas::Bridge.
Multi-type container.
Definition: Element.h:60
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
std::string attr_name
Name of object.
Definition: Root.h:127
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
void sendStamp(Atlas::Bridge &) const
Send the "stamp" attribute to an Atlas::Bridge.
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
The Atlas namespace.
Definition: Bridge.h:20
const std::string & getObjtype() const
Retrieve the "objtype" attribute.
Definition: Root.h:256
std::string & modifyName()
Retrieve the "name" attribute as a non-const reference.
Definition: Root.h:279
All objects inherit from this.
Definition: Root.h:36
void free() override
Free an instance of this class, returning it to the memory pool.
RootData(RootData *defaults=nullptr)
Construct a RootData class definition.
Definition: Root.h:40
std::string & modifyObjtype()
Retrieve the "objtype" attribute as a non-const reference.
Definition: Root.h:264
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
Retrieve the attribute "name".
bool instanceOf(int classNo) const override
Is this instance of some class?
std::string & modifyId()
Retrieve the "id" attribute as a non-const reference.
Definition: Root.h:219
double getStamp() const
Retrieve the "stamp" attribute.
Definition: Root.h:241
void setId(const std::string &val)
Set the "id" attribute.
Definition: Root.h:173
double & modifyStamp()
Retrieve the "stamp" attribute as a non-const reference.
Definition: Root.h:249
int32_t getAttrFlag(const std::string &name) const override
Find the flag for the attribute "name".
const std::string & getName() const
Retrieve the "name" attribute.
Definition: Root.h:271
bool isDefaultObjtype() const
Is "objtype" value default?
Definition: Root.h:301
std::string attr_objtype
What kind of object this is.
Definition: Root.h:125
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
void setParent(const std::string &val)
Set the "parent" attribute.
Definition: Root.h:181
const std::string & getParent() const
Retrieve the "parent" attribute.
Definition: Root.h:226
void setAttr(const std::string &name, const Atlas::Message::Element &attr) override
Set the attribute "name" to the value given by"attr".
Trait which handles allocation of instances of BaseObject.
Definition: BaseObject.h:63
bool isDefaultParent() const
Is "parent" value default?
Definition: Root.h:291
void iterate(int &current_class, std::string &attr) const override
Iterate over the attributes of this instance.
RootData * copy() const override
Copy this object.
bool isDefaultName() const
Is "name" value default?
Definition: Root.h:306
bool isDefaultStamp() const
Is "stamp" value default?
Definition: Root.h:296
double attr_stamp
Last time this object was modified.
Definition: Root.h:123
std::string attr_parent
The object this inherits attributes from.
Definition: Root.h:121
Atlas base object class.
Definition: BaseObject.h:214
void reset() override
Resets the object as it&#39;s returned to the pool.
std::string attr_id
Id of object.
Definition: Root.h:119
void sendId(Atlas::Bridge &) const
Send the "id" attribute to an Atlas::Bridge.

Copyright 2000-2004 the respective authors.

This document can be licensed under the terms of the GNU Free Documentation License or the GNU General Public License and may be freely distributed under the terms given by one of these licenses.