]> SALOME platform Git repositories - modules/shaper.git/blob - src/Config/Config_ModuleReader.cpp
Salome HOME
e09904422da317927f2ee127120cb91f92c3ccee
[modules/shaper.git] / src / Config / Config_ModuleReader.cpp
1 /*
2  * Config_ModuleReader.cpp
3  *
4  *  Created on: Mar 20, 2014
5  *      Author: sbh
6  */
7
8 #include <Config_ModuleReader.h>
9 #include <Config_FeatureReader.h>
10
11 #include <libxml\parser.h>
12 #include <libxml\tree.h>
13
14 #ifdef _DEBUG
15 #include <iostream>
16 #endif
17
18 Config_ModuleReader::Config_ModuleReader()
19     : Config_XMLReader("plugins.xml"),
20       m_isAutoImport(false)
21 {
22 }
23
24 Config_ModuleReader::~Config_ModuleReader()
25 {
26 }
27
28 /*
29  * Get module name from plugins.xml
30  * (property "module")
31  */
32 std::string Config_ModuleReader::getModuleName()
33 {
34   xmlNodePtr aRoot = findRoot();
35   return getProperty(aRoot, "module");
36 }
37
38 /*
39  *
40  */
41 void Config_ModuleReader::processNode(xmlNodePtr theNode)
42 {
43   if(isNode(theNode, "plugin")) {
44     std::string aPluginName = getProperty(theNode, "configuration");
45     if(m_isAutoImport)
46       importPlugin(aPluginName);
47     m_pluginsList.push_back(aPluginName);
48   }
49 }
50
51 bool Config_ModuleReader::processChildren(xmlNodePtr theNode)
52 {
53   return isNode(theNode, "plugins");
54 }
55
56 void Config_ModuleReader::importPlugin(const std::string& thePluginName)
57 {
58   Config_FeatureReader aReader(thePluginName);
59   aReader.readAll();
60 }
61
62 void Config_ModuleReader::setAutoImport(bool enabled)
63 {
64   m_isAutoImport = enabled;
65 }
66
67 const std::list<std::string>& Config_ModuleReader::pluginsList() const
68 {
69   return m_pluginsList;
70 }