00001 // Copyright CERN 2012 - Developed in collaboration with GSI 00002 00003 #ifndef ABSTRACT_EVENT_SOURCE_FACTORY_H_ 00004 #define ABSTRACT_EVENT_SOURCE_FACTORY_H_ 00005 00006 #include <fesa-core/RealTime/AbstractEventSource.h> 00007 00008 #include <string> 00009 #include <map> 00010 00011 namespace fesa 00012 { 00013 class AbstractRealTimeLabObjectFactory; 00014 00018 class AbstractEventSourceFactory 00019 { 00020 public: 00021 00022 AbstractEventSource* createEventSource(const std::string& className, const std::string& eventSourceName, const EventSourceType& type); 00023 00027 static void deleteEventSources(); 00028 00032 static void startEventSources(); 00033 00037 static void stopEventSources(); 00038 00043 static AbstractEventSource* getEventSource(const std::string& className, const std::string& eventSourceName); 00044 00045 static bool eventSourceExists(const std::string& className, const std::string& eventSourceName); 00046 00051 static void printConfigAll(FesaStream* fesaStream); 00052 00058 static void printStateAll(FesaStream* fesaStream, double elapsedTime); 00059 00060 protected: 00061 00065 virtual AbstractEventSource* createCustomEventSource(const std::string& eventSourceName) = 0; 00066 00072 virtual AbstractEventSource* createOnSubscriptionEventSource(const std::string& eventSourceName) = 0; 00073 00074 AbstractEventSourceFactory(); 00075 00076 virtual ~AbstractEventSourceFactory(); 00077 00082 AbstractRealTimeLabObjectFactory* labFactory_; 00083 00084 private: 00085 00086 typedef const std::string EventSourceName; 00087 typedef const std::string ClassName; 00088 typedef const std::pair<EventSourceName,ClassName> EventSourceKey; 00089 typedef std::map<EventSourceKey, AbstractEventSource*> EventSourceMap; 00090 00091 AbstractEventSource* createTimingEventSource(const std::string& eventSourceName); 00092 00093 AbstractEventSource* createTimerEventSource(const std::string& eventSourceName); 00094 00095 AbstractEventSource* createOnDemandEventSource(const std::string& className,const std::string& eventSourceName); 00096 00100 static EventSourceKey generateKey(const std::string& className, const std::string& eventSourceName); 00101 00105 static EventSourceMap eventSourceMap_; 00106 }; 00107 00108 } 00109 00110 #endif /* ABSTRACT_EVENT_SOURCE_FACTORY_H_ */