2 * Config_FeatureReader.cpp
4 * Created on: Mar 20, 2014
8 #include <Config_Keywords.h>
9 #include <Config_Common.h>
10 #include <Config_FeatureMessage.h>
11 #include <Config_FeatureReader.h>
12 #include <Event_Message.h>
13 #include <Event_Loop.h>
15 #include <libxml/parser.h>
16 #include <libxml/tree.h>
17 #include <libxml/xmlstring.h>
26 Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile,
27 const std::string& theLibraryName,
28 const char* theEventGenerated)
29 : Config_XMLReader(theXmlFile),
30 myLibraryName(theLibraryName),
31 myEventGenerated(theEventGenerated ? theEventGenerated : "FeatureEvent")
35 Config_FeatureReader::~Config_FeatureReader()
39 void Config_FeatureReader::processNode(xmlNodePtr theNode)
41 Event_ID aMenuItemEvent = Event_Loop::eventByName(myEventGenerated);
42 if (isNode(theNode, NODE_FEATURE, NULL)) {
43 Event_Loop* aEvLoop = Event_Loop::loop();
44 Config_FeatureMessage aMessage(aMenuItemEvent, this);
45 fillFeature(theNode, aMessage);
46 //If a feature has xml definition for it's widget:
47 aMessage.setUseInput(hasChild(theNode));
48 aEvLoop->send(aMessage);
50 //The m_last* variables always defined before fillFeature() call. XML is a tree.
51 if (isNode(theNode, NODE_GROUP, NULL)) {
52 myLastGroup = getProperty(theNode, _ID);
54 if (isNode(theNode, NODE_WORKBENCH, NULL)) {
55 myLastWorkbench = getProperty(theNode, _ID);
59 bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
61 return isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL);
64 void Config_FeatureReader::fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFtMessage)
66 outFtMessage.setId(getProperty(theRoot, _ID));
67 outFtMessage.setText(getProperty(theRoot, FEATURE_TEXT));
68 outFtMessage.setTooltip(getProperty(theRoot, FEATURE_TOOLTIP));
69 outFtMessage.setIcon(getProperty(theRoot, FEATURE_ICON));
70 outFtMessage.setKeysequence(getProperty(theRoot, FEATURE_KEYSEQUENCE));
71 outFtMessage.setGroupId(myLastGroup);
72 outFtMessage.setWorkbenchId(myLastWorkbench);
73 outFtMessage.setPluginLibrary(myLibraryName);