Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PsEventCreator Class Reference

Class defining what a creator of an event is. More...

#include <PsEventCreator.h>

Inheritance diagram for PsEventCreator:

Inheritance graph
[legend]
Collaboration diagram for PsEventCreator:

Collaboration graph
[legend]
List of all members.

Public Methods

virtual ~PsEventCreator ()
 PsEventCreator (const PsName &)
virtual bool touch ()
 to help avoid aggresive optimisations


Static Public Methods

PsEventcreateEvent (const PsName &classToCreate, const PsEventIdentifier &eventId, const PsDate &date, const PsName &sender, const PsName &receiver)
void declareAlias (const PsName &, const PsName &)
 declare aliases between the type names used to access an event creator.


Protected Types

typedef hash_map< PsName,
PsEventCreator *, PsName::hashFunctionObject,
PsName::equalToFunctionObject
EventCreatorContainerType

Protected Methods

virtual PsEventcreateRealEvent (const PsEventIdentifier &eventId, const PsDate &date, const PsName &sender, const PsName &receiver)

Static Protected Methods

EventCreatorContainerTypegetEventCreatorContainer ()

Protected Attributes

PsName _typeICanCreate

Detailed Description

Class defining what a creator of an event is.

Author:
David Margery

Definition at line 30 of file PsEventCreator.h.


Member Typedef Documentation

typedef hash_map<PsName, PsEventCreator *, PsName::hashFunctionObject, PsName::equalToFunctionObject> PsEventCreator::EventCreatorContainerType [protected]
 

Definition at line 52 of file PsEventCreator.h.

Referenced by getEventCreatorContainer().


Constructor & Destructor Documentation

PsEventCreator::~PsEventCreator   [virtual]
 

Definition at line 60 of file PsEventCreator.cxx.

References _typeICanCreate, hash_map< Key, T, HashFcn, EqualKey, Alloc >::erase(), and getEventCreatorContainer().

00061 {
00062    getEventCreatorContainer()->erase ( _typeICanCreate ) ;
00063 }

PsEventCreator::PsEventCreator const PsName  
 

Definition at line 51 of file PsEventCreator.cxx.

References getEventCreatorContainer(), and hash_map< Key, T, HashFcn, EqualKey, Alloc >::insert().

00051                                                           :
00052    _typeICanCreate ( className ) 
00053 {
00054    //   cerr<<"PsEventCreator::PsEventCreator inserting "<<className<<" in the map of events that can be created from their name"<<endl;
00055    getEventCreatorContainer()->insert (PsEventCreator::EventCreatorContainerType::value_type (className, this) ) ;
00056 }


Member Function Documentation

PsEvent * PsEventCreator::createEvent const PsName   classToCreate,
const PsEventIdentifier   eventId,
const PsDate   date,
const PsName   sender,
const PsName   receiver
[static]
 

Definition at line 67 of file PsEventCreator.cxx.

References hash_map< Key, T, HashFcn, EqualKey, Alloc >::begin(), hash_map< Key, T, HashFcn, EqualKey, Alloc >::end(), hash_map< Key, T, HashFcn, EqualKey, Alloc >::find(), getEventCreatorContainer(), PsDate, and hash_map< Key, T, HashFcn, EqualKey, Alloc >::size().

Referenced by PsnPvmReferenceObjectHandle::unpack(), and PsnPvmDuplicatedObjectHandle::unpack().

00068 {
00069    EventCreatorContainerType::iterator i = getEventCreatorContainer()->find (classToCreate) ;
00070 
00071    if ( i == getEventCreatorContainer()->end() )
00072       {
00073          cerr<<"PsEventCreator::createEvent "<<getEventCreatorContainer()->size()<<" event creators in the map"<<endl;
00074          cerr<<"PsEventCreator::createEvent: cannot create valued event of class "<<classToCreate
00075              <<" but I can create: ";
00076          for ( i = getEventCreatorContainer()->begin() ;
00077                i != getEventCreatorContainer()->end() ;
00078                ++i)
00079             {
00080                assert ( (*i).first != classToCreate ) ;
00081                cerr<<(*i).first<<"("<<(*i).second<<"), ";
00082             }
00083          cerr<<endl;
00084          cerr<<"If in heterogeneous environment try calling PsEventCreator:::declareAlias ( "<<classToCreate<<", ...) ; in main"<<endl;
00085          cerr<<"Or, if using g++ with version < 3, a call to "<<classToCreate<<"::myEventCreator::touch()"<<endl;
00086       }
00087 
00088 
00089    return (*i).second->createRealEvent (eventId,date,sender,receiver) ;
00090 
00091 }

PsEvent * PsEventCreator::createRealEvent const PsEventIdentifier   eventId,
const PsDate   date,
const PsName   sender,
const PsName   receiver
[protected, virtual]
 

Reimplemented in PsValuedEvent< UserType >::ValuedEventCreator.

Definition at line 95 of file PsEventCreator.cxx.

References PsDate.

00096 {
00097    return new PsEvent (eventId, date, sender, receiver) ;
00098 }

void PsEventCreator::declareAlias const PsName  ,
const PsName  
[static]
 

declare aliases between the type names used to access an event creator.

Definition at line 11 of file PsEventCreator.cxx.

References map< Key, T, Compare, Alloc >::end(), hash_map< Key, T, HashFcn, EqualKey, Alloc >::end(), map< Key, T, Compare, Alloc >::erase(), map< Key, T, Compare, Alloc >::find(), hash_map< Key, T, HashFcn, EqualKey, Alloc >::find(), getEventCreatorContainer(), hash_map< Key, T, HashFcn, EqualKey, Alloc >::insert(), and map< Key, T, Compare, Alloc >::insert().

00012 {
00013    static map <const PsName, const PsName> unInsertedAliases ;
00014    PsName nameToInsert ;
00015 
00016    //first find the event creator
00017    EventCreatorContainerType::iterator i = getEventCreatorContainer()->find ( name1 ) ;
00018    nameToInsert = name2 ;
00019    if ( i == getEventCreatorContainer()->end() )
00020       {
00021          i = getEventCreatorContainer()->find ( name2 ) ;
00022          nameToInsert = name1 ;
00023       }
00024    if ( i == getEventCreatorContainer()->end() )
00025       {
00026          // remember the declaration
00027          unInsertedAliases.insert (pair<const PsName, const PsName> (name1, name2) ) ;
00028          unInsertedAliases.insert (pair<const PsName, const PsName> (name2, name1) ) ;
00029       }   
00030    else
00031       {
00032          getEventCreatorContainer()->insert (PsEventCreator::EventCreatorContainerType::value_type (nameToInsert, (*i).second ) ) ;
00033 
00034          //look in the uninserted aliases if one could not be inserted
00035          map <const PsName, const PsName>::iterator j = unInsertedAliases.find ( name1 );
00036          if ( j == unInsertedAliases.end() )
00037             {
00038                j =  unInsertedAliases.find ( name2 );
00039             }
00040          if ( j != unInsertedAliases.end() )
00041             {
00042                getEventCreatorContainer()->insert (PsEventCreator::EventCreatorContainerType::value_type ( (*j).second, (*i).second ) ) ;
00043                   // remove the 2 instances declaring name and (*j).second as aliases
00044                unInsertedAliases.erase ( unInsertedAliases.find ( (*j).second ) ) ;
00045                unInsertedAliases.erase ( j ) ; 
00046             }
00047       }
00048 }

PsEventCreator::EventCreatorContainerType * PsEventCreator::getEventCreatorContainer   [static, protected]
 

Definition at line 5 of file PsEventCreator.cxx.

References EventCreatorContainerType.

Referenced by createEvent(), declareAlias(), PsEventCreator(), and ~PsEventCreator().

00006 {
00007    static EventCreatorContainerType * realEventCreatorContainer = new EventCreatorContainerType () ;
00008    return realEventCreatorContainer ;
00009 }

virtual bool PsEventCreator::touch   [inline, virtual]
 

to help avoid aggresive optimisations

Definition at line 38 of file PsEventCreator.h.

Referenced by PsValuedEvent< UserType >::PsValuedEvent(), and PsValuedEvent< UserType >::~PsValuedEvent().

00040    {
00041       return true ;


Member Data Documentation

PsName PsEventCreator::_typeICanCreate [protected]
 

Definition at line 47 of file PsEventCreator.h.

Referenced by ~PsEventCreator().


The documentation for this class was generated from the following files:
logo OpenMask

Documentation generated on Mon Nov 25 15:25:59 2002

Generated with doxygen 1.2.12 by Dimitri van Heesch ,   1997-2001