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 18 /** All objects inherit from this. 19 20 You can browse all definitions starting from here and 21 descending into childrens. 22 23 */ 24 25 class RootData; 26 typedef SmartPtr<RootData> Root; 27 28 static const int ROOT_NO = 1; 29 30 /// \brief All objects inherit from this.. 31 /// 32 /** You can browse all definitions starting from here and 33 descending into childrens. 34 */ 35 class RootData : public BaseObjectData 36 { 37 protected: 38 /// Construct a RootData class definition. 39 RootData(RootData *defaults = NULL) : 40 BaseObjectData((BaseObjectData*)defaults) 41 { 42 m_class_no = ROOT_NO; 43 } 44 /// Default destructor. 45 virtual ~RootData(); 46 47 public: 48 /// Copy this object. 49 virtual RootData * copy() const; 50 51 /// Is this instance of some class? 52 virtual bool instanceOf(int classNo) const; 53 54 /// Retrieve the attribute "name". Return non-zero if it does 55 /// not exist. 56 virtual int copyAttr(const std::string& name, Atlas::Message::Element & attr) const; 57 /// Set the attribute "name" to the value given by"attr" 58 virtual void setAttr(const std::string& name, 59 const Atlas::Message::Element& attr); 60 /// Remove the attribute "name". This will not work for static attributes. 61 virtual void removeAttr(const std::string& name); 62 63 /// Send the contents of this object to a Bridge. 64 virtual void sendContents(Atlas::Bridge & b) const; 65 66 /// Write this object to an existing Element. 67 virtual void addToMessage(Atlas::Message::MapType &) const; 68 69 /// Set the "id" attribute. 70 inline void setId(const std::string& val); 71 /// Set the "parents" attribute. 72 inline void setParents(const std::list<std::string>& val); 73 /// Set the "parents" attribute AsList. 74 inline void setParentsAsList(const Atlas::Message::ListType& val); 75 /// Set the "stamp" attribute. 76 inline void setStamp(double val); 77 /// Set the "objtype" attribute. 78 inline void setObjtype(const std::string& val); 79 /// Set the "name" attribute. 80 inline void setName(const std::string& val); 81 82 /// Retrieve the "id" attribute. 83 inline const std::string& getId() const; 84 /// Retrieve the "id" attribute as a non-const reference. 85 inline std::string& modifyId(); 86 /// Retrieve the "parents" attribute. 87 inline const std::list<std::string>& getParents() const; 88 /// Retrieve the "parents" attribute as a non-const reference. 89 inline std::list<std::string>& modifyParents(); 90 /// Retrieve the "parents" attribute AsList. 91 inline const Atlas::Message::ListType getParentsAsList() const; 92 /// Retrieve the "stamp" attribute. 93 inline double getStamp() const; 94 /// Retrieve the "stamp" attribute as a non-const reference. 95 inline double& modifyStamp(); 96 /// Retrieve the "objtype" attribute. 97 inline const std::string& getObjtype() const; 98 /// Retrieve the "objtype" attribute as a non-const reference. 99 inline std::string& modifyObjtype(); 100 /// Retrieve the "name" attribute. 101 inline const std::string& getName() const; 102 /// Retrieve the "name" attribute as a non-const reference. 103 inline std::string& modifyName(); 104 105 /// Is "id" value default? 106 inline bool isDefaultId() const; 107 /// Is "parents" value default? 108 inline bool isDefaultParents() const; 109 /// Is "stamp" value default? 110 inline bool isDefaultStamp() const; 111 /// Is "objtype" value default? 112 inline bool isDefaultObjtype() const; 113 /// Is "name" value default? 114 inline bool isDefaultName() const; 115 116 protected: 117 /// Find the class which contains the attribute "name". 118 virtual int getAttrClass(const std::string& name)const; 119 /// Find the flag for the attribute "name". 120 virtual int getAttrFlag(const std::string& name)const; 121 /// Id of object 122 std::string attr_id; 123 /// List of objects this inherits attributes from. 124 std::list<std::string> attr_parents; 125 /// Last time this object was modified. 126 double attr_stamp; 127 /// What kind of object this is. 128 std::string attr_objtype; 129 /// Name of object. 130 std::string attr_name; 131 132 /// Send the "id" attribute to an Atlas::Bridge. 133 void sendId(Atlas::Bridge&) const; 134 /// Send the "parents" attribute to an Atlas::Bridge. 135 void sendParents(Atlas::Bridge&) const; 136 /// Send the "stamp" attribute to an Atlas::Bridge. 137 void sendStamp(Atlas::Bridge&) const; 138 /// Send the "objtype" attribute to an Atlas::Bridge. 139 void sendObjtype(Atlas::Bridge&) const; 140 /// Send the "name" attribute to an Atlas::Bridge. 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 150 /// \brief Get the reference object that contains the default values for 151 /// attributes of instances of the same class as this object. 152 /// 153 /// @return a pointer to the default object. 154 virtual RootData *getDefaultObject(); 155 156 /// \brief Get the reference object that contains the default values for 157 /// attributes of instances of this class. 158 /// 159 /// @return a pointer to the default object. 160 static RootData *getDefaultObjectInstance(); 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 setId(const std::string & val)184void 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 setParents(const std::list<std::string> & val)192void RootData::setParents(const std::list<std::string>& val) 193 { 194 attr_parents = val; 195 m_attrFlags |= PARENTS_FLAG; 196 } 197 setParentsAsList(const Atlas::Message::ListType & val)198void 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 setStamp(double val)214void RootData::setStamp(double val) 215 { 216 attr_stamp = val; 217 m_attrFlags |= STAMP_FLAG; 218 } 219 220 const int OBJTYPE_FLAG = 1 << 4; 221 setObjtype(const std::string & val)222void 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 setName(const std::string & val)230void RootData::setName(const std::string& val) 231 { 232 attr_name = val; 233 m_attrFlags |= NAME_FLAG; 234 } 235 getId()236const 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 modifyId()244std::string& RootData::modifyId() 245 { 246 if(!(m_attrFlags & ID_FLAG)) 247 setId(((RootData*)m_defaults)->attr_id); 248 return attr_id; 249 } 250 getParents()251const 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 modifyParents()259std::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 getParentsAsList()266const 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 getStamp()279double 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 modifyStamp()287double& RootData::modifyStamp() 288 { 289 if(!(m_attrFlags & STAMP_FLAG)) 290 setStamp(((RootData*)m_defaults)->attr_stamp); 291 return attr_stamp; 292 } 293 getObjtype()294const 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 modifyObjtype()302std::string& RootData::modifyObjtype() 303 { 304 if(!(m_attrFlags & OBJTYPE_FLAG)) 305 setObjtype(((RootData*)m_defaults)->attr_objtype); 306 return attr_objtype; 307 } 308 getName()309const 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 modifyName()317std::string& RootData::modifyName() 318 { 319 if(!(m_attrFlags & NAME_FLAG)) 320 setName(((RootData*)m_defaults)->attr_name); 321 return attr_name; 322 } 323 isDefaultId()324bool RootData::isDefaultId() const 325 { 326 return (m_attrFlags & ID_FLAG) == 0; 327 } 328 isDefaultParents()329bool RootData::isDefaultParents() const 330 { 331 return (m_attrFlags & PARENTS_FLAG) == 0; 332 } 333 isDefaultStamp()334bool RootData::isDefaultStamp() const 335 { 336 return (m_attrFlags & STAMP_FLAG) == 0; 337 } 338 isDefaultObjtype()339bool RootData::isDefaultObjtype() const 340 { 341 return (m_attrFlags & OBJTYPE_FLAG) == 0; 342 } 343 isDefaultName()344bool RootData::isDefaultName() const 345 { 346 return (m_attrFlags & NAME_FLAG) == 0; 347 } 348 349 350 } } // namespace Atlas::Objects 351 352 #endif // ATLAS_OBJECTS_ROOT_H 353