#include <OMKInteractiveExtension.h>
Inheritance diagram for OMK::Iii::InteractiveExtension:
Public Member Functions | |
DECLARE_EXTENSION_FACTORY (InteractiveExtension) | |
Factory and constructor/destructor. | |
void | addConnector (IConnector *connector, bool postComputing) |
Method to add connectors. | |
IConnector * | getConnector (const Name &id) |
Method to get a connector. | |
Protected Types | |
typedef std::map< const Name, IConnector * > | ConnectorsMap |
Protected Member Functions | |
virtual bool | processGetAccessibleParameters (Type::GetAccessibleParametersEvent *event) |
Process the "parameters ?" event. | |
virtual bool | processGetCurrentValues (Type::GetCurrentValuesEvent *event) |
Process the "get current values" event. | |
virtual bool | processControlTakeOverAndGetCurrentValues (Type::TakeOverAndGetCurrentValuesEvent *event) |
Process the "control take over" event. | |
virtual bool | processControlRelease (Event *event) |
Process the "control release" event. | |
virtual bool | processControlFreeze (Type::ControlFreezeEvent *event) |
Process the "control freeze" event. | |
virtual bool | processControlUnfreeze (Event *event) |
Process the "control unfreeze" event. | |
virtual bool | processNewValueAvailable (Type::NewValueAvailableEvent *event) |
Process the "new value available" event. | |
Configuration loaders | |
virtual bool | loadExtensionParameters (const ConfigurationParameterDescriptor *node) |
Configuration parameters loader of Extension. | |
SimulatedObject interfaces | |
virtual void | preComputeParameters () |
The pre-compute part of the compute method. | |
virtual void | postComputeParameters () |
The post-compute part of the compute method. | |
Protected Attributes | |
EventListener * | _getAccessibleParametersListener |
EventListener * | _controlTakeOverAndGetCurrentValuesListener |
EventListener * | _controlReleaseListener |
EventListener * | _controlFreezeListener |
EventListener * | _controlUnfreezeListener |
EventListener * | _getCurrentValuesListener |
EventListener * | _newValueAvailableListener |
ConnectorsMap | _connectors |
Connectors map. | |
ConnectorsMap | _preConnectors |
ConnectorsMap | _postConnectors |
IAccessRule * | _defaultAccessRule |
root { Class Controller UserParams { ... AccessRules { Grp1 // Here the definition of the access rule name "Grp1" { AccessLevel 1 Freezable on } } } Sons { ... object1 { ... Extensions { ... interaction { Class Interactive Connectors { Position { Type Simple AccessRule // Here the access rule is defined localy, only for this connector { AccessLevel 1 Freezable on } Category "absolute" } Enable { Type Simple AccessRule Grp1 // Use the access rule named "Grp1" which it defined in the Controller object Category "absolute" } } } ... } } ... } }
See the introduction to the interaction protocols
Definition at line 104 of file OMKInteractiveExtension.h.
typedef std::map< const Name, IConnector* > OMK::Iii::InteractiveExtension::ConnectorsMap [protected] |
Definition at line 215 of file OMKInteractiveExtension.h.
OMK::Iii::InteractiveExtension::DECLARE_EXTENSION_FACTORY | ( | InteractiveExtension | ) |
Factory and constructor/destructor.
bool InteractiveExtension::loadExtensionParameters | ( | const ConfigurationParameterDescriptor * | node | ) | [protected, virtual] |
Configuration parameters loader of Extension.
Reimplemented from OMK::Extension.
Definition at line 81 of file OMKInteractiveExtension.cpp.
References _connectors, _controlFreezeListener, _controlReleaseListener, _controlTakeOverAndGetCurrentValuesListener, _controlUnfreezeListener, _getAccessibleParametersListener, _getCurrentValuesListener, _newValueAvailableListener, OMK::ExtensionT< SimulatedObjectType >::_owner, OMK::EventId::CONTROL_FREEZE, OMK::EventId::CONTROL_RELEASE, OMK::EventId::CONTROL_TAKE_OVER_AND_GET_CURRENT_VALUES, OMK::EventId::CONTROL_UNFREEZE, OMK::ParametersAccessor::get(), OMK::EventId::GET_ACCESSIBLE_PARAMETERS, OMK::EventId::GET_CURRENT_VALUES, OMK::Extension::getId(), OMK::ConfigurationParameterDescriptor::getNumberOfSubItems(), OMK::ConfigurationParameterDescriptor::getSubDescriptorByName(), OMK::IAttribute::getTypeId(), OMK::EventId::NEW_VALUE_AVAILABLE, OMERROR, OMFATALERROR, processControlFreeze(), processControlRelease(), processControlTakeOverAndGetCurrentValues(), processControlUnfreeze(), processGetAccessibleParameters(), processGetCurrentValues(), and processNewValueAvailable().
00082 { 00083 // Creates the event listeners 00084 _getAccessibleParametersListener = new GetAccessibleParametersEventListener 00085 ( *_owner, this, 00086 &InteractiveExtension::processGetAccessibleParameters, 00087 EventId::GET_ACCESSIBLE_PARAMETERS ) ; 00088 _controlTakeOverAndGetCurrentValuesListener = new TakeOverAndGetCurrentValuesEventListener 00089 ( *_owner, this, 00090 &InteractiveExtension::processControlTakeOverAndGetCurrentValues, 00091 EventId::CONTROL_TAKE_OVER_AND_GET_CURRENT_VALUES ) ; 00092 _controlReleaseListener = new EventListenerCallBack< InteractiveExtension > 00093 ( *_owner, this, 00094 &InteractiveExtension::processControlRelease, 00095 EventId::CONTROL_RELEASE ) ; 00096 _controlFreezeListener = new ControlFreezeEventListener 00097 ( *_owner, this, 00098 &InteractiveExtension::processControlFreeze, 00099 EventId::CONTROL_FREEZE ) ; 00100 _controlUnfreezeListener = new EventListenerCallBack< InteractiveExtension > 00101 ( *_owner, this, 00102 &InteractiveExtension::processControlUnfreeze, 00103 EventId::CONTROL_UNFREEZE ) ; 00104 _getCurrentValuesListener = new GetCurrentValuesEventListener 00105 ( *_owner, this, 00106 &InteractiveExtension::processGetCurrentValues, 00107 EventId::GET_CURRENT_VALUES ) ; 00108 _newValueAvailableListener = new NewValueAvailableEventListener 00109 ( *_owner, this, 00110 &InteractiveExtension::processNewValueAvailable, 00111 EventId::NEW_VALUE_AVAILABLE ) ; 00112 00113 // Retrieve the connector fields to create the connectors which defined a "Class" 00114 const ConfigurationParameterDescriptor * connectorsNode = node ? node->getSubDescriptorByName( "Connectors" ) : 0 ; 00115 00116 if( connectorsNode ) 00117 { 00118 // Create the connectors 00119 int nbItems = connectorsNode->getNumberOfSubItems() ; 00120 for( int i = 0 ; i < nbItems ; ++i ) 00121 { 00122 // Retrieves parameters sets for each extension 00123 Name id( static_cast<const MultipleConfigurationParameter *>( connectorsNode )->getNameOfSubDescriptor( i ) ) ; 00124 const ConfigurationParameterDescriptor * connectorParameters = connectorsNode->getSubDescriptorByPosition( i ) ; 00125 // Try to retrieve the class id to create the extension 00126 Name attributeId( id ) ; 00127 ParametersAccessor::get( connectorParameters, "Attribute", attributeId ) ; 00128 std::string classIdTmp ; 00129 if( ParametersAccessor::get( connectorParameters, "Type", classIdTmp ) ) 00130 { 00131 IAttribute *foundAttribute = _owner->getAttribute( attributeId ) ; 00132 if( foundAttribute == 0 ) 00133 { 00134 OMFATALERROR( "Attribute ID [" << attributeId 00135 << "] not found in code for the connector of extension with ID [" 00136 << getId() << "]" ) ; 00137 } 00138 // Now ClassId is ok => Create the extension 00139 Name classId( classIdTmp + "ConnectorT" + foundAttribute->getTypeId().name() ) ; 00140 ConnectorFactory::getInstance().create( classId )( id, attributeId, 00141 this, connectorParameters ) ; 00142 } 00143 else if( ParametersAccessor::get( connectorParameters, "Class", classIdTmp ) ) 00144 { // ClassId is ok => Create the extension 00145 Name classId( classIdTmp + _owner->getAttribute( attributeId )->getTypeId().name() ) ; 00146 ConnectorFactory::getInstance().create( classId )( id, attributeId, 00147 this, connectorParameters ) ; 00148 } 00149 else 00150 { 00151 OMERROR( "Unable to create the connector for the extension with ID [" << getId() 00152 << "] due to errors in configuration file" ) ; 00153 } 00154 } 00155 // Initialise the connector 00156 for( ConnectorsMap::iterator connector = _connectors.begin() ; 00157 connector != _connectors.end() ; 00158 ++connector ) 00159 { 00160 connector->second->loadParameters( connectorsNode->getSubDescriptorByName( connector->second->id().getCString() ) ) ; 00161 } 00162 } 00163 return true ; 00164 }
void InteractiveExtension::preComputeParameters | ( | ) | [protected, virtual] |
The pre-compute part of the compute method.
Reimplemented from OMK::Extension.
Definition at line 189 of file OMKInteractiveExtension.cpp.
References _preConnectors.
00190 { 00191 // Update the interactive parameters 00192 for( ConnectorsMap::iterator i = _preConnectors.begin() ; i != _preConnectors.end() ; ++i ) 00193 { 00194 (*i).second->updateParameter() ; 00195 } 00196 }
void InteractiveExtension::postComputeParameters | ( | ) | [protected, virtual] |
The post-compute part of the compute method.
Reimplemented from OMK::Extension.
Definition at line 199 of file OMKInteractiveExtension.cpp.
References _postConnectors.
00200 { 00201 // Update the interactive parameters 00202 for( ConnectorsMap::iterator i = _postConnectors.begin() ; i != _postConnectors.end() ; ++i ) 00203 { 00204 (*i).second->updateParameter() ; 00205 } 00206 }
virtual bool OMK::Iii::InteractiveExtension::processGetAccessibleParameters | ( | Type::GetAccessibleParametersEvent * | event | ) | [protected, virtual] |
Process the "parameters ?" event.
This event is a request coming from the interactor to ask the id of available connectors of the object. To answer the object sends a valued event with the list of available connectors.
This message is the first in the protocol, it initializes the dialog between the interactor and an interactive object. If the object does not answer, it means that it is not an interactive object. The next event in the protocol is the "control take over" event (see processControlTakeOver) to take the control of some of the available connectors.
See "parameters ?" and "available connectors".
Referenced by loadExtensionParameters().
virtual bool OMK::Iii::InteractiveExtension::processGetCurrentValues | ( | Type::GetCurrentValuesEvent * | event | ) | [protected, virtual] |
Process the "get current values" event.
This valued event is a request coming from the interactor to get the current value of the parameters.
See "current values ?" and "current value".
Referenced by loadExtensionParameters().
virtual bool OMK::Iii::InteractiveExtension::processControlTakeOverAndGetCurrentValues | ( | Type::TakeOverAndGetCurrentValuesEvent * | event | ) | [protected, virtual] |
Process the "control take over" event.
This valued event is a request coming from the interactor to take the control of the connectors listed in the value of the event.
Before calling this event the interactor must ask which connectors are available with the "connector parameters ?" request (see processConnectorParameters). To release the control the interactor will use the "control release" event (see processControlTakeOver).
See "control take over".
Referenced by loadExtensionParameters().
Process the "control release" event.
This event is a request coming from the interactor to release the control of the connectors. If it is a valued event, the value lists the connectors to release, if not it will release all the connectors.
The connectors must be previously put under control by the "control take over" event (see processControlTakeOver).
See "control release".
Definition at line 306 of file OMKInteractiveExtension.cpp.
References _connectors, OMK::ExtensionT< SimulatedObjectType >::_owner, OMK::debugMsg(), OMK_DEBUG_III, OMTRACEID, and OMK::Event::sender.
Referenced by loadExtensionParameters().
00307 { 00308 ControlReleaseEvent* valuedEvent = dynamic_cast< ControlReleaseEvent* >( event ) ; 00309 if( valuedEvent ) 00310 { // Removes the specified connections 00311 const ControlReleasePrm& value = valuedEvent->value.getValue() ; 00312 for ( ControlReleasePrm::const_iterator id = value.begin() ; id != value.end() ; ++id ) 00313 { // Try to release each id sent by the interactor 00314 // Is the id in the connector list 00315 ConnectorsMap::iterator connector = _connectors.find( *id ) ; 00316 if( connector != _connectors.end() && connector->second->isConnected( event->sender ) ) 00317 { // Disconnection 00318 connector->second->disconnect( event->sender ) ; 00319 } 00320 else 00321 { 00322 OMTRACEID( OMK_DEBUG_III, ":-( Error in InteractiveExtension::processControlRelease for the " << OMK::debugMsg( _owner ) << std::endl 00323 << ">>> Unable to disconnect \"" << event->sender << "\" from \"" << *id << "\" because " 00324 << ( connector == _connectors.end() ? "the connector doesn't exist":"the interactor is not connected to the connector") << std::endl ) ; 00325 } 00326 } 00327 } 00328 else 00329 { // Removes all connections from this interactor 00330 for ( ConnectorsMap::const_iterator connector = _connectors.begin() ; connector != _connectors.end() ; ++connector ) 00331 { 00332 if( connector->second->isConnected( event->sender ) ) 00333 { 00334 connector->second->disconnect( event->sender ) ; 00335 } 00336 } 00337 } 00338 // Even if the disconnection has failed, the message is processed 00339 return true ; 00340 }
virtual bool OMK::Iii::InteractiveExtension::processControlFreeze | ( | Type::ControlFreezeEvent * | event | ) | [protected, virtual] |
Process the "control freeze" event.
This valued event is a request coming from the interactor to freeze the control of the connectors listed in the value of the event. A frozen connector is no more available for interaction. In that case, the answer to the "connector parameters ?" event will not include these connectors, and a "control take over" event will not work with this connector.
To unfreeze the connectors use the "control unfreeze" event (see processControlUnfreeze).
See "control freeze".
Referenced by loadExtensionParameters().
Process the "control unfreeze" event.
This event is a request coming from the interactor to unfreeze the control of the connectors.
See "control unfreeze".
Definition at line 369 of file OMKInteractiveExtension.cpp.
References _connectors, OMK::ExtensionT< SimulatedObjectType >::_owner, OMK::debugMsg(), OMK_DEBUG_III, OMTRACEID, and OMK::Event::sender.
Referenced by loadExtensionParameters().
00370 { 00371 ControlUnfreezeEvent* valuedEvent = dynamic_cast< ControlUnfreezeEvent* >( event ) ; 00372 if( valuedEvent ) 00373 { // Unfreezes the specified connections 00374 const ControlUnfreezePrm& value = valuedEvent->value.getValue() ; 00375 for ( ControlUnfreezePrm::const_iterator id = value.begin() ; id != value.end() ; ++id ) 00376 { // Try to release each id sent by the interactor 00377 // Is the id in the connector list 00378 ConnectorsMap::iterator connector = _connectors.find( *id ) ; 00379 if( connector != _connectors.end() && connector->second->isConnected( event->sender ) ) 00380 { // Change current access level 00381 connector->second->getAccessRule().resetCurrentLevel() ; 00382 } 00383 else 00384 { 00385 OMTRACEID( OMK_DEBUG_III, ":-( Error in InteractiveExtension::processControlUnfreeze for the " << OMK::debugMsg( _owner ) << std::endl 00386 << ">>> Unable to unfreeze \"" << event->sender << "\" from \"" << *id << "\" because " 00387 << ( connector == _connectors.end() ? "the connector doesn't exist":"the interactor is not connected to the connector") << std::endl ) ; 00388 } 00389 } 00390 } 00391 else 00392 { // Removes all connections from this interactor 00393 for ( ConnectorsMap::const_iterator connector = _connectors.begin() ; connector != _connectors.end() ; ++connector ) 00394 { 00395 if( connector->second->isConnected( event->sender ) ) 00396 { 00397 // connector->second->getAccessRule().unfreeze() ; 00398 } 00399 } 00400 } 00401 // Even if the disconnection has failed, the message is processed 00402 return true ; 00403 }
virtual bool OMK::Iii::InteractiveExtension::processNewValueAvailable | ( | Type::NewValueAvailableEvent * | event | ) | [protected, virtual] |
Process the "new value available" event.
This event is a signal coming from the interactor to connect a specified connector to the interactor output.
See "control unfreeze".
Referenced by loadExtensionParameters().
void InteractiveExtension::addConnector | ( | IConnector * | connector, | |
bool | postComputing | |||
) |
Method to add connectors.
The connector will be added the map of connectors.
Definition at line 166 of file OMKInteractiveExtension.cpp.
References _connectors, _postConnectors, _preConnectors, and OMK::Iii::IConnector::id().
Referenced by OMK::Iii::IConnector::IConnector().
00167 { 00168 _connectors.insert( std::pair< const Name, IConnector* >( connector->id(), connector ) ) ; 00169 00170 if( postComputing ) 00171 { 00172 _postConnectors.insert( std::pair< const Name, IConnector* >( connector->id(), connector ) ) ; 00173 } 00174 else 00175 { 00176 _preConnectors.insert( std::pair< const Name, IConnector* >( connector->id(), connector ) ) ; 00177 } 00178 }
IConnector * InteractiveExtension::getConnector | ( | const Name & | id | ) |
Method to get a connector.
[in] | id | The id of the connector to look for. |
Definition at line 181 of file OMKInteractiveExtension.cpp.
References _connectors.
Referenced by OMK::Iii::AssociatedConnectorT< Type >::loadParameters().
00182 { 00183 ConnectorsMap::iterator connector = _connectors.find( id ) ; 00184 return connector != _connectors.end() ? connector->second : 0 ; 00185 }
Connectors map.
Definition at line 217 of file OMKInteractiveExtension.h.
Referenced by addConnector(), getConnector(), loadExtensionParameters(), processControlRelease(), and processControlUnfreeze().
Definition at line 218 of file OMKInteractiveExtension.h.
Referenced by addConnector(), and preComputeParameters().
Definition at line 219 of file OMKInteractiveExtension.h.
Referenced by addConnector(), and postComputeParameters().
Definition at line 220 of file OMKInteractiveExtension.h.
Documentation generated on Mon Jun 9 11:46:04 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |