Salome HOME
All the git "*.orig" files removed and will be ignored since this commit.
[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 //Hardcoded xml entities
19 // * Nodes
20 const static char* NODE_PLUGIN = "plugin";
21 const static char* NODE_PLUGINS = "plugins";
22
23 // * Properties
24 const static char* PLUGINS_MODULE = "module";
25 const static char* PLUGIN_CONFIG = "configuration";
26 const static char* PLUGIN_LIBRARY = "library";
27
28
29 Config_ModuleReader::Config_ModuleReader()
30     : Config_XMLReader("plugins.xml"),
31       m_isAutoImport(false)
32 {
33 }
34
35 Config_ModuleReader::~Config_ModuleReader()
36 {
37 }
38
39 /*
40  * Get module name from plugins.xml
41  * (property "module")
42  */
43 std::string Config_ModuleReader::getModuleName()
44 {
45   xmlNodePtr aRoot = findRoot();
46   return getProperty(aRoot, PLUGINS_MODULE);
47 }
48
49 /*
50  *
51  */
52 void Config_ModuleReader::processNode(xmlNodePtr theNode)
53 {
54   if(isNode(theNode, NODE_PLUGIN, NULL)) {
55     std::string aPluginName = getProperty(theNode, PLUGIN_CONFIG);
56     if(m_isAutoImport)
57       importPlugin(aPluginName);
58     m_pluginsList.push_back(aPluginName);
59   }
60 }
61
62 bool Config_ModuleReader::processChildren(xmlNodePtr theNode)
63 {
64   return isNode(theNode, NODE_PLUGINS, NULL);
65 }
66
67 void Config_ModuleReader::importPlugin(const std::string& thePluginName)
68 {
69   Config_FeatureReader aReader(thePluginName);
70   aReader.readAll();
71 }
72
73 void Config_ModuleReader::setAutoImport(bool enabled)
74 {
75   m_isAutoImport = enabled;
76 }
77
78 const std::list<std::string>& Config_ModuleReader::pluginsList() const
79 {
80   return m_pluginsList;
81 }