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 : Config_XMLReader(theXmlFile),
28 myLibraryName(theLibraryName)
32 Config_FeatureReader::~Config_FeatureReader()
36 void Config_FeatureReader::processNode(xmlNodePtr theNode)
38 static Event_ID aMenuItemEvent = Event_Loop::eventByName("FeatureEvent");
39 if (isNode(theNode, NODE_FEATURE, NULL)) {
40 Event_Loop* aEvLoop = Event_Loop::loop();
41 Config_FeatureMessage aMessage(aMenuItemEvent, this);
42 fillFeature(theNode, aMessage);
43 aEvLoop->send(aMessage);
45 //The m_last* variables always defined before fillFeature() call. XML is a tree.
46 if (isNode(theNode, NODE_GROUP, NULL)) {
47 myLastGroup = getProperty(theNode, _ID);
49 if (isNode(theNode, NODE_WORKBENCH, NULL)) {
50 myLastWorkbench = getProperty(theNode, _ID);
54 bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
56 return isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL);
59 void Config_FeatureReader::fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFtMessage)
61 outFtMessage.setId(getProperty(theRoot, _ID));
62 outFtMessage.setText(getProperty(theRoot, FEATURE_TEXT));
63 outFtMessage.setTooltip(getProperty(theRoot, FEATURE_TOOLTIP));
64 outFtMessage.setIcon(getProperty(theRoot, FEATURE_ICON));
65 outFtMessage.setKeysequence(getProperty(theRoot, FEATURE_KEYSEQUENCE));
66 outFtMessage.setGroupId(myLastGroup);
67 outFtMessage.setWorkbenchId(myLastWorkbench);
68 outFtMessage.setPluginLibrary(myLibraryName);