00001 // Copyright CERN 2012 - Developed in collaboration with GSI 00002 #include <fesa-core/Utilities/ParserElements/ParserElementFactory.h> 00003 #include <fesa-core/Utilities/ParserElements/EventElement.h> 00004 #include <fesa-core/Utilities/ParserElements/ClassElement.h> 00005 #include <fesa-core/Utilities/ParserElements/DeviceElement2.h> 00006 #include <fesa-core/Utilities/ParserElements/DeviceLogicalEventElement.h> 00007 #include <fesa-core/Utilities/ParserElements/EventConfigurationElement.h> 00008 #include <fesa-core/Utilities/ParserElements/LogicalEventElement.h> 00009 #include <fesa-core/Utilities/ParserElements/TimingEventElement.h> 00010 #include <fesa-core/Utilities/ParserElements/TimerEventElement.h> 00011 #include <fesa-core/Utilities/ParserElements/OnDemandEventElement.h> 00012 #include <fesa-core/Utilities/ParserElements/OnSubscriptionEventElement.h> 00013 #include <fesa-core/Utilities/ParserElements/CustomEventElement.h> 00014 #include <fesa-core/Utilities/ParserElements/ParserElementDefs.h> 00015 #include <fesa-core/Core/AbstractDeviceClass.h> 00016 #include <fesa-core/Exception/FesaExceptionDef.h> 00017 00018 namespace fesa 00019 { 00020 00021 ParserElementFactory::ParserElementFactory() 00022 { 00023 00024 00025 } 00026 00027 ParserElementFactory::~ParserElementFactory() 00028 { 00029 00030 } 00031 00032 boost::shared_ptr<EventElement> ParserElementFactory::createEventElement(boost::shared_ptr<EventConfigurationElement> parent,const std::string& sourceType) const 00033 { 00034 if( sourceType == TIMING_EVENT_SOURCE_TAG ) 00035 return boost::shared_ptr<TimingEventElement>(new TimingEventElement(parent)); 00036 if( sourceType == TIMER_EVENT_SOURCE_TAG ) 00037 return boost::shared_ptr<TimerEventElement>(new TimerEventElement(parent)); 00038 if( sourceType == ON_DAMAND_EVENT_SOURCE_TAG ) 00039 return boost::shared_ptr<OnDemandEventElement>(new OnDemandEventElement(parent)); 00040 if( sourceType == ON_SUBSCRIPTION_EVENT_SOURCE_TAG ) 00041 return boost::shared_ptr<OnSubscriptionEventElement>(new OnSubscriptionEventElement(parent)); 00042 if( sourceType == CUSTOM_EVENT_SOURCE_TAG ) 00043 return boost::shared_ptr<CustomEventElement>(new CustomEventElement(parent)); 00044 00045 throw FesaException(__FILE__, __LINE__, FesaErrorUnkonwEventSourceType.c_str(),sourceType.c_str()); 00046 } 00047 00048 boost::shared_ptr<ClassElement> ParserElementFactory::createClassElement(AbstractDeviceClass *classRef) const 00049 { 00050 return boost::shared_ptr<ClassElement>(new ClassElement(classRef)); 00051 } 00052 00053 00054 00055 boost::shared_ptr<DeviceElement2> ParserElementFactory::createDeviceElement2(boost::shared_ptr<ClassElement> parent,bool isGlobalDevice) const 00056 { 00057 return boost::shared_ptr<DeviceElement2>(new DeviceElement2(parent,isGlobalDevice)); 00058 } 00059 00060 00061 00062 boost::shared_ptr<DeviceLogicalEventElement> ParserElementFactory::createDeviceLogicalEventElement() const 00063 { 00064 return boost::shared_ptr<DeviceLogicalEventElement>(new DeviceLogicalEventElement()); 00065 } 00066 00067 00068 00069 boost::shared_ptr<EventConfigurationElement> ParserElementFactory::createEventConfigurationElement(boost::shared_ptr<LogicalEventElement> parent) const 00070 { 00071 return boost::shared_ptr<EventConfigurationElement>(new EventConfigurationElement(parent)); 00072 } 00073 00074 00075 00076 boost::shared_ptr<LogicalEventElement> ParserElementFactory::createLogicalEventElement(boost::shared_ptr<ClassElement> parent) const 00077 { 00078 return boost::shared_ptr<LogicalEventElement>(new LogicalEventElement(parent)); 00079 } 00080 00081 }