#include <OMKEventCreator.h>
Inheritance diagram for OMK::EventCreator:
Public Member Functions | |
virtual | ~EventCreator () |
EventCreator (const Name &) | |
virtual bool | touch () |
to help avoid aggresive optimisations | |
virtual void | touch (bool) |
to help avoid aggresive optimisations | |
Static Public Member Functions | |
static Event * | createEvent (const Name &classToCreate, const EventIdentifier &eventId, const Date &date, const Name &sender, const Name &receiver) |
static void | declareAlias (const Name &, const Name &) |
declare aliases between the type names used to access an event creator. | |
Protected Types | |
typedef __gnu_cxx::hash_map< Name, EventCreator *, Name::hash_compare_Name > | EventCreatorContainerType |
Protected Member Functions | |
virtual Event * | createRealEvent (const EventIdentifier &eventId, const Date &date, const Name &sender, const Name &receiver) |
Static Protected Member Functions | |
static EventCreatorContainerType * | getEventCreatorContainer () |
Protected Attributes | |
Name | _typeICanCreate |
Definition at line 33 of file OMKEventCreator.h.
typedef __gnu_cxx::hash_map<Name, EventCreator *, Name::hash_compare_Name> OMK::EventCreator::EventCreatorContainerType [protected] |
Definition at line 62 of file OMKEventCreator.h.
EventCreator::~EventCreator | ( | ) | [virtual] |
Definition at line 63 of file OMKEventCreator.cpp.
References _typeICanCreate, and getEventCreatorContainer().
00064 { 00065 getEventCreatorContainer()->erase ( _typeICanCreate ) ; 00066 }
EventCreator::EventCreator | ( | const Name & | ) |
Definition at line 54 of file OMKEventCreator.cpp.
References getEventCreatorContainer().
00054 : 00055 _typeICanCreate ( className ) 00056 { 00057 // cerr<<"EventCreator::EventCreator inserting "<<className<<" in the map of events that can be created from their name"<<endl; 00058 getEventCreatorContainer()->insert( EventCreator::EventCreatorContainerType::value_type( className, this ) ) ; 00059 }
Event * EventCreator::createEvent | ( | const Name & | classToCreate, | |
const EventIdentifier & | eventId, | |||
const Date & | date, | |||
const Name & | sender, | |||
const Name & | receiver | |||
) | [static] |
Definition at line 70 of file OMKEventCreator.cpp.
References getEventCreatorContainer(), and OMASSERTM.
Referenced by OMK::PvmController::parseSynchronisationMessage(), OMK::PvmReferenceObjectHandle::unpack(), OMK::PvmLocalObjectHandle::unpack(), and OMK::PvmDuplicatedObjectHandle::unpack().
00071 { 00072 EventCreatorContainerType::iterator i = getEventCreatorContainer()->find (classToCreate) ; 00073 00074 if ( i == getEventCreatorContainer()->end() ) 00075 { 00076 cerr<<"EventCreator::createEvent "<<getEventCreatorContainer()->size()<<" event creators in the map"<<endl; 00077 cerr<<"EventCreator::createEvent: cannot create valued event of class "<<classToCreate 00078 <<" but I can create: "; 00079 for ( i = getEventCreatorContainer()->begin() ; 00080 i != getEventCreatorContainer()->end() ; 00081 ++i) 00082 { 00083 OMASSERTM( (*i).first != classToCreate, "" ) ; 00084 cerr<<(*i).first<<"("<<(*i).second<<"), "; 00085 } 00086 cerr<<endl; 00087 cerr<<"If in heterogeneous environment try calling EventCreator:::declareAlias ( "<<classToCreate<<", ...) ; in main"<<endl; 00088 cerr<<"Or, if using g++ with version < 3, a call to "<<classToCreate<<"::myEventCreator::touch()"<<endl; 00089 } 00090 00091 00092 return (*i).second->createRealEvent (eventId,date,sender,receiver) ; 00093 00094 }
virtual bool OMK::EventCreator::touch | ( | ) | [inline, virtual] |
to help avoid aggresive optimisations
Definition at line 41 of file OMKEventCreator.h.
Referenced by OMK::ValuedEvent< UserType >::ValuedEvent(), and OMK::ValuedEvent< UserType >::~ValuedEvent().
virtual void OMK::EventCreator::touch | ( | bool | ) | [inline, virtual] |
declare aliases between the type names used to access an event creator.
Definition at line 14 of file OMKEventCreator.cpp.
References getEventCreatorContainer().
00015 { 00016 static map <const Name, const Name> unInsertedAliases ; 00017 Name nameToInsert ; 00018 00019 //first find the event creator 00020 EventCreatorContainerType::iterator i = getEventCreatorContainer()->find ( name1 ) ; 00021 nameToInsert = name2 ; 00022 if ( i == getEventCreatorContainer()->end() ) 00023 { 00024 i = getEventCreatorContainer()->find ( name2 ) ; 00025 nameToInsert = name1 ; 00026 } 00027 if ( i == getEventCreatorContainer()->end() ) 00028 { 00029 // remember the declaration 00030 unInsertedAliases.insert (pair<const Name, const Name> (name1, name2) ) ; 00031 unInsertedAliases.insert (pair<const Name, const Name> (name2, name1) ) ; 00032 } 00033 else 00034 { 00035 getEventCreatorContainer()->insert (EventCreator::EventCreatorContainerType::value_type (nameToInsert, (*i).second ) ) ; 00036 00037 //look in the uninserted aliases if one could not be inserted 00038 map <const Name, const Name>::iterator j = unInsertedAliases.find ( name1 ); 00039 if ( j == unInsertedAliases.end() ) 00040 { 00041 j = unInsertedAliases.find ( name2 ); 00042 } 00043 if ( j != unInsertedAliases.end() ) 00044 { 00045 getEventCreatorContainer()->insert (EventCreator::EventCreatorContainerType::value_type ( (*j).second, (*i).second ) ) ; 00046 // remove the 2 instances declaring name and (*j).second as aliases 00047 unInsertedAliases.erase ( unInsertedAliases.find ( (*j).second ) ) ; 00048 unInsertedAliases.erase ( j ) ; 00049 } 00050 } 00051 }
Event * EventCreator::createRealEvent | ( | const EventIdentifier & | eventId, | |
const Date & | date, | |||
const Name & | sender, | |||
const Name & | receiver | |||
) | [protected, virtual] |
Reimplemented in OMK::ValuedEvent< UserType >::ValuedEventCreator.
Definition at line 98 of file OMKEventCreator.cpp.
00099 { 00100 return new Event (eventId, date, sender, receiver) ; 00101 }
EventCreator::EventCreatorContainerType * EventCreator::getEventCreatorContainer | ( | ) | [static, protected] |
Definition at line 8 of file OMKEventCreator.cpp.
Referenced by createEvent(), declareAlias(), EventCreator(), and ~EventCreator().
00009 { 00010 static EventCreatorContainerType * realEventCreatorContainer = new EventCreatorContainerType () ; 00011 return realEventCreatorContainer ; 00012 }
Name OMK::EventCreator::_typeICanCreate [protected] |
Documentation generated on Mon Jun 9 11:46:01 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |