#include <PsEventCreator.h>
Inheritance diagram for PsEventCreator:


Public Methods | |
| virtual | ~PsEventCreator () |
| PsEventCreator (const PsName &) | |
| virtual bool | touch () |
| to help avoid aggresive optimisations | |
Static Public Methods | |
| PsEvent * | createEvent (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 PsEvent * | createRealEvent (const PsEventIdentifier &eventId, const PsDate &date, const PsName &sender, const PsName &receiver) |
Static Protected Methods | |
| EventCreatorContainerType * | getEventCreatorContainer () |
Protected Attributes | |
| PsName | _typeICanCreate |
Definition at line 30 of file PsEventCreator.h.
|
|
Definition at line 52 of file PsEventCreator.h. Referenced by getEventCreatorContainer(). |
|
|
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 }
|
|
|
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 } |
|
||||||||||||||||||||||||
|
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 }
|
|
||||||||||||||||||||
|
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 }
|
|
||||||||||||
|
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 }
|
|
|
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 }
|
|
|
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 ;
|
|
|
Definition at line 47 of file PsEventCreator.h. Referenced by ~PsEventCreator(). |
| Documentation generated on Mon Nov 25 15:25:59 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |