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 (C) 2000-2001 Stefanus Du Toit and Alistair Riddoch 00004 00005 #ifndef ATLAS_OBJECTS_ROOT_H 00006 #define ATLAS_OBJECTS_ROOT_H 00007 00008 #include <Atlas/Message/Encoder.h> 00009 #include <Atlas/Message/Element.h> 00010 00011 namespace Atlas { namespace Objects { 00012 00017 class NoSuchAttrException 00018 { 00019 public: 00020 NoSuchAttrException(const std::string& name) : name(name) {} 00021 std::string name; 00022 }; 00023 00029 class Root { 00030 public: 00032 Root(); 00034 Root(const char * id); 00035 protected: 00037 Root(const char * id, const char * parent); 00038 public: 00040 virtual ~Root(); 00041 00043 static Root Class(); 00044 00046 virtual bool hasAttr(const std::string& name) const; 00049 virtual Atlas::Message::Element getAttr(const std::string& name) 00050 const throw (NoSuchAttrException); 00052 virtual void setAttr(const std::string& name, 00053 const Atlas::Message::Element& attr); 00055 virtual void removeAttr(const std::string& name); 00056 00058 inline void setParents(const Atlas::Message::Element::ListType& val); 00060 inline void setId(const std::string& val); 00062 inline void setObjtype(const std::string& val); 00064 inline void setName(const std::string& val); 00065 00067 inline const Atlas::Message::Element::ListType& getParents() const; 00068 inline Atlas::Message::Element::ListType& getParents(); 00070 inline const std::string& getId() const; 00071 inline std::string& getId(); 00073 inline const std::string& getObjtype() const; 00074 inline std::string& getObjtype(); 00076 inline const std::string& getName() const; 00077 inline std::string& getName(); 00078 00080 virtual Atlas::Message::Element asObject() const; 00082 virtual Atlas::Message::Element::MapType asMap() const; 00083 00085 virtual void sendContents(Atlas::Bridge* b) const; 00086 00087 protected: 00088 std::map<std::string, Atlas::Message::Element> attributes; 00089 Atlas::Message::Element::ListType attr_parents; 00090 std::string attr_id; 00091 std::string attr_objtype; 00092 std::string attr_name; 00093 00094 inline void sendParents(Atlas::Bridge*) const; 00095 inline void sendId(Atlas::Bridge*) const; 00096 inline void sendObjtype(Atlas::Bridge*) const; 00097 inline void sendName(Atlas::Bridge*) const; 00098 }; 00099 00100 // 00101 // Inlined member functions follow. 00102 // 00103 00104 void Root::setParents(const Atlas::Message::Element::ListType& val) 00105 { 00106 attr_parents = val; 00107 } 00108 00109 void Root::setId(const std::string& val) 00110 { 00111 attr_id = val; 00112 } 00113 00114 void Root::setObjtype(const std::string& val) 00115 { 00116 attr_objtype = val; 00117 } 00118 00119 void Root::setName(const std::string& val) 00120 { 00121 attr_name = val; 00122 } 00123 00124 const Atlas::Message::Element::ListType& Root::getParents() const 00125 { 00126 return attr_parents; 00127 } 00128 00129 Atlas::Message::Element::ListType& Root::getParents() 00130 { 00131 return attr_parents; 00132 } 00133 00134 const std::string& Root::getId() const 00135 { 00136 return attr_id; 00137 } 00138 00139 std::string& Root::getId() 00140 { 00141 return attr_id; 00142 } 00143 00144 const std::string& Root::getObjtype() const 00145 { 00146 return attr_objtype; 00147 } 00148 00149 std::string& Root::getObjtype() 00150 { 00151 return attr_objtype; 00152 } 00153 00154 const std::string& Root::getName() const 00155 { 00156 return attr_name; 00157 } 00158 00159 std::string& Root::getName() 00160 { 00161 return attr_name; 00162 } 00163 00164 } } 00165 00166 #endif
Copyright 2000 the respective authors.
This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.