eris  1.4.0
A WorldForge client library.
Eris::TypeInfo Class Reference

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>

Inheritance diagram for Eris::TypeInfo:
Collaboration diagram for Eris::TypeInfo:

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 TypeInfogetParent () const
 Gets the currently resolved parent TypeInfo instances. More...
 
TypeInfogetParent ()
 
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...
 
TypeServicegetTypeService ()
 
const TypeServicegetTypeService () 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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ TypeInfo() [1/2]

Eris::TypeInfo::TypeInfo ( std::string  id,
TypeService ts 
)
protected

forward constructor, when data is not available

Definition at line 24 of file TypeInfo.cpp.

◆ TypeInfo() [2/2]

Eris::TypeInfo::TypeInfo ( const Atlas::Objects::Root &  atype,
TypeService  
)
protected

full constructor, if an INFO has been received

Member Function Documentation

◆ getChildren()

const std::set< TypeInfo * > & Eris::TypeInfo::getChildren ( ) const
inline

Gets the currently resolved child TypeInfo instances.

Returns
A set of child TypeInfo instances.

Definition at line 226 of file TypeInfo.h.

Referenced by onPropertyChanges().

◆ getEntities()

const Atlas::Message::ListType & Eris::TypeInfo::getEntities ( ) const
inline

Gets a list of entities, if the type is an Archetype.

Returns

Definition at line 241 of file TypeInfo.h.

◆ getName()

const std::string & Eris::TypeInfo::getName ( ) const
inline

the unique type name (matches the Atlas type)

Definition at line 217 of file TypeInfo.h.

◆ getObjType()

const std::string & Eris::TypeInfo::getObjType ( ) const
inline

the object type of this Type or Archetype

Definition at line 222 of file TypeInfo.h.

◆ getParent()

TypeInfo * Eris::TypeInfo::getParent ( ) const
inline

Gets the currently resolved parent TypeInfo instances.

Returns
A set of parent TypeInfo instances.

Definition at line 231 of file TypeInfo.h.

Referenced by Eris::Entity::fillPropertiesFromType(), and getProperty().

◆ getProperties()

const Atlas::Message::MapType & Eris::TypeInfo::getProperties ( ) const
inline

Gets the default properties for this entity type. Note that the map returned does not include inherited properties.

Returns
An element map of the default properties for this type.

Definition at line 207 of file TypeInfo.h.

Referenced by Eris::Entity::fillPropertiesFromType().

◆ getProperty()

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.

Parameters
propertyNameThe name of the property to search for.
Note
This method won't throw an exception if the property isn't found.
Returns
A pointer to an Element instance, or a null pointer if no property could be found.

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().

◆ hasUnresolvedChildren()

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.

◆ isA() [1/2]

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.

◆ isA() [2/2]

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.

◆ isBound()

bool Eris::TypeInfo::isBound ( ) const
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.

◆ onPropertyChanges()

void Eris::TypeInfo::onPropertyChanges ( const std::string &  propertyName,
const Atlas::Message::Element &  element 
)
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.

Parameters
propertyNameThe name of the property which is being changed.
elementThe 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().

◆ operator<()

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.

◆ operator==()

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.

◆ processTypeData()

void Eris::TypeInfo::processTypeData ( const Atlas::Objects::Root &  atype)
protected

process the INFO data

Definition at line 96 of file TypeInfo.cpp.

References Eris::TypeService::findTypeByName(), Eris::TypeService::getTypeByName(), and PropertyChanges.

◆ refresh()

void Eris::TypeInfo::refresh ( )

Request update to the type info from the server.

Definition at line 300 of file TypeInfo.cpp.

References Eris::TypeService::sendRequest().

◆ resolveChildren()

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().

◆ setProperty()

void Eris::TypeInfo::setProperty ( const std::string &  propertyName,
const Atlas::Message::Element &  element 
)

Sets a property.

Parameters
propertyNameThe name of the property.
elementThe new value of the property.

Definition at line 277 of file TypeInfo.cpp.

References onPropertyChanges().

Member Data Documentation

◆ Bound

sigc::signal<void> Eris::TypeInfo::Bound
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.

◆ PropertyChanges

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().


The documentation for this class was generated from the following files: