#include <OMKConnectors.h>
Inheritance diagram for OMK::Iii::SharedConnectorT< Type >:
Public Types | |
typedef std::map< const Name, InputNT * > | MapInput |
Type for map of inputs. | |
Public Member Functions | |
Redefined interface. | |
virtual bool | isConnected (const Name &interactor) const |
Returns if the interactor is connected or not. | |
virtual bool | preConnect (const Name &interactor, const OMK::Type::AccessGroupLevel &freezeLevel, OMK::Type::AccessLevel tool) |
Connection method. | |
virtual bool | connect (const Name &interactor, const Name &outputName) |
virtual void | disconnect (const Name &interactor) |
Disconnection method. | |
virtual void | disconnect () |
Disconnection method. | |
virtual void | updateParameter () const |
Update method. | |
virtual void | sendValue (const Name &receiver) const |
Sending the current value. | |
Protected Attributes | |
MapInput | _inputs |
The pointer on the input to get the value from the interactor. | |
IAttributeBaseT< Type > * | _attribute |
The attribute interface. | |
IConvertorT< Type, std::vector< Type > > * | _convertor |
The convertor from inputs to the attribute. | |
Private Member Functions | |
DECLARE_TEMPLATE_CONNECTOR_FACTORY (SharedConnectorT, Type) |
This connector is a template class, the parameter is:
Definition at line 165 of file OMKConnectors.h.
typedef std::map< const Name, InputNT* > OMK::Iii::SharedConnectorT< Type >::MapInput |
OMK::Iii::SharedConnectorT< Type >::DECLARE_TEMPLATE_CONNECTOR_FACTORY | ( | SharedConnectorT< Type > | , | |
Type | ||||
) | [private] |
bool OMK::Iii::SharedConnectorT< T >::isConnected | ( | const Name & | interactor | ) | const [virtual] |
Returns if the interactor is connected or not.
Implements OMK::Iii::IConnector.
Definition at line 214 of file OMKConnectors.inl.
References OMK::Iii::SharedConnectorT< Type >::_inputs.
00215 { 00216 typename MapInput::const_iterator input = _inputs.find( interactor ) ; 00217 return input != _inputs.end() ; 00218 }
virtual bool OMK::Iii::SharedConnectorT< Type >::preConnect | ( | const Name & | interactor, | |
const OMK::Type::AccessGroupLevel & | freezeLevel, | |||
OMK::Type::AccessLevel | tool | |||
) | [virtual] |
Connection method.
This method creates an input in its associated interactive object and connects it to the output of the interactor.
The name of the created input is the concatenation of the iterator name and its output.
See IConnector::connect.
Implements OMK::Iii::IConnector.
bool OMK::Iii::SharedConnectorT< T >::connect | ( | const Name & | interactor, | |
const Name & | outputName | |||
) | [virtual] |
Implements OMK::Iii::IConnector.
Definition at line 237 of file OMKConnectors.inl.
References OMK::Iii::SharedConnectorT< Type >::_attribute, OMK::Iii::IConnector::_id, OMK::Iii::SharedConnectorT< Type >::_inputs, OMK::Iii::IConnector::_owner, OMK::Iii::IConnector::_toolsOnStandby, OMK::InputNT::connect(), OMK::IAttribute::createInput(), OMK::debugMsg(), OMK::SimulatedObject::deleteInput(), OMK::Name::getString(), OMK_DEBUG_III, and OMTRACEID.
00238 { 00239 bool ok = false ; 00240 Name inputName ; 00241 InputNT* input = 0 ; 00242 std::list< Name >::iterator onStandby = std::find( _toolsOnStandby.begin(), _toolsOnStandby.end(), interactor ) ; 00243 if( onStandby != _toolsOnStandby.end() ) 00244 { 00245 // creates the name's input 00246 inputName = interactor.getString() + outputName.getString() ; 00247 // creates the input in the interactive object 00248 input = _attribute->createInput( inputName ) ; 00249 // connects it to the interactor output 00250 ok = input->connect( interactor, outputName ) ; 00251 } 00252 if( ok ) 00253 { // successful connection => add the input to the list 00254 _inputs.insert( std::pair< const Name, InputNT* >( interactor, input ) ) ; 00255 _toolsOnStandby.erase( onStandby ) ; 00256 } 00257 else 00258 { // Unsuccessful connection => delete the input 00259 OMTRACEID( OMK_DEBUG_III, ":-( Error in SharedConnectorT< \"" << _id.getString() 00260 << "\" >:: connect for the " << OMK::debugMsg( _owner ) << std::endl 00261 << ">>> The interactor \"" << interactor.getString() << "\" cannot be connected !" ) ; 00262 if( !input ) 00263 { 00264 _owner->deleteInput( inputName ) ; 00265 } 00266 } 00267 return ok ; 00268 }
void OMK::Iii::SharedConnectorT< T >::disconnect | ( | const Name & | interactor | ) | [virtual] |
Disconnection method.
Disconnects the input and destroys it.
See IConnector::disconnect( const Name& interactor ).
Implements OMK::Iii::IConnector.
Definition at line 271 of file OMKConnectors.inl.
References OMK::Iii::IConnector::_accessRule, OMK::Iii::IConnector::_id, OMK::Iii::SharedConnectorT< Type >::_inputs, OMK::Iii::IConnector::_owner, OMK::Iii::IConnector::_toolsInUse, OMK::Iii::IConnector::_toolsOnStandby, OMK::debugMsg(), OMK::SimulatedObject::deleteInput(), OMK::Name::getString(), OMK_DEBUG_III, OMTRACEID, OMK::Iii::IAccessRule::resetCurrentLevel(), OMK::Iii::IConnector::SendControlReleased(), and OMK::Iii::IConnector::SendControlReleasedBy().
00272 { 00273 // Only this iterator will be disconnected => find it 00274 std::list< Name >::iterator inUse = std::find( _toolsInUse.begin(), _toolsInUse.end(), interactor ) ; 00275 if( inUse != _toolsInUse.end() ) 00276 { 00277 // Inform interactor 00278 SendControlReleased( interactor ) ; 00279 // Clean the lists => no more interactor in them 00280 _toolsInUse.erase( inUse ) ; 00281 std::list< Name >::iterator onStanby = std::find( _toolsOnStandby.begin(), _toolsOnStandby.end(), interactor ) ; 00282 if( onStanby != _toolsOnStandby.end() ) _toolsOnStandby.erase( onStanby ) ; 00283 // Informs every other interactor in use or standby 00284 SendControlReleasedBy( interactor ) ; 00285 // find the input connected to the interactor, disconnects and deletes it 00286 typename MapInput::iterator input = _inputs.find( interactor ) ; 00287 if( input != _inputs.end() ) 00288 { 00289 input->second->disconnect() ; 00290 _owner->deleteInput( input->second->getName() ) ; 00291 _inputs.erase( input ) ; 00292 if( _inputs.empty() ) _accessRule->resetCurrentLevel() ; // unfreeze if necessary 00293 } 00294 } 00295 else 00296 { 00297 OMTRACEID( OMK_DEBUG_III, ":-( Error in SharedConnectorT< \"" << _id.getString() 00298 << "\" >:: disconnect for the " << OMK::debugMsg( _owner ) << std::endl 00299 << ">>> The interactor \"" << interactor.getString() << "\" is not one of those which are connected !" ) ; 00300 } 00301 }
void OMK::Iii::SharedConnectorT< T >::disconnect | ( | ) | [virtual] |
Disconnection method.
Disconnects all the inputs and destroys them.
See IConnector::disconnect().
Implements OMK::Iii::IConnector.
Definition at line 304 of file OMKConnectors.inl.
References OMK::Iii::IConnector::_accessRule, OMK::Iii::SharedConnectorT< Type >::_inputs, OMK::Iii::IConnector::_owner, OMK::Iii::IConnector::_toolsInUse, OMK::Iii::IConnector::_toolsOnStandby, OMK::SimulatedObject::deleteInput(), OMK::Iii::IAccessRule::resetCurrentLevel(), and OMK::Iii::IConnector::SendControlEnded().
00305 { 00306 // Inform every connected interactor 00307 for ( std::list< Name >::const_iterator interactor = _toolsInUse.begin() ; interactor != _toolsInUse.end() ; ++interactor ) 00308 { 00309 SendControlEnded( *interactor ) ; 00310 } 00311 // All the iterators will be disconnected 00312 // disconnects and deletes all the inputs and clear the map 00313 for ( typename MapInput::const_iterator i = _inputs.begin() ; i != _inputs.end() ; ++i ) 00314 { 00315 i->second->disconnect() ; 00316 _owner->deleteInput( i->second->getName() ) ; 00317 } 00318 _inputs.clear() ; 00319 _toolsOnStandby.clear() ; 00320 _toolsInUse.clear() ; 00321 _accessRule->resetCurrentLevel() ; // unfreeze if necessary 00322 }
void OMK::Iii::SharedConnectorT< T >::updateParameter | ( | ) | const [virtual] |
Update method.
The method gets the values read from the associated inputs and gives them to the object which updates its parameter.
See IConnector::updateParameter.
Implements OMK::Iii::IConnector.
Definition at line 325 of file OMKConnectors.inl.
References OMK::Iii::SharedConnectorT< Type >::_attribute, OMK::Iii::SharedConnectorT< Type >::_convertor, OMK::Iii::SharedConnectorT< Type >::_inputs, OMK::Iii::IConvertorT< TypeOut, TypeIn >::convert(), OMK::IAccessorT< T >::get(), OMK::IAttributeBaseT< PrmType >::getValueFromInput(), and OMK::IAccessorT< T >::set().
00326 { 00327 // if at least one input is connected, it updates the parameter 00328 if( _inputs.size() ) 00329 { 00330 // Creating a vector with the appropriate size 00331 std::vector< T > values( _inputs.size() ) ; 00332 // Retrieve the value in the inputs 00333 int j = 0 ; 00334 for ( typename MapInput::const_iterator i = _inputs.begin() ; 00335 i != _inputs.end() ; 00336 ++i, j++ ) 00337 { 00338 _attribute->getValueFromInput( values[j], i->second ) ; 00339 } 00340 // Update the parameter 00341 if( _convertor ) 00342 { 00343 T valueOut = _attribute->get() ; 00344 _convertor->convert( valueOut, values ) ; 00345 _attribute->set( valueOut ) ; 00346 } 00347 } 00348 }
void OMK::Iii::SharedConnectorT< T >::sendValue | ( | const Name & | receiver | ) | const [virtual] |
Sending the current value.
Call by EventInteractorListener::processGetParameters to send the current value of the parameter. See the protocol
Implements OMK::Iii::IConnector.
Definition at line 351 of file OMKConnectors.inl.
References OMK::Iii::SharedConnectorT< Type >::_attribute, OMK::Iii::IConnector::_id, OMK::EventId::CURRENT_VALUE, and OMK::IAttribute::sendIdAndValue().
00352 { 00353 _attribute->sendIdAndValue( receiver, EventId::CURRENT_VALUE, _id ) ; 00354 }
MapInput OMK::Iii::SharedConnectorT< Type >::_inputs [protected] |
The pointer on the input to get the value from the interactor.
Definition at line 204 of file OMKConnectors.h.
Referenced by OMK::Iii::SharedConnectorT< Type >::connect(), OMK::Iii::SharedConnectorT< Type >::disconnect(), OMK::Iii::SharedConnectorT< Type >::isConnected(), and OMK::Iii::SharedConnectorT< Type >::updateParameter().
IAttributeBaseT< Type >* OMK::Iii::SharedConnectorT< Type >::_attribute [protected] |
The attribute interface.
Definition at line 206 of file OMKConnectors.h.
Referenced by OMK::Iii::SharedConnectorT< Type >::connect(), OMK::Iii::SharedConnectorT< Type >::sendValue(), and OMK::Iii::SharedConnectorT< Type >::updateParameter().
IConvertorT< Type, std::vector< Type > >* OMK::Iii::SharedConnectorT< Type >::_convertor [protected] |
The convertor from inputs to the attribute.
Definition at line 208 of file OMKConnectors.h.
Referenced by OMK::Iii::SharedConnectorT< Type >::updateParameter().
Documentation generated on Mon Jun 9 11:46:04 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |