]> SALOME platform Git repositories - modules/shaper.git/blob - src/Config/Config_FeatureReader.cpp
Salome HOME
Merge branch 'master' of newgeom:newgeom.git into BR_PORTING_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                                            const char* theEventGenerated)
28     : Config_XMLReader(theXmlFile),
29       myLibraryName(theLibraryName),
30       myEventGenerated(theEventGenerated ? theEventGenerated : "FeatureEvent")
31 {
32 }
33
34 Config_FeatureReader::~Config_FeatureReader()
35 {
36 }
37
38 void Config_FeatureReader::processNode(xmlNodePtr theNode)
39 {
40   Event_ID aMenuItemEvent = Event_Loop::eventByName(myEventGenerated);
41   if (isNode(theNode, NODE_FEATURE, NULL)) {
42     Event_Loop* aEvLoop = Event_Loop::loop();
43     Config_FeatureMessage aMessage(aMenuItemEvent, this);
44     fillFeature(theNode, aMessage);
45     aEvLoop->send(aMessage);
46   }
47   //The m_last* variables always defined before fillFeature() call. XML is a tree.
48   if (isNode(theNode, NODE_GROUP, NULL)) {
49     myLastGroup = getProperty(theNode, _ID);
50   }
51   if (isNode(theNode, NODE_WORKBENCH, NULL)) {
52     myLastWorkbench = getProperty(theNode, _ID);
53   }
54 }
55
56 bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
57 {
58   return isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL);
59 }
60
61 void Config_FeatureReader::fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFtMessage)
62 {
63   outFtMessage.setId(getProperty(theRoot, _ID));
64   outFtMessage.setText(getProperty(theRoot, FEATURE_TEXT));
65   outFtMessage.setTooltip(getProperty(theRoot, FEATURE_TOOLTIP));
66   outFtMessage.setIcon(getProperty(theRoot, FEATURE_ICON));
67   outFtMessage.setKeysequence(getProperty(theRoot, FEATURE_KEYSEQUENCE));
68   outFtMessage.setGroupId(myLastGroup);
69   outFtMessage.setWorkbenchId(myLastWorkbench);
70   outFtMessage.setPluginLibrary(myLibraryName);
71 }