2 * Config_FeatureReader.cpp
4 * Created on: Mar 20, 2014
8 #include <Config_Keywords.h>
9 #include <Config_FeatureMessage.h>
10 #include <Config_FeatureReader.h>
11 #include <Event_Message.h>
12 #include <Event_Loop.h>
14 #include <libxml/parser.h>
15 #include <libxml/tree.h>
16 #include <libxml/xmlstring.h>
25 Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile,
26 const std::string& theLibraryName,
27 const char* theEventGenerated)
28 : Config_XMLReader(theXmlFile),
29 myLibraryName(theLibraryName),
30 myEventGenerated(theEventGenerated ? theEventGenerated : "FeatureEvent")
34 Config_FeatureReader::~Config_FeatureReader()
38 void Config_FeatureReader::processNode(xmlNodePtr theNode)
40 Event_ID aMenuItemEvent = Event_Loop::eventByName(myEventGenerated);
41 if (isNode(theNode, NODE_FEATURE, NULL)) {
42 Event_Loop* aEvLoop = Event_Loop::loop();
43 Config_FeatureMessage aMessage(aMenuItemEvent, this);
44 fillFeature(theNode, aMessage);
45 aEvLoop->send(aMessage);
47 //The m_last* variables always defined before fillFeature() call. XML is a tree.
48 if (isNode(theNode, NODE_GROUP, NULL)) {
49 myLastGroup = getProperty(theNode, _ID);
51 if (isNode(theNode, NODE_WORKBENCH, NULL)) {
52 myLastWorkbench = getProperty(theNode, _ID);
56 bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
58 return isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL);
61 void Config_FeatureReader::fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFtMessage)
63 outFtMessage.setId(getProperty(theRoot, _ID));
64 outFtMessage.setText(getProperty(theRoot, FEATURE_TEXT));
65 outFtMessage.setTooltip(getProperty(theRoot, FEATURE_TOOLTIP));
66 outFtMessage.setIcon(getProperty(theRoot, FEATURE_ICON));
67 outFtMessage.setKeysequence(getProperty(theRoot, FEATURE_KEYSEQUENCE));
68 outFtMessage.setGroupId(myLastGroup);
69 outFtMessage.setWorkbenchId(myLastWorkbench);
70 outFtMessage.setPluginLibrary(myLibraryName);