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 <Events_Message.h>
13 #include <Events_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 std::list<std::string> Config_FeatureReader::features() const
44 void Config_FeatureReader::processNode(xmlNodePtr theNode)
46 Events_ID aMenuItemEvent = Events_Loop::eventByName(myEventGenerated);
47 if (isNode(theNode, NODE_FEATURE, NULL)) {
48 Events_Loop* aEvLoop = Events_Loop::loop();
49 Config_FeatureMessage aMessage(aMenuItemEvent, this);
50 fillFeature(theNode, aMessage);
51 myFeatures.push_back(getProperty(theNode, _ID));
52 //If a feature has xml definition for it's widget:
53 aMessage.setUseInput(hasChild(theNode));
54 aEvLoop->send(aMessage);
56 //The m_last* variables always defined before fillFeature() call. XML is a tree.
57 if (isNode(theNode, NODE_GROUP, NULL)) {
58 myLastGroup = getProperty(theNode, _ID);
60 if (isNode(theNode, NODE_WORKBENCH, NULL)) {
61 myLastWorkbench = getProperty(theNode, _ID);
63 //Process SOURCE nodes.
64 Config_XMLReader::processNode(theNode);
67 bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
69 return isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL);
72 void Config_FeatureReader::fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFtMessage)
74 outFtMessage.setId(getProperty(theRoot, _ID));
75 outFtMessage.setText(getProperty(theRoot, FEATURE_TEXT));
76 outFtMessage.setTooltip(getProperty(theRoot, FEATURE_TOOLTIP));
77 outFtMessage.setIcon(getProperty(theRoot, FEATURE_ICON));
78 outFtMessage.setKeysequence(getProperty(theRoot, FEATURE_KEYSEQUENCE));
79 outFtMessage.setGroupId(myLastGroup);
80 outFtMessage.setWorkbenchId(myLastWorkbench);
81 outFtMessage.setPluginLibrary(myLibraryName);
82 outFtMessage.setNestedFeatures(getProperty(theRoot, FEATURE_NESTED));