Eris  1.4.0
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
Eris::TypeInfo Class Reference

The representation of an Atlas type (i.e a class or operation definition). More...

#include <TypeInfo.h>

Inheritance diagram for Eris::TypeInfo:

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

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.

Member Function Documentation

◆ getAttribute()

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.

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

first check with the local attributes

it wasn't locally defined check with the parent

References getParent().

◆ getAttributes()

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

Gets the default attributes for this entity type.

Note that the map returned does not include inherited attributes.

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

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

◆ getChildren()

const TypeInfoSet & Eris::TypeInfo::getChildren ( ) const
inline

Gets the currently resolved child TypeInfo instances.

Returns
A set of child TypeInfo instances.

Referenced by onAttributeChanges().

◆ getEntities()

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

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

Returns

◆ getParent()

const TypeInfoPtr & Eris::TypeInfo::getParent ( ) const
inline

Gets the currently resolved parent TypeInfo instances.

Returns
A set of parent TypeInfo instances.

Referenced by Eris::Entity::fillAttributesFromType(), and getAttribute().

◆ isA()

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.

◆ onAttributeChanges()

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

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

◆ 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.

References Eris::TypeService::getTypeByName().

◆ setAttribute()

void Eris::TypeInfo::setAttribute ( const std::string &  attributeName,
const Atlas::Message::Element &  element 
)

Sets an attribute.

Parameters
attributeNameThe name of the attribute.
elementThe new value of the attribute.

References onAttributeChanges().

Member Data Documentation

◆ AttributeChanges

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


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