00001 // Copyright CERN 2012 - Developed in collaboration with GSI 00002 #include <fesa-core/Utilities/ParserElements/OnSubscriptionEventElement.h> 00003 #include <fesa-core/Utilities/ParserElements/EventConfigurationElement.h> 00004 #include <fesa-core/Utilities/ParserElements/ParserElementDefs.h> 00005 #include <fesa-core/Utilities/XMLParser.h> 00006 00007 namespace fesa 00008 { 00009 00010 OnSubscriptionEventElement::OnSubscriptionEventElement(boost::shared_ptr<EventConfigurationElement> parent): 00011 EventElement(parent,OnSubscriptionSource) 00012 { 00013 00014 } 00015 00016 OnSubscriptionEventElement::~OnSubscriptionEventElement() 00017 { 00018 00019 } 00020 00021 void OnSubscriptionEventElement::initialize(const std::string& xpath,ElementXML* eventElement) 00022 { 00023 eventSourceName_ = ON_SUBSCRIPTION_EVENT_SOURCE_TAG; 00024 std::vector<AttributeXML*>::iterator iter; 00025 for(iter=eventElement->attributeList_.begin();iter!=eventElement->attributeList_.end();++iter) 00026 { 00027 if((*iter)->name_ == ON_SUBSCRIPTION_TAG_DEVICE ) 00028 { 00029 subscribedDeviceName_ = (*iter)->value_; 00030 } 00031 if((*iter)->name_ == ON_SUBSCRIPTION_TAG_PROPERTY ) 00032 { 00033 subscribedPropertyName_ = (*iter)->value_; 00034 } 00035 if((*iter)->name_ == ON_SUBSCRIPTION_TAG_CONTEXT ) 00036 { 00037 subscribedContextName_ = (*iter)->value_; 00038 } 00039 } 00040 00041 concreteEventName_ = eventSourceName_ + "::" + subscribedDeviceName_ + "::" + subscribedPropertyName_ + "::" + subscribedContextName_; 00042 isInitialized_ = true; 00043 } 00044 00045 const std::string& OnSubscriptionEventElement::getSourceTypeSpecificData(const std::string& dataTag) 00046 { 00047 if( dataTag == ON_SUBSCRIPTION_TAG_DEVICE ) 00048 { 00049 return subscribedDeviceName_; 00050 } 00051 if( dataTag == ON_SUBSCRIPTION_TAG_PROPERTY ) 00052 { 00053 return subscribedPropertyName_; 00054 } 00055 if( dataTag == ON_SUBSCRIPTION_TAG_CONTEXT ) 00056 { 00057 return subscribedContextName_; 00058 } 00059 00060 //Not found 00061 throw FesaException(__FILE__, __LINE__, FesaErrorUnkonwDataToken.c_str(),dataTag.c_str(),getLogicalName().c_str()); 00062 } 00063 00064 }