Eris  1.3.23
TypeInfo.h
1 #ifndef ERIS_TYPE_INFO_H
2 #define ERIS_TYPE_INFO_H
3 
4 #include <Eris/Types.h>
5 #include <Eris/TypeService.h>
6 
7 #include <sigc++/trackable.h>
8 
9 #include <map>
10 #include <string>
11 
12 namespace Atlas {
13  namespace Message {
14  class Element;
15  typedef std::map<std::string, Element> MapType;
16  }
17 }
18 
19 namespace Eris {
20 
37 class TypeInfo : virtual public sigc::trackable
38 {
39 public:
43  bool isA(TypeInfoPtr ti);
44 
48  inline bool isBound() const;
49 
53  bool hasUnresolvedChildren() const;
54 
59  void resolveChildren();
60 
61 // operators
63  bool operator==(const TypeInfo &x) const;
64 
66  bool operator<(const TypeInfo &x) const;
67 
68 // accessors
70  const std::string& getName() const;
71 
76  const TypeInfoSet & getChildren() const;
77 
82  const TypeInfoSet & getParents() const;
83 
89  const Atlas::Message::MapType& getAttributes() const;
90 
98  const Atlas::Message::Element* getAttribute(const std::string& attributeName) const;
99 
104  sigc::signal<void, const std::string&, const Atlas::Message::Element&> AttributeChanges;
105 
106 
112  void setAttribute(const std::string& attributeName, const Atlas::Message::Element& element);
113 
114 
115 protected:
116  friend class TypeService;
117  friend class TypeBoundRedispatch;
118 
120  TypeInfo(const std::string &id, TypeService*);
121 
123  TypeInfo(const Atlas::Objects::Root &atype, TypeService*);
124 
125  void validateBind();
126 
128  void processTypeData(const Atlas::Objects::Root& atype);
129 
133  sigc::signal<void> Bound;
134 
135 
142  void onAttributeChanges(const std::string& attributeName, const Atlas::Message::Element& element);
143 
144 private:
145  void addParent(TypeInfoPtr tp);
146  void addChild(TypeInfoPtr tp);
147 
149  void addAncestor(TypeInfoPtr tp);
150 
156  void extractDefaultAttributes(const Atlas::Objects::Root& atype);
157 
159  TypeInfoSet m_parents;
161  TypeInfoSet m_children;
162 
164  TypeInfoSet m_ancestors;
165 
166  bool m_bound;
167  const std::string m_name;
168  int m_atlasClassNo;
169 
170  StringSet m_unresolvedChildren;
171 
176  unsigned int m_moveCount;
177 
178  TypeService* m_typeService;
179 
183  Atlas::Message::MapType m_attributes;
184 };
185 
186 inline const Atlas::Message::MapType& TypeInfo::getAttributes() const
187 {
188  return m_attributes;
189 }
190 
191 inline bool TypeInfo::isBound() const
192 {
193  return m_bound;
194 }
195 
196 inline const std::string& TypeInfo::getName() const
197 {
198  return m_name;
199 }
200 
201 inline const TypeInfoSet & TypeInfo::getChildren() const
202 {
203  return m_children;
204 }
205 
206 inline const TypeInfoSet & TypeInfo::getParents() const
207 {
208  return m_parents;
209 }
210 
211 
212 } // of Eris namespace
213 
214 #endif
Eris::TypeService::BoundType
sigc::signal< void, TypeInfoPtr > BoundType
emitted when a new type is available and bound to it's parents
Definition: TypeService.h:45
Eris::TypeInfo::isA
bool isA(TypeInfoPtr ti)
Test whether this type inherits (directly or indirectly) from the specific class.
Definition: TypeInfo.cpp:45
Eris::TypeInfo::isBound
bool isBound() const
Check the bound flag for this node; if false then recursivley check parents until an authorative is f...
Definition: TypeInfo.h:191
Eris::TypeInfo::resolveChildren
void resolveChildren()
Retrive all child types from the server.
Definition: TypeInfo.cpp:60
Eris::TypeInfo::getChildren
const TypeInfoSet & getChildren() const
Gets the currently resolved child TypeInfo instances.
Definition: TypeInfo.h:201
Eris::TypeInfo::getName
const std::string & getName() const
the unique type name (matches the Atlas type)
Definition: TypeInfo.h:196
Eris::TypeService
A service class querying and caching types.
Definition: TypeService.h:25
Eris::TypeService::findTypeByName
TypeInfoPtr findTypeByName(const std::string &tynm)
Lookup the requested type, by name, and return NULL if it's unknown.
Definition: TypeService.cpp:54
Eris::TypeInfo::operator==
bool operator==(const TypeInfo &x) const
efficent comparisom of types (uses type ids if possible)
Definition: TypeInfo.cpp:112
Eris::TypeInfo::getParents
const TypeInfoSet & getParents() const
Gets the currently resolved parent TypeInfo instances.
Definition: TypeInfo.h:206
Eris::error
Definition: LogStream.h:56
Eris::TypeService::getTypeByName
TypeInfoPtr getTypeByName(const std::string &tynm)
find the TypeInfo for the named type; this may involve a search, or a map lookup.
Definition: TypeService.cpp:62
Eris::TypeInfo::hasUnresolvedChildren
bool hasUnresolvedChildren() const
Test if there are child types of the type, which have not yet been retrieved from the server.
Definition: TypeInfo.cpp:55
Eris::TypeInfo::processTypeData
void processTypeData(const Atlas::Objects::Root &atype)
process the INFO data
Definition: TypeInfo.cpp:77
Eris::TypeInfo::setAttribute
void setAttribute(const std::string &attributeName, const Atlas::Message::Element &element)
Sets an attribute.
Definition: TypeInfo.cpp:236
Eris::TypeInfo
The representation of an Atlas type (i.e a class or operation definition).
Definition: TypeInfo.h:38
Eris::TypeInfo::getAttributes
const Atlas::Message::MapType & getAttributes() const
Gets the default attributes for this entity type.
Definition: TypeInfo.h:186
Eris::TypeBoundRedispatch
Definition: TypeBoundRedispatch.h:14
Eris::TypeInfo::operator<
bool operator<(const TypeInfo &x) const
efficent ordering of type (uses type ids if possible)
Definition: TypeInfo.cpp:120
Eris::TypeInfo::getAttribute
const Atlas::Message::Element * getAttribute(const std::string &attributeName) const
Gets the value of the named attribute.
Definition: TypeInfo.cpp:216
Eris::TypeInfo::TypeInfo
TypeInfo(const std::string &id, TypeService *)
forward constructor, when data is not available
Definition: TypeInfo.cpp:23
Eris::TypeInfo::AttributeChanges
sigc::signal< void, const std::string &, const Atlas::Message::Element & > AttributeChanges
Emitted before an attribute changes.
Definition: TypeInfo.h:104
Eris::TypeInfo::TypeInfo
TypeInfo(const Atlas::Objects::Root &atype, TypeService *)
full constructor, if an INFO has been received
Eris::warning
Definition: LogStream.h:46
Eris::TypeInfo::Bound
sigc::signal< void > Bound
Emitted when the type is bound, i.e there is an unbroken graph of TypeInfo instances through every an...
Definition: TypeInfo.h:133
Eris::TypeInfo::onAttributeChanges
void onAttributeChanges(const std::string &attributeName, const Atlas::Message::Element &element)
Called before the AttributeChanges signal is emitted.
Definition: TypeInfo.cpp:248