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 // Automatically generated using gen_cpp.py.
6 
7 #ifndef ATLAS_OBJECTS_ROOT_H
8 #define ATLAS_OBJECTS_ROOT_H
9 
10 #include <Atlas/Objects/BaseObject.h>
11 
12 #include <Atlas/Message/Element.h>
13 
14 namespace Atlas { namespace Objects {
15 
16 template <class T> class SmartPtr;
17 
25 class RootData;
26 typedef SmartPtr<RootData> Root;
27 
28 static const int ROOT_NO = 1;
29 
32 
35 class RootData : public BaseObjectData
36 {
37 protected:
39  RootData(RootData *defaults = NULL) :
40  BaseObjectData((BaseObjectData*)defaults)
41  {
42  m_class_no = ROOT_NO;
43  }
45  virtual ~RootData();
46 
47 public:
49  virtual RootData * copy() const;
50 
52  virtual bool instanceOf(int classNo) const;
53 
56  virtual int copyAttr(const std::string& name, Atlas::Message::Element & attr) const;
58  virtual void setAttr(const std::string& name,
59  const Atlas::Message::Element& attr);
61  virtual void removeAttr(const std::string& name);
62 
64  virtual void sendContents(Atlas::Bridge & b) const;
65 
67  virtual void addToMessage(Atlas::Message::MapType &) const;
68 
70  inline void setId(const std::string& val);
72  inline void setParents(const std::list<std::string>& val);
74  inline void setParentsAsList(const Atlas::Message::ListType& val);
76  inline void setStamp(double val);
78  inline void setObjtype(const std::string& val);
80  inline void setName(const std::string& val);
81 
83  inline const std::string& getId() const;
85  inline std::string& modifyId();
87  inline const std::list<std::string>& getParents() const;
89  inline std::list<std::string>& modifyParents();
91  inline const Atlas::Message::ListType getParentsAsList() const;
93  inline double getStamp() const;
95  inline double& modifyStamp();
97  inline const std::string& getObjtype() const;
99  inline std::string& modifyObjtype();
101  inline const std::string& getName() const;
103  inline std::string& modifyName();
104 
106  inline bool isDefaultId() const;
108  inline bool isDefaultParents() const;
110  inline bool isDefaultStamp() const;
112  inline bool isDefaultObjtype() const;
114  inline bool isDefaultName() const;
115 
116 protected:
118  virtual int getAttrClass(const std::string& name)const;
120  virtual int getAttrFlag(const std::string& name)const;
122  std::string attr_id;
124  std::list<std::string> attr_parents;
126  double attr_stamp;
128  std::string attr_objtype;
130  std::string attr_name;
131 
133  void sendId(Atlas::Bridge&) const;
137  void sendStamp(Atlas::Bridge&) const;
141  void sendName(Atlas::Bridge&) const;
142 
143  virtual void iterate(int& current_class, std::string& attr) const;
144 
145  //freelist related things
146 public:
147  static RootData *alloc();
148  virtual void free();
149 
155 
161 private:
162  static RootData *defaults_RootData;
163  static RootData *begin_RootData;
164 
165  static std::map<std::string, int> * attr_flags_RootData;
166 };
167 
168 //
169 // Attribute name strings follow.
170 //
171 
172 extern const std::string ID_ATTR;
173 extern const std::string PARENTS_ATTR;
174 extern const std::string STAMP_ATTR;
175 extern const std::string OBJTYPE_ATTR;
176 extern const std::string NAME_ATTR;
177 
178 //
179 // Inlined member functions follow.
180 //
181 
182 const int ID_FLAG = 1 << 1;
183 
184 void RootData::setId(const std::string& val)
185 {
186  attr_id = val;
187  m_attrFlags |= ID_FLAG;
188 }
189 
190 const int PARENTS_FLAG = 1 << 2;
191 
192 void RootData::setParents(const std::list<std::string>& val)
193 {
194  attr_parents = val;
195  m_attrFlags |= PARENTS_FLAG;
196 }
197 
198 void RootData::setParentsAsList(const Atlas::Message::ListType& val)
199 {
200  m_attrFlags |= PARENTS_FLAG;
201  attr_parents.resize(0);
202  for(Atlas::Message::ListType::const_iterator I = val.begin();
203  I != val.end();
204  I++)
205  {
206  if((*I).isString()) {
207  attr_parents.push_back((*I).asString());
208  }
209  }
210 }
211 
212 const int STAMP_FLAG = 1 << 3;
213 
214 void RootData::setStamp(double val)
215 {
216  attr_stamp = val;
217  m_attrFlags |= STAMP_FLAG;
218 }
219 
220 const int OBJTYPE_FLAG = 1 << 4;
221 
222 void RootData::setObjtype(const std::string& val)
223 {
224  attr_objtype = val;
225  m_attrFlags |= OBJTYPE_FLAG;
226 }
227 
228 const int NAME_FLAG = 1 << 5;
229 
230 void RootData::setName(const std::string& val)
231 {
232  attr_name = val;
233  m_attrFlags |= NAME_FLAG;
234 }
235 
236 const std::string& RootData::getId() const
237 {
238  if(m_attrFlags & ID_FLAG)
239  return attr_id;
240  else
241  return ((RootData*)m_defaults)->attr_id;
242 }
243 
244 std::string& RootData::modifyId()
245 {
246  if(!(m_attrFlags & ID_FLAG))
247  setId(((RootData*)m_defaults)->attr_id);
248  return attr_id;
249 }
250 
251 const std::list<std::string>& RootData::getParents() const
252 {
253  if(m_attrFlags & PARENTS_FLAG)
254  return attr_parents;
255  else
256  return ((RootData*)m_defaults)->attr_parents;
257 }
258 
259 std::list<std::string>& RootData::modifyParents()
260 {
261  if(!(m_attrFlags & PARENTS_FLAG))
262  setParents(((RootData*)m_defaults)->attr_parents);
263  return attr_parents;
264 }
265 
266 const Atlas::Message::ListType RootData::getParentsAsList() const
267 {
268  const std::list<std::string>& lst_in = getParents();
269  Atlas::Message::ListType lst_out;
270  for(std::list<std::string>::const_iterator I = lst_in.begin();
271  I != lst_in.end();
272  I++)
273  {
274  lst_out.push_back(std::string(*I));
275  }
276  return lst_out;
277 }
278 
279 double RootData::getStamp() const
280 {
281  if(m_attrFlags & STAMP_FLAG)
282  return attr_stamp;
283  else
284  return ((RootData*)m_defaults)->attr_stamp;
285 }
286 
288 {
289  if(!(m_attrFlags & STAMP_FLAG))
290  setStamp(((RootData*)m_defaults)->attr_stamp);
291  return attr_stamp;
292 }
293 
294 const std::string& RootData::getObjtype() const
295 {
296  if(m_attrFlags & OBJTYPE_FLAG)
297  return attr_objtype;
298  else
299  return ((RootData*)m_defaults)->attr_objtype;
300 }
301 
303 {
304  if(!(m_attrFlags & OBJTYPE_FLAG))
305  setObjtype(((RootData*)m_defaults)->attr_objtype);
306  return attr_objtype;
307 }
308 
309 const std::string& RootData::getName() const
310 {
311  if(m_attrFlags & NAME_FLAG)
312  return attr_name;
313  else
314  return ((RootData*)m_defaults)->attr_name;
315 }
316 
317 std::string& RootData::modifyName()
318 {
319  if(!(m_attrFlags & NAME_FLAG))
320  setName(((RootData*)m_defaults)->attr_name);
321  return attr_name;
322 }
323 
325 {
326  return (m_attrFlags & ID_FLAG) == 0;
327 }
328 
330 {
331  return (m_attrFlags & PARENTS_FLAG) == 0;
332 }
333 
335 {
336  return (m_attrFlags & STAMP_FLAG) == 0;
337 }
338 
340 {
341  return (m_attrFlags & OBJTYPE_FLAG) == 0;
342 }
343 
345 {
346  return (m_attrFlags & NAME_FLAG) == 0;
347 }
348 
349 
350 } } // namespace Atlas::Objects
351 
352 #endif // ATLAS_OBJECTS_ROOT_H
Atlas::Objects::RootData::setId
void setId(const std::string &val)
Set the "id" attribute.
Definition: Root.h:184
Atlas::Objects::BaseObjectData
Atlas base object class.
Definition: BaseObject.h:68
Atlas::Objects::RootData
All objects inherit from this.
Definition: Root.h:36
Atlas::Objects::RootData::getParents
const std::list< std::string > & getParents() const
Retrieve the "parents" attribute.
Definition: Root.h:251
Atlas::Bridge
Atlas stream bridge.
Definition: Bridge.h:36
Atlas::Objects::RootData::attr_stamp
double attr_stamp
Last time this object was modified.
Definition: Root.h:126
Atlas::Objects::RootData::RootData
RootData(RootData *defaults=NULL)
Construct a RootData class definition.
Definition: Root.h:39
Atlas::Objects::RootData::iterate
virtual void iterate(int &current_class, std::string &attr) const
Iterate over the attributes of this instance.
Atlas::Objects::RootData::setParentsAsList
void setParentsAsList(const Atlas::Message::ListType &val)
Set the "parents" attribute AsList.
Definition: Root.h:198
Atlas::Objects::RootData::sendId
void sendId(Atlas::Bridge &) const
Send the "id" attribute to an Atlas::Bridge.
Atlas::Objects::RootData::isDefaultName
bool isDefaultName() const
Is "name" value default?
Definition: Root.h:344
Atlas::Objects::RootData::modifyObjtype
std::string & modifyObjtype()
Retrieve the "objtype" attribute as a non-const reference.
Definition: Root.h:302
Atlas::Objects::RootData::getDefaultObjectInstance
static RootData * getDefaultObjectInstance()
Get the reference object that contains the default values for attributes of instances of this class.
Atlas::Objects::RootData::free
virtual void free()
Free an instance of this class, returning it to the memory pool.
Atlas::Objects::RootData::setStamp
void setStamp(double val)
Set the "stamp" attribute.
Definition: Root.h:214
Atlas::Objects::RootData::isDefaultObjtype
bool isDefaultObjtype() const
Is "objtype" value default?
Definition: Root.h:339
Atlas::Objects::RootData::instanceOf
virtual bool instanceOf(int classNo) const
Is this instance of some class?
Atlas::Objects::RootData::setAttr
virtual void setAttr(const std::string &name, const Atlas::Message::Element &attr)
Set the attribute "name" to the value given by"attr".
Atlas::Objects::RootData::removeAttr
virtual void removeAttr(const std::string &name)
Remove the attribute "name". This will not work for static attributes.
Atlas::Objects::RootData::attr_objtype
std::string attr_objtype
What kind of object this is.
Definition: Root.h:128
Atlas::Objects::RootData::modifyId
std::string & modifyId()
Retrieve the "id" attribute as a non-const reference.
Definition: Root.h:244
Atlas::Objects::RootData::attr_id
std::string attr_id
Id of object.
Definition: Root.h:122
Atlas::Objects::RootData::getId
const std::string & getId() const
Retrieve the "id" attribute.
Definition: Root.h:236
Atlas::Objects::RootData::sendName
void sendName(Atlas::Bridge &) const
Send the "name" attribute to an Atlas::Bridge.
Atlas::Objects::RootData::isDefaultId
bool isDefaultId() const
Is "id" value default?
Definition: Root.h:324
Atlas::Message::Element
Multi-type container.
Definition: Element.h:61
Atlas::Objects::RootData::setObjtype
void setObjtype(const std::string &val)
Set the "objtype" attribute.
Definition: Root.h:222
Atlas::Objects::RootData::isDefaultStamp
bool isDefaultStamp() const
Is "stamp" value default?
Definition: Root.h:334
Atlas::Objects::RootData::addToMessage
virtual void addToMessage(Atlas::Message::MapType &) const
Write this object to an existing Element.
Atlas::Objects::RootData::sendContents
virtual void sendContents(Atlas::Bridge &b) const
Send the contents of this object to a Bridge.
Atlas::Objects::RootData::modifyParents
std::list< std::string > & modifyParents()
Retrieve the "parents" attribute as a non-const reference.
Definition: Root.h:259
Atlas::Objects::RootData::attr_name
std::string attr_name
Name of object.
Definition: Root.h:130
Atlas::Objects::RootData::~RootData
virtual ~RootData()
Default destructor.
Atlas::Objects::RootData::getParentsAsList
const Atlas::Message::ListType getParentsAsList() const
Retrieve the "parents" attribute AsList.
Definition: Root.h:266
Atlas::Objects::RootData::isDefaultParents
bool isDefaultParents() const
Is "parents" value default?
Definition: Root.h:329
Atlas::Objects::RootData::setParents
void setParents(const std::list< std::string > &val)
Set the "parents" attribute.
Definition: Root.h:192
Atlas::Objects::RootData::getAttrFlag
virtual int getAttrFlag(const std::string &name) const
Find the flag for the attribute "name".
Atlas::Objects::RootData::attr_parents
std::list< std::string > attr_parents
List of objects this inherits attributes from.
Definition: Root.h:124
Atlas::Objects::RootData::sendParents
void sendParents(Atlas::Bridge &) const
Send the "parents" attribute to an Atlas::Bridge.
Atlas::Objects::RootData::modifyStamp
double & modifyStamp()
Retrieve the "stamp" attribute as a non-const reference.
Definition: Root.h:287
Atlas::Objects::RootData::getObjtype
const std::string & getObjtype() const
Retrieve the "objtype" attribute.
Definition: Root.h:294
Atlas::Objects::RootData::copyAttr
virtual int copyAttr(const std::string &name, Atlas::Message::Element &attr) const
Retrieve the attribute "name".
Atlas::Objects::RootData::getDefaultObject
virtual RootData * getDefaultObject()
Get the reference object that contains the default values for attributes of instances of the same cla...
Atlas::Objects::RootData::setName
void setName(const std::string &val)
Set the "name" attribute.
Definition: Root.h:230
Atlas
The Atlas namespace.
Definition: Bridge.h:20
Atlas::Objects::RootData::getAttrClass
virtual int getAttrClass(const std::string &name) const
Find the class which contains the attribute "name".
Atlas::Objects::RootData::sendObjtype
void sendObjtype(Atlas::Bridge &) const
Send the "objtype" attribute to an Atlas::Bridge.
Atlas::Objects::RootData::getStamp
double getStamp() const
Retrieve the "stamp" attribute.
Definition: Root.h:279
Atlas::Objects::RootData::modifyName
std::string & modifyName()
Retrieve the "name" attribute as a non-const reference.
Definition: Root.h:317
Atlas::Objects::RootData::copy
virtual RootData * copy() const
Copy this object.
Atlas::Objects::RootData::getName
const std::string & getName() const
Retrieve the "name" attribute.
Definition: Root.h:309
Atlas::Objects::RootData::sendStamp
void sendStamp(Atlas::Bridge &) const
Send the "stamp" 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.