OMKAttribute.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_ATTRIBUTE_H
00024 #define OMK_ATTRIBUTE_H
00025 
00026 #include "OMKIAttribute.h"
00027 #include "OMKIAccessor.h"
00028 #include "OMKSimpleTypeT.h"
00029 #include "OMKEventTypeForAttributeT.h"
00030 
00031 namespace OMK  
00032 {
00033 template< typename T > class Output ;
00034 template< typename T > class Input ;
00035 
00036 
00037 //-----------------------------------------------------------------
00054   template< typename PrmType >
00055 class IAttributeBaseT : public IAttribute, public IAccessorT< PrmType >
00056 { 
00058 
00059 protected:
00062   IAttributeBaseT( const Name& id ) ;
00063 public:
00066   virtual ~IAttributeBaseT() ;
00068 
00070 
00071 public:
00074   virtual IAccessorT< PrmType >* getAccessor() { return  this ; }
00077   virtual const std::type_info& getTypeId() const { return typeid( PrmType ) ; }
00079 
00081 
00082 public:
00083   using IAttribute::loadParameters ;
00084 protected:
00089   virtual bool loadParameters( const ConfigurationParameterDescriptor * node, const std::string* aliasName ) ;
00091 
00093 
00094 public:
00108   virtual void getValueFromInput( PrmType& value, InputNT* input,       int deltaT = 0 ) const = 0 ;
00119   virtual void getValueFromInput( InputNT* input ) = 0 ;
00121 } ;
00122 
00123 //-----------------------------------------------------------------
00152 template< typename PrmType, typename ModelType, typename AccessorType >
00153 class IAttributeT : public IAttributeBaseT< PrmType >, public EventTypeForAttributeT< ModelType >
00154 { 
00155 public:
00156   typedef std::pair< Name, ModelType > IdAndValuePrm ;
00157   DECLARE_TYPE_EVENT_LISTENER( IdAndValuePrm, IdAndValue, EventTypeForAttributeT< ModelType > ) ;
00158   using IAttributeBaseT< PrmType >::getId ;
00160 
00161 protected:
00170   IAttributeT( const Name& id, const AccessorType& init ) ;
00171 public:
00175   virtual ~IAttributeT() ;
00177 
00179 
00180 public:
00181   using IAttribute::isUpdated ;
00182   using IAttribute::_updated ;
00185   virtual const std::type_info& getModelTypeId() const { return typeid( ModelType ) ; }
00190   virtual const PrmType& get() const 
00191   {
00192     return _accessor.AccessorType::get() ; 
00193   }
00198   virtual void set( const PrmType& value )
00199   {
00200     this->_updated = true ;
00201     _accessor.AccessorType::set( value ) ; 
00202   }
00203 protected:
00206   AccessorType _accessor ;
00208 
00210 
00211 public:
00214   virtual void createInput() ;
00221   virtual InputNT* getInput() ;
00228   Input< ModelType >* getInputT() ;
00234   virtual void createOutput() ;
00239   virtual OutputNT* getOutput() ;
00242   Output< ModelType >* getOutputT() ;
00243 protected:
00247   Input< ModelType >* _input ;
00251   Output< ModelType >* _output ;
00253 
00255 
00256 public:
00274   virtual void getValueFromInput() ;
00278   virtual void setValueToOutput() ;
00280 
00282 
00283 public:
00287   virtual void sendIdAndValue( const Name &receiver, const EventIdentifier& eventId, const Name &attributeId ) ;
00290   virtual void sendValue( const Name &receiver, const EventIdentifier& eventId ) ;
00294   virtual void fireIdAndValue( const EventIdentifier& eventId, const Name &attributeId ) ;
00298   virtual void fireValue( const EventIdentifier& eventId ) ;
00299 protected:
00307   bool processSetValueOf( ValuedEvent< ModelType > *e ) ;
00316   virtual bool processSetValue( IdAndValueEvent *e ) ;
00318 
00320 
00321 public:
00324   virtual void activateSetByEvent() ;
00327   virtual void activateSetByEventOf() ;
00329 
00332 
00333 public:
00340   virtual InputNT* createInput( const Name& name ) ;
00350   virtual void getValueFromInput( InputNT* input ) ;
00371   virtual void getValueFromInput( PrmType& value, InputNT* input, int deltaT = 0 ) const ;
00373 } ;
00374 
00375 //-----------------------------------------------------------------
00390 template< typename PrmType >
00391 class AttributeT : public IAttributeT< PrmType, OMK::Type::SimpleTypeT< PrmType >, AccessorT< PrmType > >
00392 { 
00394 
00395 public:
00398   AttributeT( const Name& id, const PrmType& value ) 
00399     : IAttributeT< PrmType, OMK::Type::SimpleTypeT< PrmType >, AccessorT< PrmType > >( id, AccessorT< PrmType >( value ) ) {}
00401   virtual ~AttributeT() {}
00403 
00404 
00405 
00406 
00407 
00408 
00409 
00410 
00411 
00412   PrmType& getRef() { return this->_accessor.operator PrmType&() ; }
00413 } ;
00414 
00415 //-----------------------------------------------------------------
00428 template< typename PrmType >
00429 class AttributeTypeT : public IAttributeT< PrmType, PrmType, AccessorT< PrmType > >
00430 { 
00432 
00433 public:
00436   AttributeTypeT( const Name& id, const PrmType& value ) 
00437     : IAttributeT< PrmType, PrmType, AccessorT< PrmType > >( id, AccessorT< PrmType >( value ) ) {}
00439   virtual ~AttributeTypeT() {}
00441 
00442   PrmType& getRef() { return this->_accessor.operator PrmType&() ; }
00443 } ;
00444 
00445 
00446 //-----------------------------------------------------------------
00478 template< typename PrmType, typename  PrmAccType >
00479 class AttributeAccT : public IAttributeT< PrmType, OMK::Type::SimpleTypeT< PrmType >, AccessorAccT< PrmType,  PrmAccType > >
00480 { 
00482 
00483 public:
00486   AttributeAccT( const Name& id, IAccessorT<  PrmAccType >* accessor ) 
00487     : IAttributeT< PrmType, OMK::Type::SimpleTypeT< PrmType >, AccessorAccT< PrmType,  PrmAccType > >( id, AccessorAccT< PrmType,  PrmAccType >( accessor ) ) {}
00489   virtual ~AttributeAccT() {}
00491 
00492 
00493 
00494 
00495 
00496 
00497 
00498   void setAccessor( IAccessorT< PrmAccType >* accessor )
00499   {
00500     this->_accessor.setAccessor( accessor ) ;
00501   }
00502 } ;
00503 
00504 //-----------------------------------------------------------------
00516 template< typename PrmType, typename  PrmAccType >
00517 class AttributeAccTypeT : public IAttributeT< PrmType, PrmType, AccessorAccT< PrmType,  PrmAccType > >
00518 { 
00520 
00521 public:
00524   AttributeAccTypeT( const Name& id, IAccessorT<  PrmAccType >* accessor ) 
00525     : IAttributeT< PrmType, PrmType, AccessorAccT< PrmType,  PrmAccType > >( id, AccessorAccT< PrmType,  PrmAccType >( accessor ) ) {}
00527   virtual ~AttributeAccTypeT() {}
00529 
00530 
00531 
00532 
00533 
00534 
00535 
00536   void setAccessor( IAccessorT< PrmAccType >* accessor )
00537   {
00538     this->_accessor.setAccessor( accessor ) ;
00539   }
00540 } ;
00541 
00542 
00543 
00544 //-----------------------------------------------------------------
00584 template< typename PrmType, typename ObjectType >
00585 class AttributeFctT : public IAttributeT< PrmType, OMK::Type::SimpleTypeT< PrmType >, AccessorFctT< PrmType, ObjectType > >
00586 { 
00588 
00589 public:
00592   AttributeFctT( const Name& id, ObjectType *object, 
00593                  typename AccessorFctT< PrmType, ObjectType >::SetMethod setMethod, 
00594                  typename AccessorFctT< PrmType, ObjectType >::GetMethod getMethod ) 
00595     : IAttributeT< PrmType, OMK::Type::SimpleTypeT< PrmType >, AccessorFctT< PrmType, ObjectType > >
00596     ( id, AccessorAccT< PrmType, ObjectType >( object, setMethod, getMethod ) ) {}
00598   virtual ~AttributeFctT() {}
00600 } ;
00601 
00602 //-----------------------------------------------------------------
00615 template< typename PrmType, typename ObjectType >
00616 class AttributeFctTypeT : public IAttributeT< PrmType, PrmType, AccessorFctT< PrmType, ObjectType > >
00617 { 
00619 
00620 public:
00623   AttributeFctTypeT( const Name& id, ObjectType *object, 
00624                      typename AccessorFctT< PrmType, ObjectType >::SetMethod setMethod, 
00625                      typename AccessorFctT< PrmType, ObjectType >::GetMethod getMethod ) 
00626     : IAttributeT< PrmType, PrmType, AccessorFctT< PrmType, ObjectType > >
00627     ( id, AccessorAccT< PrmType, ObjectType >( object, setMethod, getMethod ) ) {}
00629   virtual ~AttributeFctTypeT() {}
00631 } ;
00632 
00633 
00634 //-----------------------------------------------------------------
00635 
00636 }// namespace OMK
00637 
00638 #include "OMKAttribute.inl"
00639 
00640 #endif // defined OMK_ATTRIBUTE_H

logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007