00001 00002 /************************************************************************/ 00003 /* This file is part of openMask(c) INRIA, CNRS, Universite de Rennes 1 */ 00004 /* 1993-2002, thereinafter the Software */ 00005 /* */ 00006 /* The Software has been developped within the Siames Project. */ 00007 /* INRIA, the University of Rennes 1 and CNRS jointly hold intellectual */ 00008 /* property rights */ 00009 /* */ 00010 /* The Software has been registered with the Agence pour la Protection */ 00011 /* des Programmes (APP) under registration number */ 00012 /* IDDN.FR.001.510008.00.S.P.2001.000.41200 */ 00013 /* */ 00014 /* This file may be distributed under the terms of the Q Public License */ 00015 /* version 1.0 as defined by Trolltech AS of Norway and appearing in */ 00016 /* the file LICENSE.QPL included in the packaging of this file. */ 00017 /* */ 00018 /* Licensees holding valid specific licenses issued by INRIA, CNRS or */ 00019 /* Universite Rennes 1 for the software may use this file in */ 00020 /* acordance with that specific license */ 00021 /************************************************************************/ 00022 00023 #include "OMKIConnectors.h" 00024 #include "OMKIAttribute.h" 00025 #include "OMKExtensibleSimulatedObject.h" 00026 #include "OMKParametersAccessor.inl" 00027 #include "OMKInteractiveExtension.h" 00028 #include "OMKIAccessRule.h" 00029 00030 namespace OMK 00031 { 00032 namespace Iii 00033 { 00034 //----------------------------------------------------------------- 00035 IConnector::IConnector( const Name& id, const Name& category, const Name& type, 00036 OMK::Type::AccessLevel accessLevel, bool freezable, 00037 ExtensibleSimulatedObject *owner ) 00038 : _id( id ), 00039 _category( category ), 00040 _type( type ), 00041 _accessRule( 0 ), 00042 _owner( owner ) 00043 { 00044 _accessRule = AccessRuleFactory::getInstance().create( "GrpLevel" )( 0 ) ; 00045 } 00046 //----------------------------------------------------------------- 00047 IConnector::IConnector( const Name& id, 00048 const Name& attributeId, 00049 const Name& type, 00050 InteractiveExtension *extension, 00051 const ConfigurationParameterDescriptor* node ) 00052 : _id( id ), 00053 _attributeId( attributeId ), 00054 _category(), 00055 _type( type ), 00056 _accessRule( 0 ), 00057 _owner( extension->getOwner() ), 00058 _interactiveExtension( extension ) 00059 { 00060 ParametersAccessor::get( node, "Category", _category ) ; 00061 00062 // Access rule 00063 const ConfigurationParameterDescriptor* accessRuleNode = 0 ; 00064 std::string accessRuleGrp ; 00065 Name accessRuleType( "GrpLevel" ) ; 00066 if( ParametersAccessor::get( node, "AccessRule", accessRuleNode ) ) 00067 { 00068 if( !dynamic_cast< const MultipleConfigurationParameter* >( accessRuleNode ) ) 00069 { // It is a name => Try to find the corresponding access rule definition 00070 // in the "AccessRules" node of the controller 00071 ParametersAccessor::get( node, "AccessRule", accessRuleGrp ) ; 00072 const ConfigurationParameterDescriptor* defaultAccessRulesNode = 0 ; 00073 ParametersAccessor::get( _owner->getController().getConfigurationParameters(), 00074 "AccessRules", defaultAccessRulesNode ) ; 00075 ParametersAccessor::get( defaultAccessRulesNode, accessRuleGrp, accessRuleNode ) ; 00076 } 00077 // else No name => Try to find a node which defines a local definition of the access rule 00078 } 00079 ParametersAccessor::get( accessRuleNode, "Class", accessRuleType ) ; 00080 _accessRule = AccessRuleFactory::getInstance().create( accessRuleType )( accessRuleNode ) ; 00081 00082 bool postCompute = _owner->getAttribute( _attributeId )->getOutput() != 0 ; 00083 ParametersAccessor::get( node, "PostCompute", postCompute ) ; 00084 // If there is a output we must use post processing 00085 _interactiveExtension->addConnector( this, postCompute ) ; 00086 } 00087 //----------------------------------------------------------------- 00088 void IConnector::SendControlTakenBy( const Name& newInteractor ) 00089 { 00090 for( std::list< Name >::const_iterator interactor = _toolsInUse.begin() ; 00091 interactor != _toolsInUse.end() ; 00092 ++interactor ) 00093 { 00094 _owner->sendValuedEvent( 00095 *interactor, 00096 EventId::CONTROL_TAKEN_BY, 00097 Type::ControlUpdatedType( Type::ControlUpdatedPrm( _id, newInteractor ) ) ) ; 00098 } 00099 } 00100 //----------------------------------------------------------------- 00101 void IConnector::SendControlReleased( const Name& interactor ) 00102 { 00103 _owner->sendValuedEvent( interactor, EventId::CONTROL_RELEASED, _id ) ; 00104 } 00105 //----------------------------------------------------------------- 00106 void IConnector::SendControlReleasedBy( const Name& oldInteractor ) 00107 { 00108 for( std::list< Name >::const_iterator interactor = _toolsInUse.begin() ; 00109 interactor != _toolsInUse.end() ; 00110 ++interactor ) 00111 { 00112 if( *interactor != oldInteractor ) 00113 { 00114 _owner->sendValuedEvent( 00115 *interactor, 00116 EventId::CONTROL_RELEASED_BY, 00117 Type::ControlUpdatedType( Type::ControlUpdatedPrm( _id, oldInteractor ) ) ) ; 00118 } 00119 } 00120 } 00121 //----------------------------------------------------------------- 00122 void IConnector::SendControlEnded( const Name& interactor ) 00123 { 00124 _owner->sendValuedEvent( interactor, EventId::CONTROL_ENDED, _id ) ; 00125 } 00126 //----------------------------------------------------------------- 00127 }// namespace Iii 00128 }// namespace OMK
Documentation generated on Mon Jun 9 11:45:56 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |