Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | Related Pages

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 (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/Object.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 std::string& id);
00035 protected:
00037     Root(const std::string& id, const std::string& parent);
00038 public:
00040     virtual ~Root();
00041 
00043     static Root Instantiate();
00044 
00046     virtual bool HasAttr(const std::string& name) const;
00049     virtual Atlas::Message::Object GetAttr(const std::string& name)
00050         const throw (NoSuchAttrException);
00052     virtual void SetAttr(const std::string& name,
00053                          const Atlas::Message::Object& attr);
00055     virtual void RemoveAttr(const std::string& name);
00056 
00058     inline void SetParents(const Atlas::Message::Object::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::Object::ListType& GetParents() const;
00068     inline Atlas::Message::Object::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::Object AsObject() const;
00082     virtual Atlas::Message::Object::MapType AsMap() const;
00083 
00085     virtual void SendContents(Atlas::Bridge* b) const;
00086 
00087 protected:
00088     std::map<std::string, Atlas::Message::Object> attributes;
00089     Atlas::Message::Object::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::Object::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::Object::ListType& Root::GetParents() const
00125 {
00126     return attr_parents;
00127 }
00128 
00129 Atlas::Message::Object::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.