OMKReferenceObjectHandle.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of openMask © INRIA, CNRS, Universite de Rennes 1 1993-2002, thereinafter the Software
00003  * 
00004  * The Software has been developped within the Siames Project. 
00005  * INRIA, the University of Rennes 1 and CNRS jointly hold intellectual property rights
00006  * 
00007  * The Software has been registered with the Agence pour la Protection des
00008  * Programmes (APP) under registration number IDDN.FR.001.510008.00.S.P.2001.000.41200
00009  *
00010  * This file may be distributed under the terms of the Q Public License
00011  * version 1.0 as defined by Trolltech AS of Norway and appearing in the file
00012  * LICENSE.QPL included in the packaging of this file.
00013  *
00014  * Licensees holding valid specific licenses issued by INRIA, CNRS or Université de Rennes 1 
00015  * for the software may use this file in accordance with that specific license 
00016  *
00017  */
00018 #ifndef OMKReferenceObjectHandleHEADER
00019 #define OMKReferenceObjectHandleHEADER
00020 
00021 #include <OMKObjectHandle.h>
00022 #include <OMKNameToPointerMap.h>
00023 #include "OMKSignalDispatcher.h"
00024 
00025 #include "OMKEventIdentifier.h"
00026 #include <list>
00027 namespace OMK 
00028 { 
00029 class Controller ;
00030 class EventListener ; 
00031 class Scheduler ; 
00037 class OMK_API ReferenceObjectHandle: public ObjectHandle
00038 {
00039 public:   
00045    ReferenceObjectHandle( SimulatedObject & object, Controller & controller, SignalDispatcher * signalDispatcher = 0 );
00046 
00047 public:
00050    virtual ~ReferenceObjectHandle () ;
00051    
00054    virtual void init () ;
00055 
00057    virtual void initAfterMorphose () ;
00058    virtual void setMigrationCaseToTrue () ;
00059    virtual void setMorphosisPhaseTrue () ;
00064    virtual void compute() ;
00065 
00067    virtual void processEvents () ;
00068 
00072    virtual void receiveEvent (const Event & event) ;
00073 
00077    virtual void receiveEvent (Event * event) ;
00078 
00082    virtual void registerEventListenerForEvent ( EventListener & eventListener, 
00083                                                 const EventIdentifier & eventId ) ;
00084 
00090    virtual void unregisterEventListener( EventListener & eventListener ) ;
00095    virtual void sendEventsForSignal ( Event & event , const EventIdentifier & sigId ) ;
00096 
00097 
00102    virtual bool receiveRegistrationForSignal ( const EventIdentifier & sigId, 
00103                                                const Name & registrant, 
00104                                                const EventIdentifier & eventId ) ;
00105 
00106 
00110    virtual bool cancelRegistrationForSignal ( const EventIdentifier & sigId, 
00111                                                const Name & registrant ) ;
00112 
00114    virtual void insertInStream (std::ostream & = std::cout) const;
00115 
00117    virtual void extract (std::istream & = std::cin);
00118    
00125    friend bool operator < (const ReferenceObjectHandle &,
00126                           const ReferenceObjectHandle &);
00129    friend bool operator <= (const ReferenceObjectHandle &,
00130                            const ReferenceObjectHandle &);
00133    friend bool operator > (const ReferenceObjectHandle &,
00134                           const ReferenceObjectHandle &);
00137    friend bool operator >= (const ReferenceObjectHandle &,
00138                             const ReferenceObjectHandle &);
00139    
00141 
00143    enum SimulatedObjectComputingState { initial, running, suspended, stopped, destroyed } ;
00144 
00146    virtual const SimulatedObjectComputingState & getComputingState() const ;
00147 
00148 protected:
00150   friend class OMK::Controller;
00151 
00153   friend class OMK::Scheduler ;
00154 
00156    SimulatedObjectComputingState _computingState; 
00157 
00159    Controller & _controller ;
00160 
00162    virtual std::list <Event *> & getCurrentEventList() ;
00163 
00165    virtual void switchEventList () ;
00166 
00168    Date _dateOfLastEventManagement ;
00169 
00171    Date _dateOfLastActivation ;
00172 
00174    std::list <Event *> * * _eventList ;
00175 
00177    unsigned int _currentWritableEventList ;
00178 
00179 #ifdef _OMK_MUTEX_
00180 
00181    BENCO OMKMutexLock _mutexForListEvt ;
00182 #endif
00183 
00185    bool _isInObjectNeedingActivationList[2]; 
00186 
00187 
00189 #ifdef _MSC_VER
00190    typedef stdext::hash_map< const EventIdentifier, std::list < EventListener *> *, Name::hash_compare_Name > virtualEventTableType ;
00191 #else
00192    typedef __gnu_cxx::hash_map< const EventIdentifier, std::list < EventListener *> *, Name::hash_compare_Name > virtualEventTableType ;
00193 #endif
00194 
00196    virtualEventTableType _virtualEventTable ;
00197 
00199    SignalDispatcher * _signalDispatcher ;
00200 
00201 }; // ReferenceObjectHandle
00202 
00209 bool operator < (const ReferenceObjectHandle &,
00210                         const ReferenceObjectHandle &);
00213 bool operator <= (const ReferenceObjectHandle &,
00214                   const ReferenceObjectHandle &);
00217 bool operator > (const ReferenceObjectHandle &,
00218                         const ReferenceObjectHandle &);
00221 bool operator >= (const ReferenceObjectHandle &,
00222                          const ReferenceObjectHandle &);
00223    
00225 } // namespace OMK
00226 #endif
00227 
00228 
00229 
00230 
00231 
00232 

logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007