Attribute feature

Collaboration diagram for Attribute feature:

A simulated object which is a child of the extensible simulated object class can add to itself attributes (children of the Attribute class). More...

Classes

class  OMK::IAttributeBaseT< PrmType >
 Attribute interface. More...
class  OMK::IAttributeT< PrmType, ModelType, AccessorType >
 Attribute interface. More...
class  OMK::AttributeT< PrmType >
 Attribute with encapsulated value for types that are not sons of OMKType. More...
class  OMK::AttributeTypeT< PrmType >
 Attribute with encapsulated value for types that are sons of OMKType. More...
class  OMK::AttributeAccT< PrmType, PrmAccType >
 Attribute with indirect access to value for types that are not sons of OMKType. More...
class  OMK::AttributeAccTypeT< PrmType, PrmAccType >
 Attribute with indirect access to value for types that are sons of OMKType. More...
class  OMK::AttributeFctT< PrmType, ObjectType >
 Attribute with indirect access to value for types that are not sons of OMKType. More...
class  OMK::AttributeFctTypeT< PrmType, ObjectType >
 Attribute with indirect access to value for types that are not sons of OMKType. More...
class  OMK::IAccessorT< T >
 The interface class for accessor to a simple value. More...
class  OMK::AccessorT< T >
 The implementation class for accessor to encapsuled value. More...
class  OMK::AccessorFctT< T, ObjectT >
 The implementation class for accessor through accessors method of an associated object. More...
class  OMK::AccessorAccT< T, T2 >
 The implementation class for accessor through accessors method of an associated object. More...
class  OMK::IAttribute
 Attribute interface. More...
class  OMK::ExtensibleSimulatedObject
 Ancestor of every extensible objects. More...
class  OMK::IAttributeAnimatorT< PrmType, ModelType, AccessorType >
 Attribute for animator interface. More...
class  OMK::AttributeAnimatorT< PrmType >
 Attribute with encapsulated value for types that are not sons of OMKType. More...
class  OMK::AttributeAnimatorTypeT< PrmType >
 Attribute with encapsulated value for types that are sons of OMKType. More...
class  OMK::AttributeAnimatorAccT< PrmType, PrmAccType >
 Attribute with indirect access to value for types that are not sons of OMKType. More...
class  OMK::AttributeAnimatorAccTypeT< PrmType, PrmAccType >
 Attribute with indirect access to value for types that are sons of OMKType. More...
class  OMK::AttributeAnimatorFctT< PrmType, ObjectType >
 Attribute with indirect access to value for types that are not sons of OMKType. More...
class  OMK::AttributeAnimatorFctTypeT< PrmType, ObjectType >
 Attribute with indirect access to value for types that are not sons of OMKType. More...
class  OMK::Iii::IConvertorT< TypeOut, TypeIn >
 The interface class for convertor. More...

Detailed Description

A simulated object which is a child of the extensible simulated object class can add to itself attributes (children of the Attribute class).

Attribute definition

The aim of the attributes is to provide a simple way to access and to handle the parameters used by the simulated object or an extension. In this aim the attributes provide an interface to give many features including awareness.

An attribute is defined by:

An attribute defines some services:
The following code is used:

Accessors

Initialisation Creation of input and output Updating value according to the input or output Input connection and events processing to manage connection Events processing to manage value setting Activation of event processing Services for additional inputs (use by connectors)

Attribute classes characteristics

There are three manners to access to the value and there are two cases for the type, if it is a type which is a son of base type or not. According to these, there are six kinds of attributes. The following table shows the six attribute implementations.

Class name Access PrmType must
be a son
of PsType
Notes
to a value
AccessorT
by accessor
AccessorAccT
by methods
AccessorFctT
AttributeT
X
    no (1)
AttributeTypeT
X
    yes
AttributeAccT  
X
  no (2)
AttributeAccTypeT  
X
  yes
AttributeFctT    
X
no (3)
AttributeFctTypeT    
X
yes

  1. This attribute encapsulates its value.
    Most of the attributes are of this types.
  2. This attribute accesses to value through the given accessor.
    You can use this attribute to offer a differente type for the same attribute, unless a convertion between PrmType and PrmAccType is defined.
  3. This attribute accesses to the value through the methods of the object.
    You should use this attribute if the value is encapsulated in an other object associated to the owner of the attribute.

Template arguments and parameters for attribute classes

The following table shows which template arguments are used with IAttributeT to create the Attribute and what parameters are needed to implement the attribute.

Class name IAttributeT arguments Template parameters
AttributeT PrmType   PrmType :
type of the attribute
ModelType SimpleTypeT< PrmType >
AccessorType AccessorT< PrmType >
AttributeTypeT PrmType  
ModelType PrmType
AccessorType AccessorT< PrmType >
AttributeAccT PrmType   PrmType :
type of the attribute
PrmAccType :
type of the associated attribute
ModelType SimpleTypeT< PrmType >
AccessorType AccessorAccT< PrmType, PrmAccType >
AttributeAccTypeT
PrmType  
ModelType PrmType
AccessorType AccessorAccT< PrmType, PrmAccType >
AttributeFctT PrmType   PrmType :
type of the attribute
ObjectType :
type of the associated object
of which one uses the methods
ModelType SimpleTypeT< PrmType >
AccessorType AccessorFctT< PrmType, ObjectType >
AttributeFctTypeT PrmType  
ModelType PrmType
AccessorType AccessorFctT< PrmType, ObjectType >

Constructor arguments for attribute classes

The following table shows which how the attribute accesses to the value and the constructor arguments for each attribute classes.

Class name Access to the value Constructor arguments
AttributeT directly to the encapsulated value
(AccessorT)
id : PsName
value : PrmType
AttributeTypeT
AttributeAccT through an other accessor
(AccessorAccT)
id : PsName
accessor : IAccessorT< PrmAccType >*
AttributeAccTypeT
AttributeFctT by methods of an object
(AccessorFctT)
id : PsName
object : ObjectType*
setMethod : AccessorFctT< PrmType >::SetMethod
getMethod : AccessorFctT< PrmType >::GetMethod
AttributeFctTypeT

The attribute and its owner

The attribute can be declared by any kind of object (simulated object, extension,...) but its owner is always a extensible simulated object.

The extensible object manages its attributes in a map which is indexed by the attributes id. The object offers the following methods to manage the attribute :

How to implement an attribute ?

The attributes are very easy to use.

In a simulated object

First of all, the object must be a Extensible Simulated Object. It declares attributes as it did with standard parameters. The only difference is that the type used for the parameter is AttributeT< Type > instead of Type.
class MyObject : public ExtensibleSimulatedObject
{
protected:
  AttributeT< int > _myParam ;
...
In the constructor, the attribute is initialised and registered
MyObject::MyObject( PsController& ctrl, const PsObjectDescriptor& objectDescriptor ) 
: ExtensibleSimulatedObject( ctrl, objectDescriptor ),
_myParam( "theIdOfTheParam", 0 ) // Initialise to 0
{
  addAttribute( _myParam ) ;
  // To add an input
  _myParam.creatInput() ;
  // To add an output
  _myParam.creatOutput() ;
}
That's all !

After you can use all the features which come with this attribute.

Be carefull the output, must be created in the object constructor or in its postConstruction method.

In a extension

The extension can add attribute to its owner, and can access to the attributes of its owner.

In this example the extension declares an attribute and an accessor to an attribute.

class MyExtension:  
  public OMK::ExtensionT< ExtensibleSimulatedObject >
{
  DECLARE_EXTENSION_FACTORY( MyExtension ) ;
  // The attribute
  AttributeT< int > _myParam ;
  // The accessor
  IAccessorT< int >* _attributeAccessor ;
};
The attribute is initialised and registered in the constructor.
MyExtension::MyExtension( ExtensibleSimulatedObject* owner, const PsName& id )
: OMK::ExtensionT< ExtensibleSimulatedObject >( owner, id ),
  _myParam( id, 0 ),
  _attributeAccessor( 0 )
{
  // add the attribute to the object
  _owner->addAttribute( _offset ) ;
}
Then in the loadExtensionParameters, the id of the attribute which the extension has to access to is retrieved in the configuration parameter Attribute" .
bool MyExtension::loadExtensionParameters( const PsConfigurationParameterDescriptor * node )
{
  bool ok = true ;
  // Attribute to offset
  PsName attributeName ;
  ok = ok && PsParametersAccessor::get( node, "Attribute", attributeName, _owner ) ;
  if( ok )
  {
    _attributeAccessor = _owner->getBaseAttribute< int >( attributeName ) ;
    ok = _attributeAccessor != 0 ;
  }
  return ok ;
}
For a real example, you can see the offset extension.

Only the extensions dynamically created or created in the object constructor or in its postConstruction method can create attributes with an associated output in their own constructor.

How to configure an attribute ?

See the attribute interface for more details.
logo OpenMask

Documentation generated on Mon Jun 9 11:45:59 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007