Salome HOME
Changes in source code within porting on CentOS 6.3
[modules/shaper.git] / src / Config / Config_FeatureReader.cpp
1 /*
2  * Config_FeatureReader.cpp
3  *
4  *  Created on: Mar 20, 2014
5  *      Author: sbh
6  */
7
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>
13
14 #include <libxml/parser.h>
15 #include <libxml/tree.h>
16 #include <libxml/xmlstring.h>
17
18 #include <string>
19
20 #ifdef _DEBUG
21 #include <iostream>
22 #endif
23
24
25 Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile,
26                                            const std::string& theLibraryName)
27     : Config_XMLReader(theXmlFile),
28       myLibraryName(theLibraryName)
29 {
30 }
31
32 Config_FeatureReader::~Config_FeatureReader()
33 {
34 }
35
36 void Config_FeatureReader::processNode(xmlNodePtr theNode)
37 {
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);
44   }
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);
48   }
49   if (isNode(theNode, NODE_WORKBENCH, NULL)) {
50     myLastWorkbench = getProperty(theNode, _ID);
51   }
52 }
53
54 bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
55 {
56   return isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL);
57 }
58
59 void Config_FeatureReader::fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFtMessage)
60 {
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);
69 }