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.
To help user to write new simulated objects two macros are defined:
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 ; } ;
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.
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.
The inputs and outputs should work with associated parameters, you should use these associated data.
The extensions take place between each step :
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" ] ;
Documentation generated on Mon Jun 9 11:45:59 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |