2 * Config_FeatureReader.cpp
4 * Created on: Mar 20, 2014
8 #include <Config_FeatureReader.h>
10 #include <Event_Loop.hxx>
12 #include <libxml\parser.h>
13 #include <libxml\tree.h>
19 //Hardcoded xml entities
23 const static char* FEATURE_ID = "id";
24 const static char* FEATURE_TEXT = "text";
25 const static char* FEATURE_TOOLTIP = "tooltip";
26 const static char* FEATURE_ICON = "icon";
27 const static char* FEATURE_KEYSEQUENCE = "keysequence";
28 const static char* FEATURE_GROUP_NAME = "name";
33 Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile)
34 : Config_XMLReader(theXmlFile)
37 if(!Event_Loop::Loop()) {
38 std::cout << "Config_FeatureReader::importWorkbench: "
39 << "No event loop registered" << std::endl;
44 Config_FeatureReader::~Config_FeatureReader()
48 void Config_FeatureReader::processNode(xmlNodePtr theNode)
50 if(isNode(theNode,"feature")) {
51 Event_Loop* aEvLoop = Event_Loop::Loop();
52 Config_FeatureMessage aMessage(aEvLoop->EventByName("Feature"), this);
53 fillFeature(theNode, aMessage);
54 xmlNodePtr aGroupNode = theNode->parent;
56 std::string aGroupName = getProperty(aGroupNode, FEATURE_GROUP_NAME);
57 aMessage.m_group = aGroupName;
59 aEvLoop->Send(aMessage);
63 bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
65 return isNode(theNode, "workbench")
66 || isNode(theNode, "group");
67 // || isNode(theNode, "feature");
70 void Config_FeatureReader::fillFeature(xmlNodePtr theRoot,
71 Config_FeatureMessage& outFtMessage)
73 outFtMessage.m_id = getProperty(theRoot, FEATURE_ID);
74 outFtMessage.m_text = getProperty(theRoot, FEATURE_TEXT);
75 outFtMessage.m_tooltip = getProperty(theRoot, FEATURE_TOOLTIP);
76 outFtMessage.m_icon = getProperty(theRoot, FEATURE_ICON);
77 outFtMessage.m_keysequence = getProperty(theRoot, FEATURE_KEYSEQUENCE);