00001 #ifndef ERIS_TYPE_INFO_H
00002 #define ERIS_TYPE_INFO_H
00003
00004 #include <Eris/Types.h>
00005 #include <Eris/TypeService.h>
00006
00007 #include <sigc++/trackable.h>
00008
00009 #include <map>
00010 #include <string>
00011
00012 namespace Atlas {
00013 namespace Message {
00014 class Element;
00015 typedef std::map<std::string, Element> MapType;
00016 }
00017 }
00018
00019 namespace Eris {
00020
00037 class TypeInfo : virtual public sigc::trackable
00038 {
00039 public:
00043 bool isA(TypeInfoPtr ti);
00044
00048 inline bool isBound() const;
00049
00053 bool hasUnresolvedChildren() const;
00054
00059 void resolveChildren();
00060
00061
00063 bool operator==(const TypeInfo &x) const;
00064
00066 bool operator<(const TypeInfo &x) const;
00067
00068
00070 const std::string& getName() const;
00071
00076 const TypeInfoSet & getChildren() const;
00077
00082 const TypeInfoSet & getParents() const;
00083
00089 const Atlas::Message::MapType& getAttributes() const;
00090
00098 const Atlas::Message::Element* getAttribute(const std::string& attributeName) const;
00099
00104 sigc::signal<void, const std::string&, const Atlas::Message::Element&> AttributeChanges;
00105
00106
00112 void setAttribute(const std::string& attributeName, const Atlas::Message::Element& element);
00113
00114
00115 protected:
00116 friend class TypeService;
00117 friend class TypeBoundRedispatch;
00118
00120 TypeInfo(const std::string &id, TypeService*);
00121
00123 TypeInfo(const Atlas::Objects::Root &atype, TypeService*);
00124
00125 void validateBind();
00126
00128 void processTypeData(const Atlas::Objects::Root& atype);
00129
00133 sigc::signal<void, TypeInfo*> Bound;
00134
00135
00142 virtual void onAttributeChanges(const std::string& attributeName, const Atlas::Message::Element& element);
00143
00144 private:
00145 void addParent(TypeInfoPtr tp);
00146 void addChild(TypeInfoPtr tp);
00147
00149 void addAncestor(TypeInfoPtr tp);
00150
00156 void extractDefaultAttributes(const Atlas::Objects::Root& atype);
00157
00159 TypeInfoSet m_parents;
00161 TypeInfoSet m_children;
00162
00164 TypeInfoSet m_ancestors;
00165
00166 bool m_bound;
00167 const std::string m_name;
00168 int m_atlasClassNo;
00169
00170 StringSet m_unresolvedChildren;
00171
00176 unsigned int m_moveCount;
00177
00178 TypeService* m_typeService;
00179
00183 Atlas::Message::MapType m_attributes;
00184 };
00185
00186 inline const Atlas::Message::MapType& TypeInfo::getAttributes() const
00187 {
00188 return m_attributes;
00189 }
00190
00191 inline bool TypeInfo::isBound() const
00192 {
00193 return m_bound;
00194 }
00195
00196 inline const std::string& TypeInfo::getName() const
00197 {
00198 return m_name;
00199 }
00200
00201 inline const TypeInfoSet & TypeInfo::getChildren() const
00202 {
00203 return m_children;
00204 }
00205
00206 inline const TypeInfoSet & TypeInfo::getParents() const
00207 {
00208 return m_parents;
00209 }
00210
00211
00212 }
00213
00214 #endif