OMKIAttribute.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_IATTRIBUTE_H
00024 #define OMK_IATTRIBUTE_H
00025 
00026 #include "OMKEventIdentifier.h"
00027 #include "OMKSimpleTypeT.h"
00028 #include <string>
00029 #include <map>
00030 #include "OMKValuedEvent.h"
00031 
00032 namespace OMK  
00033 {
00034 template< class CallerClass, class PrmType > class ValuedEventListenerCallBack ;
00035 class ConfigurationParameterDescriptor ;
00036 class EventListener ;
00037 class Event ;
00038 class InputNT ;
00039 class OutputNT ;
00040 namespace EventId
00041 {
00043 
00044 
00045 
00046 
00047 
00048 extern EventIdentifier OMK_API CURRENT_ATTRIBUTE_VALUE ;
00057 extern EventIdentifier OMK_API getConnectToEventId( const std::string& id ) ;
00064 extern EventIdentifier OMK_API getCurrentValueEventId( const std::string& id ) ;
00073 extern EventIdentifier OMK_API getDisconnectEventId( const std::string& id ) ;
00080 extern EventIdentifier OMK_API getGetValueEventId( const std::string& id ) ;
00082 } 
00083   class ExtensibleSimulatedObject ;
00084 //-----------------------------------------------------------------
00190 class OMK_API IAttribute
00191 { 
00193 
00194 protected:
00200   IAttribute( const Name& id ) ;
00201 public:
00204   virtual ~IAttribute() ;
00206 
00208 
00209 public:
00210 
00213   const ExtensibleSimulatedObject* const getOwner() const ;
00214 
00215 private:
00218   friend class ExtensibleSimulatedObject ;
00230   void setOwner( ExtensibleSimulatedObject* owner, bool withOutput ) ;
00231 protected:
00232 
00236   ExtensibleSimulatedObject* _owner ;
00238 
00240 
00241 public:
00247   virtual const std::type_info& getTypeId() const = 0 ;
00253   virtual const std::type_info& getModelTypeId() const = 0 ;
00254   std::pair< std::string, std::string > getTypes() const
00255   {
00256     return std::pair< std::string, std::string >( getTypeId().name(), getModelTypeId().name() ) ;
00257   }
00260   const Name& getId() const ;
00261 protected:
00266   Name _id ;
00268 
00270 
00271   public:
00273     bool isUpdated() const { return _updated ; }
00275     void resetUpdated() { _updated = false ; }
00276   protected:
00281     bool _updated ;
00283 
00285 
00286 public:
00296   bool loadParameters( const ConfigurationParameterDescriptor * node ) 
00297   {
00298     return loadParameters( node, 0 ) ;
00299   }
00359   bool loadParameters( const ConfigurationParameterDescriptor * node, const std::string& aliasName ) 
00360   {
00361     return loadParameters( node, &aliasName ) ;
00362   }
00363 protected:
00371   virtual bool loadParameters( const ConfigurationParameterDescriptor * node, const std::string* aliasName ) ;
00373 
00375 
00376 public:
00382   virtual void createInput() = 0 ;
00388   virtual InputNT* getInput() = 0 ;
00397   virtual void createOutput() = 0 ;
00403   virtual OutputNT* getOutput() = 0 ;
00405 
00407 
00408 public:
00418   virtual void getValueFromInput() = 0 ;
00426   virtual void setValueToOutput() = 0 ;
00428 
00430 
00431 public:
00438   typedef std::pair< Name, Name > ConnectToPrm ;
00442   DECLARE_TYPE_EVENT_LISTENER( ConnectToPrm, ConnectTo, IAttribute ) ;
00443 public:
00450   bool connectTo( const Name &objectName, const Name &outputName ) ;
00452   void disconnect() ;
00453 protected:
00458   bool processConnectTo( ConnectToEvent *e ) ;
00463   bool processDisconnect( Event* e ) ;
00467   EventListener* _connectToListener ;
00471   EventListener* _disconnectListener ;
00474   const EventIdentifier _connectToId ;
00477   const EventIdentifier _disconnectId ;
00479 
00481 
00482 public:
00494   virtual void sendIdAndValue( const Name &receiver, const EventIdentifier& eventId, const Name &attributeId ) = 0 ;
00503   virtual void sendValue( const Name &receiver, const EventIdentifier& eventId ) = 0 ;
00517   void sendValueTo( const Name &receiver, const Name& attributeId, bool genericId ) ;
00528   void sendValueOf( const Name &receiver, bool genericId ) ;
00539   virtual void fireIdAndValue( const EventIdentifier& eventId, const Name &attributeId ) = 0 ;
00548   virtual void fireValue( const EventIdentifier& eventId ) = 0 ;
00561   void fireValueTo( const Name &attributeId, bool genericId ) ;
00572   void fireValueOf( bool genericId ) ;
00573 protected:
00578   bool processGetValue( Event* e ) ;
00582   EventListener* _getValueListener ;
00591   EventListener* _currentValueListener ;
00599   EventListener* _currentValueOfListener ;
00602   const EventIdentifier _getValueId ;
00605   const EventIdentifier _currentValueOfId ;
00607 
00609 
00610 public:
00615   void activateConnectByEvent() ;
00623   void activateConnectBySignal( const Name& emitter = Name() ) ;
00627   void activateGetByEvent() ;
00634   void activateGetBySignal( const Name& emitter = Name() ) ;
00641   virtual void activateSetByEvent() = 0 ;
00648   virtual void activateSetByEventOf() = 0 ;
00661   void activateSetBySignal( const Name& emitter = Name() ) ;
00674   void activateSetBySignalOf( const Name& emitter = Name() ) ;
00676 
00679 
00680 public:
00690   virtual InputNT* createInput( const Name& name ) = 0 ;
00700   virtual void getValueFromInput( InputNT* input ) = 0 ;
00702 } ;
00703 //-----------------------------------------------------------------
00704 
00705 inline const Name& IAttribute::getId() const
00706 { 
00707   return _id ; 
00708 }
00709 
00710 
00711 }// namespace OMK
00712 
00713 #endif // defined OMK_IATTRIBUTE_H

logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007