OMKIConnectors.h

Go to the documentation of this file.
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 #if !defined _OMK_III_ICONNECTORS_H_
00024 #define _OMK_III_ICONNECTORS_H_
00025 
00026 #include "OMKName.h"
00027 #include <map>
00028 #include <list>
00029 #include "OMKTracer.h"
00030 #include "OBTPrototypeFactory.h"
00031 #include "OMKInteraction.h"
00032 #include "OMKException.h"
00033 #include "OMKConfigurationParameterDescriptor.h"
00034 #include "OMKIAccessRule.h"
00035 
00036 template< typename T > class Input ;
00037 namespace OMK  
00038 {
00039   class ExtensibleSimulatedObject ;
00040   namespace Iii
00041   {
00042 
00043 // Predefined classes
00044 class InteractiveSimulatedObject ;
00045 class InteractiveExtension ;
00046 
00047 //-----------------------------------------------------------------
00060 class OMKIII_API IConnector
00061 { 
00063 
00064 protected:
00067   IConnector( const Name& id, const Name& category, const Name& type,
00068               OMK::Type::AccessLevel accessLevel, bool freezable, 
00069               ExtensibleSimulatedObject *owner ) ;
00078   IConnector( const Name& id, 
00079               const Name& attributeId, 
00080               const Name& type,
00081               InteractiveExtension *extension, 
00082               const ConfigurationParameterDescriptor* node ) ;
00083 public:
00085   virtual ~IConnector() {}
00087 
00088 
00089 public:
00096   virtual bool loadParameters( const ConfigurationParameterDescriptor* node ) { return true ; }
00100   virtual bool isConnected( const Name& interactor ) const = 0 ;
00109   virtual bool preConnect( const Name& interactor, const OMK::Type::AccessGroupLevel& freezeLevel, OMK::Type::AccessLevel toolLevel ) = 0 ;
00110   virtual bool connect( const Name& interactor, const Name& outputName ) = 0 ;
00117   virtual void disconnect( const Name& interactor ) = 0 ;
00122   virtual void disconnect() = 0 ;
00126   virtual void updateParameter() const = 0 ;
00130   virtual void sendValue( const Name& receiver ) const = 0 ;
00133   const Name& id() const { return _id ; }
00136   const Name& category() const { return _category ; }
00139   const Name& type() const { return _type ; }
00142   const IAccessRule& getAccessRule() const { return *_accessRule ; }
00143   IAccessRule& getAccessRule() { return *_accessRule ; }
00145   std::list< Name >& getToolsInUse() { return _toolsInUse ; }
00149   const std::list< Name >& getToolsInUse() const { return _toolsInUse ; }
00151   void addToolInUse( const Name& toolId ) { _toolsInUse.push_back( toolId ) ; }
00152 
00154 protected:
00159   Name _id ;
00161   Name _attributeId ;
00167   Name _category ;
00171   Name _type ;
00177   IAccessRule* _accessRule ;
00179   std::list< Name > _toolsInUse ;
00181   std::list< Name > _toolsOnStandby ;
00183   ExtensibleSimulatedObject *_owner ;
00185   InteractiveExtension * _interactiveExtension ;
00186   void SendControlTakenBy( const Name& newInteractor ) ;
00187   void SendControlReleased( const Name& interactor ) ;
00188   void SendControlReleasedBy( const Name& oldInteractor ) ;
00189   void SendControlEnded( const Name& interactor ) ;
00190 } ;
00191 //-----------------------------------------------------------------
00192 
00193 //-----------------------------------------------------------------------------
00201 class OMKIII_API ConnectorCreator
00202 {
00203 public:
00204   virtual ~ConnectorCreator() {}
00205   virtual IConnector* operator()( const Name& id, 
00206                                   const Name& attributeId, 
00207                                   InteractiveExtension *extension,
00208                                   const ConfigurationParameterDescriptor* node ) const
00209   {
00210     OMERROR( "Creator is not registered for \"" << id << "\"" << std::endl << *node ) ;
00211     throw Exception( "Creator is not registered" ) ;
00212     return 0 ;
00213   }
00214 } ;
00215 
00216 //-----------------------------------------------------------------------------
00222 template <class T>
00223 class ConnectorCreatorT : public ConnectorCreator
00224 {
00225 public:
00226         IConnector* operator()( const Name& id, 
00227                           const Name& attributeId, 
00228                           InteractiveExtension *extension,
00229                           const ConfigurationParameterDescriptor* node ) const
00230         {
00231                 return new T( id, attributeId, extension, node ) ;
00232         }
00233 } ;
00234 
00235 
00236 
00237   }// namespace Iii
00238 
00239 //-----------------------------------------------------------------------------
00308 typedef OBT::Singleton< OBT::PrototypeFactory< OMK::Name, Iii::ConnectorCreator > > ConnectorFactory ;
00309 }// namespace OMK
00310 
00311 template class OMKIII_API OBT::PrototypeFactory< OMK::Name, OMK::Iii::ConnectorCreator > ;
00312 template class OMKIII_API OBT::Singleton< OBT::PrototypeFactory< OMK::Name, OMK::Iii::ConnectorCreator > > ;
00313 
00314 #endif // defined _OMK_III_ICONNECTORS_H_

logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007