Root.h

00001 // This file may be redistributed and modified only under the terms of
00002 // the GNU Lesser General Public License (See COPYING for details).
00003 // Copyright 2000-2001 Stefanus Du Toit and Aloril.
00004 // Copyright 2001-2004 Al Riddoch.
00005 // Automatically generated using gen_cpp.py.
00006 
00007 #ifndef ATLAS_OBJECTS_ROOT_H
00008 #define ATLAS_OBJECTS_ROOT_H
00009 
00010 #include <Atlas/Objects/BaseObject.h>
00011 
00012 #include <Atlas/Message/Element.h>
00013 
00014 namespace Atlas { namespace Objects { 
00015 
00016 template <class T> class SmartPtr;
00017 
00025 class RootData;
00026 typedef SmartPtr<RootData> Root;
00027 
00028 static const int ROOT_NO = 1;
00029 
00032 
00035 class RootData : public BaseObjectData
00036 {
00037 protected:
00039     RootData(RootData *defaults = NULL) : 
00040         BaseObjectData((BaseObjectData*)defaults)
00041     {
00042         m_class_no = ROOT_NO;
00043     }
00045     virtual ~RootData();
00046 
00047 public:
00049     virtual RootData * copy() const;
00050 
00052     virtual bool instanceOf(int classNo) const;
00053 
00056     virtual int copyAttr(const std::string& name, Atlas::Message::Element & attr) const;
00058     virtual void setAttr(const std::string& name,
00059                          const Atlas::Message::Element& attr);
00061     virtual void removeAttr(const std::string& name);
00062 
00064     virtual void sendContents(Atlas::Bridge & b) const;
00065 
00067     virtual void addToMessage(Atlas::Message::MapType &) const;
00068 
00070     inline void setId(const std::string& val);
00072     inline void setParents(const std::list<std::string>& val);
00074     inline void setParentsAsList(const Atlas::Message::ListType& val);
00076     inline void setStamp(double val);
00078     inline void setObjtype(const std::string& val);
00080     inline void setName(const std::string& val);
00081 
00083     inline const std::string& getId() const;
00085     inline std::string& modifyId();
00087     inline const std::list<std::string>& getParents() const;
00089     inline std::list<std::string>& modifyParents();
00091     inline const Atlas::Message::ListType getParentsAsList() const;
00093     inline double getStamp() const;
00095     inline double& modifyStamp();
00097     inline const std::string& getObjtype() const;
00099     inline std::string& modifyObjtype();
00101     inline const std::string& getName() const;
00103     inline std::string& modifyName();
00104 
00106     inline bool isDefaultId() const;
00108     inline bool isDefaultParents() const;
00110     inline bool isDefaultStamp() const;
00112     inline bool isDefaultObjtype() const;
00114     inline bool isDefaultName() const;
00115 
00116 protected:
00118     virtual int getAttrClass(const std::string& name)const;
00120     virtual int getAttrFlag(const std::string& name)const;
00122     std::string attr_id;
00124     std::list<std::string> attr_parents;
00126     double attr_stamp;
00128     std::string attr_objtype;
00130     std::string attr_name;
00131 
00133     void sendId(Atlas::Bridge&) const;
00135     void sendParents(Atlas::Bridge&) const;
00137     void sendStamp(Atlas::Bridge&) const;
00139     void sendObjtype(Atlas::Bridge&) const;
00141     void sendName(Atlas::Bridge&) const;
00142 
00143     virtual void iterate(int& current_class, std::string& attr) const;
00144 
00145     //freelist related things
00146 public:
00147     static RootData *alloc();
00148     virtual void free();
00149 
00154     virtual RootData *getDefaultObject();
00155 
00160     static RootData *getDefaultObjectInstance();
00161 private:
00162     static RootData *defaults_RootData;
00163     static RootData *begin_RootData;
00164 
00165     static std::map<std::string, int> * attr_flags_RootData;
00166 };
00167 
00168 //
00169 // Inlined member functions follow.
00170 //
00171 
00172 const int ID_FLAG = 1 << 1;
00173 void RootData::setId(const std::string& val)
00174 {
00175     attr_id = val;
00176     m_attrFlags |= ID_FLAG;
00177 }
00178 
00179 const int PARENTS_FLAG = 1 << 2;
00180 void RootData::setParents(const std::list<std::string>& val)
00181 {
00182     attr_parents = val;
00183     m_attrFlags |= PARENTS_FLAG;
00184 }
00185 
00186 void RootData::setParentsAsList(const Atlas::Message::ListType& val)
00187 {
00188     m_attrFlags |= PARENTS_FLAG;
00189     attr_parents.resize(0);
00190     for(Atlas::Message::ListType::const_iterator I = val.begin();
00191         I != val.end();
00192         I++)
00193     {
00194         if((*I).isString()) {
00195             attr_parents.push_back((*I).asString());
00196         }
00197     }
00198 }
00199 
00200 const int STAMP_FLAG = 1 << 3;
00201 void RootData::setStamp(double val)
00202 {
00203     attr_stamp = val;
00204     m_attrFlags |= STAMP_FLAG;
00205 }
00206 
00207 const int OBJTYPE_FLAG = 1 << 4;
00208 void RootData::setObjtype(const std::string& val)
00209 {
00210     attr_objtype = val;
00211     m_attrFlags |= OBJTYPE_FLAG;
00212 }
00213 
00214 const int NAME_FLAG = 1 << 5;
00215 void RootData::setName(const std::string& val)
00216 {
00217     attr_name = val;
00218     m_attrFlags |= NAME_FLAG;
00219 }
00220 
00221 const std::string& RootData::getId() const
00222 {
00223     if(m_attrFlags & ID_FLAG)
00224         return attr_id;
00225     else
00226         return ((RootData*)m_defaults)->attr_id;
00227 }
00228 
00229 std::string& RootData::modifyId()
00230 {
00231     if(!(m_attrFlags & ID_FLAG))
00232         setId(((RootData*)m_defaults)->attr_id);
00233     return attr_id;
00234 }
00235 
00236 const std::list<std::string>& RootData::getParents() const
00237 {
00238     if(m_attrFlags & PARENTS_FLAG)
00239         return attr_parents;
00240     else
00241         return ((RootData*)m_defaults)->attr_parents;
00242 }
00243 
00244 std::list<std::string>& RootData::modifyParents()
00245 {
00246     if(!(m_attrFlags & PARENTS_FLAG))
00247         setParents(((RootData*)m_defaults)->attr_parents);
00248     return attr_parents;
00249 }
00250 
00251 const Atlas::Message::ListType RootData::getParentsAsList() const
00252 {
00253     const std::list<std::string>& lst_in = getParents();
00254     Atlas::Message::ListType lst_out;
00255     for(std::list<std::string>::const_iterator I = lst_in.begin();
00256         I != lst_in.end();
00257         I++)
00258     {
00259         lst_out.push_back(std::string(*I));
00260     }
00261     return lst_out;
00262 }
00263 
00264 double RootData::getStamp() const
00265 {
00266     if(m_attrFlags & STAMP_FLAG)
00267         return attr_stamp;
00268     else
00269         return ((RootData*)m_defaults)->attr_stamp;
00270 }
00271 
00272 double& RootData::modifyStamp()
00273 {
00274     if(!(m_attrFlags & STAMP_FLAG))
00275         setStamp(((RootData*)m_defaults)->attr_stamp);
00276     return attr_stamp;
00277 }
00278 
00279 const std::string& RootData::getObjtype() const
00280 {
00281     if(m_attrFlags & OBJTYPE_FLAG)
00282         return attr_objtype;
00283     else
00284         return ((RootData*)m_defaults)->attr_objtype;
00285 }
00286 
00287 std::string& RootData::modifyObjtype()
00288 {
00289     if(!(m_attrFlags & OBJTYPE_FLAG))
00290         setObjtype(((RootData*)m_defaults)->attr_objtype);
00291     return attr_objtype;
00292 }
00293 
00294 const std::string& RootData::getName() const
00295 {
00296     if(m_attrFlags & NAME_FLAG)
00297         return attr_name;
00298     else
00299         return ((RootData*)m_defaults)->attr_name;
00300 }
00301 
00302 std::string& RootData::modifyName()
00303 {
00304     if(!(m_attrFlags & NAME_FLAG))
00305         setName(((RootData*)m_defaults)->attr_name);
00306     return attr_name;
00307 }
00308 
00309 bool RootData::isDefaultId() const
00310 {
00311     return (m_attrFlags & ID_FLAG) == 0;
00312 }
00313 
00314 bool RootData::isDefaultParents() const
00315 {
00316     return (m_attrFlags & PARENTS_FLAG) == 0;
00317 }
00318 
00319 bool RootData::isDefaultStamp() const
00320 {
00321     return (m_attrFlags & STAMP_FLAG) == 0;
00322 }
00323 
00324 bool RootData::isDefaultObjtype() const
00325 {
00326     return (m_attrFlags & OBJTYPE_FLAG) == 0;
00327 }
00328 
00329 bool RootData::isDefaultName() const
00330 {
00331     return (m_attrFlags & NAME_FLAG) == 0;
00332 }
00333 
00334 
00335 } } // namespace Atlas::Objects
00336 
00337 #endif // ATLAS_OBJECTS_ROOT_H

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.