eris
1.4.0
A WorldForge client library.
|
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. More...
#include <TypeInfo.h>
Public Member Functions | |
bool | isA (TypeInfo *ti) const |
Test whether this type inherits (directly or indirectly) from the specific class. If this type is not bound, this may return false-negatives. More... | |
bool | isA (const std::string &typeName) const |
Test whether this type inherits (directly or indirectly) from the specific class. If this type is not bound, this may return false-negatives. This test is a bit slower than checking against a TypeInfo instance. More... | |
bool | isBound () const |
Check the bound flag for this node; if false then recursivley check parents until an authorative is found. More... | |
void | refresh () |
Request update to the type info from the server. More... | |
bool | hasUnresolvedChildren () const |
Test if there are child types of the type, which have not yet been retrieved from the server. More... | |
void | resolveChildren () |
Retrive all child types from the server. This will log an error and do nothing if no unresolved children exist. More... | |
bool | operator== (const TypeInfo &x) const |
efficent comparisom of types (uses type ids if possible) More... | |
bool | operator< (const TypeInfo &x) const |
efficent ordering of type (uses type ids if possible) More... | |
const std::string & | getName () const |
the unique type name (matches the Atlas type) More... | |
const std::string & | getObjType () const |
the object type of this Type or Archetype More... | |
const std::set< TypeInfo * > & | getChildren () const |
Gets the currently resolved child TypeInfo instances. More... | |
const TypeInfo * | getParent () const |
Gets the currently resolved parent TypeInfo instances. More... | |
TypeInfo * | getParent () |
const Atlas::Message::MapType & | getProperties () const |
Gets the default properties for this entity type. Note that the map returned does not include inherited properties. More... | |
const Atlas::Message::Element * | getProperty (const std::string &propertyName) const |
Gets the value of the named property. This method will search through both this instance and all of its parents for the property by the specified name. If no property can be found a null pointer will be returned. More... | |
void | setProperty (const std::string &propertyName, const Atlas::Message::Element &element) |
Sets a property. More... | |
const Atlas::Message::ListType & | getEntities () const |
Gets a list of entities, if the type is an Archetype. More... | |
TypeService & | getTypeService () |
const TypeService & | getTypeService () const |
Public Attributes | |
sigc::signal< void, const std::string &, const Atlas::Message::Element & > | PropertyChanges |
Emitted before an property changes. The first parameter is the name of the property, and the second is the actual property. More... | |
Protected Member Functions | |
TypeInfo (std::string id, TypeService &) | |
forward constructor, when data is not available More... | |
TypeInfo (const Atlas::Objects::Root &atype, TypeService &) | |
full constructor, if an INFO has been received More... | |
void | validateBind () |
void | processTypeData (const Atlas::Objects::Root &atype) |
process the INFO data More... | |
void | onPropertyChanges (const std::string &propertyName, const Atlas::Message::Element &element) |
Called before the PropertyChanges signal is emitted. This call is made before an property is changed. It will emit the PropertyChanges event first, and then go through all of the children, calling itself on them as long as the children themselves doesn't have an property by the same name defined. 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. More... | |
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.
Definition at line 32 of file TypeInfo.h.
|
protected |
forward constructor, when data is not available
Definition at line 24 of file TypeInfo.cpp.
References processTypeData().
|
protected |
full constructor, if an INFO has been received
|
inline |
Gets the currently resolved child TypeInfo instances.
Definition at line 226 of file TypeInfo.h.
Referenced by onPropertyChanges().
|
inline |
Gets a list of entities, if the type is an Archetype.
Definition at line 241 of file TypeInfo.h.
|
inline |
the unique type name (matches the Atlas type)
Definition at line 217 of file TypeInfo.h.
Referenced by operator<().
|
inline |
the object type of this Type or Archetype
Definition at line 222 of file TypeInfo.h.
|
inline |
Gets the currently resolved parent TypeInfo instances.
Definition at line 231 of file TypeInfo.h.
Referenced by Eris::Entity::fillPropertiesFromType(), and getProperty().
|
inline |
Gets the default properties for this entity type. Note that the map returned does not include inherited properties.
Definition at line 207 of file TypeInfo.h.
Referenced by Eris::Entity::fillPropertiesFromType().
const Atlas::Message::Element * Eris::TypeInfo::getProperty | ( | const std::string & | propertyName | ) | const |
Gets the value of the named property. This method will search through both this instance and all of its parents for the property by the specified name. If no property can be found a null pointer will be returned.
propertyName | The name of the property to search for. |
first check with the local properties
it wasn't locally defined check with the parent
Definition at line 259 of file TypeInfo.cpp.
References getParent().
bool Eris::TypeInfo::hasUnresolvedChildren | ( | ) | const |
Test if there are child types of the type, which have not yet been retrieved from the server.
Definition at line 76 of file TypeInfo.cpp.
bool Eris::TypeInfo::isA | ( | TypeInfo * | ti | ) | const |
Test whether this type inherits (directly or indirectly) from the specific class. If this type is not bound, this may return false-negatives.
Definition at line 48 of file TypeInfo.cpp.
bool Eris::TypeInfo::isA | ( | const std::string & | typeName | ) | const |
Test whether this type inherits (directly or indirectly) from the specific class. If this type is not bound, this may return false-negatives. This test is a bit slower than checking against a TypeInfo instance.
Definition at line 62 of file TypeInfo.cpp.
|
inline |
Check the bound flag for this node; if false then recursivley check parents until an authorative is found.
Definition at line 212 of file TypeInfo.h.
Referenced by refresh(), and Eris::View::taskRateChanged().
|
protected |
Called before the PropertyChanges signal is emitted. This call is made before an property is changed. It will emit the PropertyChanges event first, and then go through all of the children, calling itself on them as long as the children themselves doesn't have an property by the same name defined.
propertyName | The name of the property which is being changed. |
element | The new property value. |
Now go through all children, and only make them emit the event if they themselves doesn't have an property by this name (which thus overrides this).
Definition at line 288 of file TypeInfo.cpp.
References getChildren(), and PropertyChanges.
Referenced by setProperty().
bool Eris::TypeInfo::operator< | ( | const TypeInfo & | x | ) | const |
efficent ordering of type (uses type ids if possible)
Definition at line 179 of file TypeInfo.cpp.
References getName().
bool Eris::TypeInfo::operator== | ( | const TypeInfo & | x | ) | const |
efficent comparisom of types (uses type ids if possible)
Definition at line 171 of file TypeInfo.cpp.
|
protected |
process the INFO data
Definition at line 96 of file TypeInfo.cpp.
References Eris::TypeService::findTypeByName(), Eris::TypeService::getTypeByName(), and PropertyChanges.
Referenced by TypeInfo().
void Eris::TypeInfo::refresh | ( | ) |
Request update to the type info from the server.
Definition at line 300 of file TypeInfo.cpp.
References Bound, Eris::TypeService::BoundType, isBound(), and Eris::TypeService::sendRequest().
Referenced by Eris::Avatar::useStop().
void Eris::TypeInfo::resolveChildren | ( | ) |
Retrive all child types from the server. This will log an error and do nothing if no unresolved children exist.
Definition at line 81 of file TypeInfo.cpp.
References Eris::TypeService::getTypeByName().
void Eris::TypeInfo::setProperty | ( | const std::string & | propertyName, |
const Atlas::Message::Element & | element | ||
) |
Sets a property.
propertyName | The name of the property. |
element | The new value of the property. |
Definition at line 277 of file TypeInfo.cpp.
References onPropertyChanges().
|
protected |
Emitted when the type is bound, i.e there is an unbroken graph of TypeInfo instances through every ancestor to the root object.
Definition at line 152 of file TypeInfo.h.
Referenced by refresh().
sigc::signal<void, const std::string&, const Atlas::Message::Element&> Eris::TypeInfo::PropertyChanges |
Emitted before an property changes. The first parameter is the name of the property, and the second is the actual property.
Definition at line 114 of file TypeInfo.h.
Referenced by onPropertyChanges(), and processTypeData().