Extensible simulated object

Some of the new features of the extensible simulated objects of this OpenMASK version are their attributes and their extensibility.

Using attributes is a simple way to define parameters that can be seen by other objects. Using attributes gives automatically many features to manage the initialisation, connection, and event processing.

Using extensions is a simple way to modify the object features without modifying it. An extension can independently modify the attributes, the loading of the configuration, the computation or the event handling of its associated object.

For more details see the Attribute feature and Extension feature explanations.

Creation of simulated objects

The simulated objects are managed by the controller which is in charge of creating them. To do this task it uses a factory. Every simulated object must be registered in this factory, if not, the controller will not able to create it.

To help user to write new simulated objects two macros are defined:

The following exemple shows the declaration and the implementation of a very simple object (SimplePoint) with its unique attribut.

In the declaration ("SimplePoint.h") the object uses the macro and declares its attribute.

class SimplePoint : public ExtensibleSimulatedObject
{
  DECLARE_OBJECT_FACTORY( SimplePoint ) ;
protected:
  OM::AttributeT< OM::Type::Transform > _position ;
} ;
In the implementation ("SimplePoint.cpp") the object uses the macro and implements its contructor and destructor.
REGISTER_OBJECT_FACTORY( SimplePoint, "SimplePoint" ) ;

SimplePoint::SimplePoint( PsController& ctrl, const PsObjectDescriptor& objectDescriptor )
: OM::ExtensibleSimulatedObject( ctrl, objectDescriptor ),
  _position( "Position", Transform( Wm4::Vector3f::ZERO ) )
{
  addAttribute( _position ) ;
  _position.createOutput() ;
}

SimplePoint::~SimplePoint()
{
}

Controller,"Object descriptor","Object factory","Object creator","Simulated object";

Controller=>Controller [ label = "createDescribedObject( Object descriptor )" ] ; Controller=>"Object descriptor" [ label = "createDescribedObject()" ] ; --- [ label = "createDescribedObject" ] ; "Object descriptor"=>"Object factory" [ label = "create( class id )" ] ; "Object descriptor"<<"Object factory" [ label = "Object creator" ] ; "Object descriptor"=>"Object creator" [ label = "operator()( Controller, Object descriptor )" ] ; --- [ label = "operator()" ] ; "Object creator"=>"Simulated object" [ label = "new()" ] ; "Object creator"<<"Simulated object" [ label = "Simulated object" ] ; "Object creator"=>"Simulated object" [ label = "postConstruction()" ] ; --- [ label = "postConstruction()" ] ; --- [ label = "for each extension" ] ; "Simulated object"=>"Simulated object" [ label = "createAndAddExtension()" ] ; --- [ label = "end of each extension" ] ; --- [ label = "end of postConstruction()" ] ; "Object descriptor"<<"Object creator" [ label = "Simulated object" ] ; --- [ label = "end of operator()" ] ; Controller<<"Object descriptor" [ label = "Simulated object" ] ; --- [ label = "end of createDescribedObject" ] ;

Note

In the previous version, the simulated object factory was included in the controller. So it is easier to register the simulated object in the factory because it is no more necessary to have the controller to do that. It is very useful to create plugins which register themselves the objects they define.

Reuse an old simulated object in the new version needs few changes.

Initialisation of simulated objects

TODO

Controller,"Extensible simulated object",Attribut,Extension;

Controller=>"Extensible simulated object" [ label = "init()" ] ; "Extensible simulated object"=>"Extensible simulated object" [ label = "loadParameters(UserParams node)" ] ; --- [ label = "for each attribut" ] ; "Extensible simulated object"=>Attribut [ label = "loadParameters(UserParams node)" ] ; --- [ label = "end of each attribut" ] ; --- [ label = "for each extension" ] ; "Extensible simulated object"=>Extension [ label = "loadObjectParameters(UserParams node)" ] ; --- [ label = "end of each extension" ] ; "Extensible simulated object"=>"Extensible simulated object" [ label = "loadExtensionsParameters(Extensions node)" ] ; --- [ label = "for each extension in configuration" ] ; "Extensible simulated object"=>Extension [ label = "loadExtensionParameters(Extension parameter node)" ] ; --- [ label = "end of each extension in configuration" ] ;

Note

In the previous version, only the init method was available. It still work for old object.

Computing of simulated object

The compute method of the extensible simulated object is splitted in three main parts: The second method computeParameters is a pure virtual method and must be defined in the child classes.

The inputs and outputs should work with associated parameters, you should use these associated data.

The extensions take place between each step :

So the extensions could modify the associated data, after they have been retrieved in the inputs, and before they have been copied in the outputs.

The calling in the compute method of the extensible object is: Controller,"Extensible simulated object",Attribut,Extension;

Controller=>"Extensible simulated object" [ label = "compute()" ] ; "Extensible simulated object"=>"Extensible simulated object" [ label = "computeInputs()" ] ; --- [ label = "for each attribut" ] ; "Extensible simulated object"=>Attribut [ label = "getValueFromInput()" ] ; --- [ label = "end of each attribut" ] ; --- [ label = "for each extension" ] ; "Extensible simulated object"=>Extension [ label = "preComputeParameters()" ] ; --- [ label = "end of each extension" ] ; "Extensible simulated object"=>"Extensible simulated object" [ label = "computeParameters()" ] ; --- [ label = "for each extension" ] ; "Extensible simulated object"=>Extension [ label = "postComputeParameters()" ] ; --- [ label = "end of each extension" ] ; "Extensible simulated object"=>"Extensible simulated object" [ label = "computeOutputs()" ] ; --- [ label = "for each attribut" ] ; "Extensible simulated object"=>Attribut [ label = "setValueToOutput()" ] ; "Extensible simulated object"=>Attribut [ label = "resetUpdated()" ] ; --- [ label = "end of each attribut" ] ;


logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007