OMKDistributedController.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 OMKDistributedControllerHEADER
00019 #define OMKDistributedControllerHEADER
00020 
00021 
00022 #include <OMKController.h>
00023 
00024 #include "OMKDuplicatedObjectHandle.h"
00025 #include "OMKLocalObjectHandle.h"
00026 namespace OMK
00027 {
00028 class MirrorObjectHandle ;
00029 
00037 class OMK_API DistributedController : public Controller 
00038 {
00039 public:
00041    DistributedController(ObjectDescriptor & initialObjects, const Date & initialDate);
00042 
00044    virtual ~DistributedController();
00045 
00050    virtual SimulatedObject * getPointerToSimulatedObjectNamed (const Name & objectName );
00051    
00053    virtual void dispatchEvent(Event * event);
00054 
00055 
00056 
00058    virtual bool processEvent ( Event * event ) ;
00059  
00061    virtual void purgeMemoryFromOldEvents ( const Date & dateOfOldestKept );
00062 
00063 
00065    virtual void broadcastEventsForSignal ( Event & event, const EventIdentifier & sigId ) ;
00066 
00067 
00073    virtual bool receiveRegistrationForSignal(const EventIdentifier & sigId, 
00074                                   const Name & registrant, 
00075                                   const EventIdentifier & eventId);
00076 
00077 
00082    virtual bool receiveCancellationForSignal ( const EventIdentifier & sigId , 
00083                                               const Name & registrant ) ;
00084 
00091   virtual const ObjectDescriptor & getObjectDescriptorOfObject(const Name & objectName) ;
00092 
00093 
00095   // pour rendre public la liste des miroirs
00096   std::vector<Name> _publicMirrorObjectsVector ;
00097   
00098   virtual std::vector<Name> getMirrorList() ;
00099   virtual std::vector<Name> getIsolatedMirrorList() { return std::vector<Name>() ;} ;
00100   virtual std::vector<Name> getNonIsolatedMirrorList()  { return std::vector<Name>() ;} ;
00101   // fin TDTD
00102   virtual  bool isAMirror(const Name & name) ;
00103   virtual bool testIfTroubleOccured()  { return true ; };
00104   virtual void createNewSite (const Date &) {} ;
00105   Name exProcessName ;
00108 protected:
00113    virtual MirrorObjectHandle * newOMKMirrorObjectHandle (SimulatedObject & obj) = 0 ;
00114 
00115 
00120    virtual DuplicatedObjectHandle * newOMKDuplicatedObjectHandle (SimulatedObject & obj) = 0 ;
00121 
00123    virtual LocalObjectHandle * newOMKLocalObjectHandle (SimulatedObject & obj) = 0 ;
00124 
00126    virtual void deleteObject (  ObjectDescriptor * objectDescriptor ) ;
00127    
00129    virtual void createControlledObjects (const ObjectDescriptor * subTree) ;
00130 
00132    virtual void createObject(const ObjectDescriptor & newObjectDescription, const Name & fathersName) ;
00133 
00135    virtual void processNewObjectDeclaration ( ObjectDescriptor & declaration, const Date & declarationDate ) ;
00136 
00140    virtual MirrorObjectHandle * createMirrorObject ( ObjectDescriptor * objectDescription );
00141 
00142 
00144    virtual DuplicatedObjectHandle * createDuplicatedObject( ObjectDescriptor * objectDescription );
00145 
00148    virtual void createLocalObject(const ObjectDescriptor & newLObjectDescription, 
00149                                   const Name & fathersLName) ;
00150    virtual  int getMirrorsNbre () ;   
00153 #ifdef _MSC_VER   
00154    typedef stdext::hash_map<Name,MirrorObjectHandle *,Name::hash_compare_Name >  MirrorObjectsContainerType ;
00155 #else
00156    typedef __gnu_cxx::hash_map<Name,MirrorObjectHandle *,Name::hash_compare_Name >  MirrorObjectsContainerType ;
00157 #endif
00158 
00161    MirrorObjectsContainerType _mirrorObjectsMap ;
00162 
00165    NameToPointerMap<DuplicatedObjectHandle> _duplicatedObjectsMap;
00166    
00168    NameToPointerMap<LocalObjectHandle> _localObjectsMap;
00169    
00170 
00175    virtual void processStartEventOf(ReferenceObjectHandle * objectHandle) ;
00176 
00178    NameToPointerMap<ReferenceObjectHandle> tableDesNonInitialises ;
00179 
00181    NameToPointerMap<ReferenceObjectHandle> tableDesInitialises ;
00182 
00184    Name _processName ;
00185 
00187    std::list<std::pair<EventIdentifier, std::pair <Event *, Date> > > _broadcastedSignals ;
00188 
00190    std::list <std::pair <Date, ObjectDescriptor *> > _deletedObjectDescriptors ; 
00191 protected:
00192   class RegistrationData : public OMK::Type::Base
00193    {
00194    public:
00195       RegistrationData() {} ;
00196 
00197       RegistrationData (const EventIdentifier & sig,
00198                         const Name & registrant, 
00199                         const EventIdentifier & eventId) ;
00200 
00201       virtual ~RegistrationData() ;
00202 
00204       virtual void unpack (IncomingSynchronisationMessage &) ;
00205       
00207       virtual void pack (OutgoingSynchronisationMessage &) const ;
00208 
00209       virtual void extract(std::istream & in) ;
00210 
00211       virtual void insertInStream (std::ostream & out) const ;
00212 
00213       virtual OMK::Type::PolatorNT * createPolator() ;
00214 
00215       EventIdentifier _sig ;
00216       Name _registrant ;
00217       EventIdentifier _eventId ;
00218    }; 
00219 
00220 
00221 
00222    class CancellationData : public OMK::Type::Base
00223    {
00224    public:
00225       CancellationData(){};
00226 
00227       CancellationData  ( const EventIdentifier & sigId , const Name & registrant ) ;
00228 
00229       virtual ~CancellationData() ;
00230 
00232       virtual void unpack (IncomingSynchronisationMessage &) ;
00233       
00235       virtual void pack (OutgoingSynchronisationMessage &) const ;
00236 
00237       virtual void extract(std::istream & in) ;
00238 
00239       virtual void insertInStream (std::ostream & out) const ;
00240 
00241       virtual OMK::Type::PolatorNT * createPolator() ;
00242 
00243       EventIdentifier _sigId ;
00244 
00245       Name _registrant ;
00246    };
00247 };
00248 } // namespace OMK
00249 #endif
00250 

logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007