OMKConnectors.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_CONNECTORS_H
00024 #define OMK_III_CONNECTORS_H
00025 
00026 #include "OMKIConnectors.h"
00027 
00028 
00029 #define DECLARE_TEMPLATE_CONNECTOR_FACTORY( ConnectorClass, Type ) \
00030 public: \
00031  \
00032   friend class OMK::Iii::ConnectorCreatorT< ConnectorClass< Type > > ; \
00033  \
00034   static OMK::Name OMK_CLASS_ID ; \
00035  \
00036   static const bool REGISTERED_IN_CONNECTOR_FACTORY ; \
00037 protected: \
00038  \
00040         ConnectorClass( const Name& id, \
00041                   const OMK::Name& attributeId, \
00042                   OMK::Iii::InteractiveExtension *extension, \
00043                   const OMK::ConfigurationParameterDescriptor* node ) ; \
00044 public: \
00045         virtual ~ConnectorClass() 
00046 
00047 #define DECLARE_CONNECTOR_FACTORY( ConnectorClass, Type ) \
00048 public: \
00049  \
00050   friend class OMK::Iii::ConnectorCreatorT< ConnectorClass > ; \
00051  \
00052   static OMK::Name OMK_CLASS_ID ; \
00053  \
00054   static const bool REGISTERED_IN_CONNECTOR_FACTORY ; \
00055 protected: \
00056  \
00058         ConnectorClass( const Name& id, \
00059                   const OMK::Name& attributeId, \
00060                   OMK::Iii::InteractiveExtension *extension, \
00061                   const OMK::ConfigurationParameterDescriptor* node ) ; \
00062 public: \
00063         virtual ~ConnectorClass() 
00064 
00065 
00066 #define REGISTER_TEMPLATE_CONNECTOR_FACTORY( ConnectorClass, Type )\
00067   /* Factory */ \
00068   template <> OMK::Name ConnectorClass< Type >::OMK_CLASS_ID( std::string( #ConnectorClass ) + typeid( Type ).name() ) ; \
00069   template <> const bool ConnectorClass< Type >::REGISTERED_IN_CONNECTOR_FACTORY( OMK::ConnectorFactory::getInstance().registerCreator< OMK::Iii::ConnectorCreatorT< ConnectorClass< Type > > >( ConnectorClass< Type >::OMK_CLASS_ID ) )
00070 
00071 #define REGISTER_CONNECTOR_FACTORY( ConnectorClass, Type )\
00072   /* Factory */ \
00073   template <> OMK::Name ConnectorClass::OMK_CLASS_ID( std::string( #ConnectorClass ) + typeid( Type ).name() ) ; \
00074   template <> const bool ConnectorClass::REGISTERED_IN_CONNECTOR_FACTORY( OMK::ConnectorFactory::getInstance().registerCreator< OMK::Iii::ConnectorCreatorT< ConnectorClass > > ( ConnectorClass::OMK_CLASS_ID ) )
00075 
00076 
00077 namespace OMK  
00078 {
00079 class InputNT ;
00080 template< typename Type > class IAttributeBaseT ;
00081 class ExtensibleSimulatedObject ;
00082 namespace Type { class Transform ; }
00083 namespace Iii
00084 {
00085 template< typename TypeOut, typename TypeIn > class IConvertorT ;
00086 
00087 //-----------------------------------------------------------------
00102 template< typename Type >
00103 class SimpleConnectorT : public IConnector
00104 { 
00105   DECLARE_TEMPLATE_CONNECTOR_FACTORY( SimpleConnectorT, Type ) ;
00106 public:
00108 
00109 
00110 
00111 
00112   virtual bool isConnected( const Name& interactor ) const ;
00119   virtual bool preConnect( const Name& interactor, const OMK::Type::AccessGroupLevel& freeze, OMK::Type::AccessLevel tool ) ;
00120   virtual bool connect( const Name& interactor, const Name& outputName ) ;
00125   virtual void disconnect( const Name& interactor ) ;
00130   virtual void disconnect() ;
00135   virtual void updateParameter() const ;
00139   virtual void sendValue( const Name& receiver ) const ;
00141 protected:
00143   InputNT* _input ;
00145   IAttributeBaseT< Type >* _attribute;
00147   IConvertorT< Type, Type >* _convertor ;
00148 } ;
00149 //-----------------------------------------------------------------
00166 template< typename Type >
00167 class SharedConnectorT : public IConnector
00168 { 
00169   DECLARE_TEMPLATE_CONNECTOR_FACTORY( SharedConnectorT, Type ) ;
00170 public:
00172   typedef std::map< const Name, InputNT* > MapInput ;
00174 
00175 
00176 
00177   virtual bool isConnected( const Name& interactor ) const ;
00184   virtual bool preConnect( const Name& interactor,const OMK::Type::AccessGroupLevel& freezeLevel, OMK::Type::AccessLevel tool ) ;
00185   virtual bool connect( const Name& interactor, const Name& outputName ) ;
00189   virtual void disconnect( const Name& interactor ) ;
00193   virtual void disconnect() ;
00198   virtual void updateParameter() const ;
00202   virtual void sendValue( const Name& receiver ) const ;
00204 protected:
00206   MapInput _inputs ;
00208   IAttributeBaseT< Type >* _attribute ;
00210   IConvertorT< Type, std::vector< Type > >* _convertor ;
00211 } ;
00212 //-----------------------------------------------------------------
00213 
00214 
00215 //-----------------------------------------------------------------
00255 template< typename Type >
00256 class AssociatedConnectorT : public OMK::Iii::SimpleConnectorT< Type >
00257 { 
00258   DECLARE_TEMPLATE_CONNECTOR_FACTORY( AssociatedConnectorT, Type ) ;
00259 public:
00260   virtual bool preConnect( const Name& interactor, const OMK::Type::AccessGroupLevel& freezeLevel, OMK::Type::AccessLevel tool ) ;
00261   virtual bool loadParameters( const ConfigurationParameterDescriptor* node ) ;
00262 protected:
00263   IConnector *_associatedConnector ;
00264 } ;
00265 
00266 #if defined _MSC_VER
00267 REGISTER_TEMPLATE_CONNECTOR_FACTORY( SimpleConnectorT, OMK::Type::Transform ) ;
00268 REGISTER_TEMPLATE_CONNECTOR_FACTORY( SimpleConnectorT, int ) ;
00269 REGISTER_TEMPLATE_CONNECTOR_FACTORY( SimpleConnectorT, float ) ;
00270 REGISTER_TEMPLATE_CONNECTOR_FACTORY( SimpleConnectorT, bool ) ;
00271 
00272 REGISTER_TEMPLATE_CONNECTOR_FACTORY( SharedConnectorT, OMK::Type::Transform ) ;
00273 REGISTER_TEMPLATE_CONNECTOR_FACTORY( SharedConnectorT, int ) ;
00274 REGISTER_TEMPLATE_CONNECTOR_FACTORY( SharedConnectorT, float ) ;
00275 
00276 REGISTER_TEMPLATE_CONNECTOR_FACTORY( AssociatedConnectorT, OMK::Type::Transform ) ;
00277 REGISTER_TEMPLATE_CONNECTOR_FACTORY( AssociatedConnectorT, int ) ;
00278 REGISTER_TEMPLATE_CONNECTOR_FACTORY( AssociatedConnectorT, float ) ;
00279 REGISTER_TEMPLATE_CONNECTOR_FACTORY( AssociatedConnectorT, bool ) ;
00280 #endif //defined _MSC_VER
00281 
00282   }// namespace Iii
00283 }// namespace OMK
00284 
00285 #endif // defined OMK_III_CONNECTORS_H
00286 

logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007