Eris
1.4.0
|
The representation of an Atlas type (i.e a class or operation definition). More...
#include <TypeInfo.h>
Public Member Functions | |
bool | isA (TypeInfoPtr ti) |
Test whether this type inherits (directly or indirectly) from the specific class. More... | |
bool | isBound () const |
Check the bound flag for this node; if false then recursivley check parents until an authorative is found. | |
void | refresh () |
Request update to the type info from the server. | |
bool | hasUnresolvedChildren () const |
Test if there are child types of the type, which have not yet been retrieved from the server. | |
void | resolveChildren () |
Retrive all child types from the server. More... | |
bool | operator== (const TypeInfo &x) const |
efficent comparisom of types (uses type ids if possible) | |
bool | operator< (const TypeInfo &x) const |
efficent ordering of type (uses type ids if possible) | |
const std::string & | getName () const |
the unique type name (matches the Atlas type) | |
const std::string & | getObjType () const |
the object type of this Type or Archetype | |
const TypeInfoSet & | getChildren () const |
Gets the currently resolved child TypeInfo instances. More... | |
const TypeInfoPtr & | getParent () const |
Gets the currently resolved parent TypeInfo instances. More... | |
const Atlas::Message::MapType & | getAttributes () const |
Gets the default attributes for this entity type. More... | |
const Atlas::Message::Element * | getAttribute (const std::string &attributeName) const |
Gets the value of the named attribute. More... | |
void | setAttribute (const std::string &attributeName, const Atlas::Message::Element &element) |
Sets an attribute. More... | |
const Atlas::Message::ListType & | getEntities () const |
Gets a list of entities, if the type is an Archetype. More... | |
Public Attributes | |
sigc::signal< void, const std::string &, const Atlas::Message::Element & > | AttributeChanges |
Emitted before an attribute changes. More... | |
Protected Member Functions | |
TypeInfo (const std::string &id, TypeService *) | |
forward constructor, when data is not available | |
TypeInfo (const Atlas::Objects::Root &atype, TypeService *) | |
full constructor, if an INFO has been received | |
void | validateBind () |
void | processTypeData (const Atlas::Objects::Root &atype) |
process the INFO data | |
void | onAttributeChanges (const std::string &attributeName, const Atlas::Message::Element &element) |
Called before the AttributeChanges signal is emitted. More... | |
Protected Attributes | |
sigc::signal< void > | Bound |
Emitted when the type is bound, i.e there is an unbroken graph of TypeInfo instances through every ancestor to the root object. | |
Friends | |
class | TypeService |
class | TypeBoundRedispatch |
The representation of an Atlas type (i.e a class or operation definition).
This class supports efficent inheritance queries, and traversal of the type hierarchy. Atlas types have a unique ID, and types can be retrieved using this value. Where an Atlas::Objects instance, or an Atlas::Message::Element representing an Atlas object is being examined, it is much more efficient to use the 'getSafe' methods rather than extracting PARENTS[0] and calling findSafe. This is because the getSafe methods may take advantage of integer type codes stored in the object, which avoids a map lookup to locate the type.
Note that the core Atlas::Objects hierarchy (as defined in the protocols/atlas/spec section of CVS) is loaded from the 'atlas.xml' file at startup, and that other types are queried from the server. In general, Eris will automatically delay processing operations and entities until the necessary type data has become available, without intervention by the client. However, certain routines may throw the 'OperationBlocked' exception, which must be forward to the Connection instance for handling.
const Atlas::Message::Element * Eris::TypeInfo::getAttribute | ( | const std::string & | attributeName | ) | const |
Gets the value of the named attribute.
This method will search through both this instance and all of its parents for the attribute by the specified name. If no attribute can be found a null pointer will be returned.
attributeName | The name of the attribute to search for. |
first check with the local attributes
it wasn't locally defined check with the parent
References getParent().
|
inline |
Gets the default attributes for this entity type.
Note that the map returned does not include inherited attributes.
Referenced by Eris::Entity::fillAttributesFromType().
|
inline |
Gets the currently resolved child TypeInfo instances.
Referenced by onAttributeChanges().
|
inline |
Gets a list of entities, if the type is an Archetype.
|
inline |
Gets the currently resolved parent TypeInfo instances.
Referenced by Eris::Entity::fillAttributesFromType(), and getAttribute().
bool Eris::TypeInfo::isA | ( | TypeInfoPtr | ti | ) |
Test whether this type inherits (directly or indirectly) from the specific class.
If this type is not bound, this may return false-negatives.
|
protected |
Called before the AttributeChanges signal is emitted.
This call is made before an attribute is changed. It will emit the AttributeChanges event first, and then go through all of the children, calling itself on them as long as the children themselves doesn't have an attribute by the same name defined.
attributeName | The name of the attribute which is being changed. |
element | The new attribute value. |
Now go through all children, and only make them emit the event if they themselves doesn't have an attribute by this name (which thus overrides this).
References AttributeChanges, and getChildren().
Referenced by setAttribute().
void Eris::TypeInfo::resolveChildren | ( | ) |
Retrive all child types from the server.
This will log an error and do nothing if no unresolved children exist.
References Eris::TypeService::getTypeByName().
void Eris::TypeInfo::setAttribute | ( | const std::string & | attributeName, |
const Atlas::Message::Element & | element | ||
) |
Sets an attribute.
attributeName | The name of the attribute. |
element | The new value of the attribute. |
References onAttributeChanges().
sigc::signal<void, const std::string&, const Atlas::Message::Element&> Eris::TypeInfo::AttributeChanges |
Emitted before an attribute changes.
The first parameter is the name of the attribute, and the second is the actual attribute.
Referenced by onAttributeChanges(), and processTypeData().