LogicalEventElement.cpp
Go to the documentation of this file.00001
00002 #include <fesa-core/Utilities/ParserElements/LogicalEventElement.h>
00003 #include <fesa-core/Utilities/ParserElements/EventConfigurationElement.h>
00004 #include <fesa-core/Utilities/ParserElements/ClassElement.h>
00005 #include <fesa-core/Utilities/ParserElements/ParserElementFactory.h>
00006 #include <fesa-core/Exception/FesaExceptionDef.h>
00007 #include <fesa-core/Core/AbstractDeviceClass.h>
00008 #include <fesa-core/Utilities/XMLParser.h>
00009
00010 namespace fesa
00011 {
00012
00013 LogicalEventElement::LogicalEventElement(boost::shared_ptr<ClassElement> parent):
00014 parentClassElement_(parent), isInitialized_(false)
00015 {
00016
00017 }
00018
00019 LogicalEventElement::LogicalEventElement()
00020 {
00021
00022 }
00023
00024 LogicalEventElement::~LogicalEventElement()
00025 {
00026
00027 }
00028
00029 void LogicalEventElement::initialize(const std::string& xpath, ElementXML *logicalEventElement, ParserElementFactory& parserElementFactory)
00030 {
00031 logicalEventName_ = logicalEventElement->name_;
00032 loadEventConfigurationElements(xpath,logicalEventElement,parserElementFactory);
00033 isInitialized_ = true;
00034 }
00035
00036 void LogicalEventElement::loadEventConfigurationElements(const std::string& xpath, ElementXML *logicalEventElement, ParserElementFactory& parserElementFactory)
00037 {
00038 std::vector<ElementXML*>::iterator iter;
00039 for(iter = logicalEventElement->childList_.begin();iter != logicalEventElement->childList_.end();++iter)
00040 {
00041 std::string xpathEventConfig = xpath + "/" + (*iter)->name_;
00042 boost::shared_ptr<EventConfigurationElement> temp = parserElementFactory.createEventConfigurationElement(shared_from_this());
00043 temp->initialize(xpathEventConfig,*iter,parserElementFactory);
00044 configurationElementCol_.push_back(temp);
00045 }
00046 }
00047
00048 AbstractDeviceClass* LogicalEventElement::getClassRef() const
00049 {
00050 return parentClassElement_->getClassRef();
00051 }
00052
00053 boost::shared_ptr<EventConfigurationElement> LogicalEventElement::getEventConfigurationElementRef(const std::string& eventConfigurationName) const
00054 {
00055 std::vector<boost::shared_ptr<EventConfigurationElement> >::const_iterator iter;
00056 for(iter = configurationElementCol_.begin();iter != configurationElementCol_.end();++iter)
00057 {
00058 if((*iter)->getName() == eventConfigurationName)
00059 {
00060 return *iter;
00061 }
00062 }
00063
00064
00065 throw FesaException(__FILE__, __LINE__, FesaErrorTimingMappingNotConform.c_str(),logicalEventName_.c_str());
00066 }
00067
00068 const std::vector<boost::shared_ptr<EventConfigurationElement> >& LogicalEventElement::getEventConfigurationElementCol() const
00069 {
00070 if(!isInitialized_)
00071 throw FesaException(__FILE__, __LINE__, FesaErrorParserElementNotInitialized.c_str());
00072
00073 return configurationElementCol_;
00074 }
00075
00076 const std::string& LogicalEventElement::getName() const
00077 {
00078 if(!isInitialized_)
00079 throw FesaException(__FILE__, __LINE__, FesaErrorParserElementNotInitialized.c_str());
00080
00081 return logicalEventName_;
00082 }
00083
00084 std::vector<boost::shared_ptr<EventElement> > LogicalEventElement::getActiveEventElements() const
00085 {
00086 std::vector<boost::shared_ptr<EventElement> > eventCol;
00087 std::vector<boost::shared_ptr<EventElement> >::iterator eventIter = eventCol.begin();
00088 std::vector<boost::shared_ptr<EventConfigurationElement> >::const_iterator configIter;
00089 for(configIter = configurationElementCol_.begin();configIter != configurationElementCol_.end();configIter++)
00090 {
00091 if(!(*configIter)->isNotUsed())
00092 {
00093 std::vector<boost::shared_ptr<EventElement> > tempCol = (*configIter)->getEventElementCol();
00094 std::vector<boost::shared_ptr<EventElement> >::iterator tempIter;
00095 for(tempIter = tempCol.begin();tempIter != tempCol.end();tempIter++)
00096 {
00097 eventIter = eventCol.insert(eventIter,*tempIter);
00098 }
00099 }
00100 }
00101 return eventCol;
00102 }
00103
00104 }
00105
00106
00107
00108