2 * Config_ModuleReader.cpp
4 * Created on: Mar 20, 2014
8 #include <Config_ModuleReader.h>
9 #include <Config_FeatureReader.h>
11 #include <libxml\parser.h>
12 #include <libxml\tree.h>
18 //Hardcoded xml entities
20 const static char* NODE_PLUGIN = "plugin";
21 const static char* NODE_PLUGINS = "plugins";
24 const static char* PLUGINS_MODULE = "module";
25 const static char* PLUGIN_CONFIG = "configuration";
26 const static char* PLUGIN_LIBRARY = "library";
28 Config_ModuleReader::Config_ModuleReader()
29 : Config_XMLReader("plugins.xml"), myIsAutoImport(false)
33 Config_ModuleReader::~Config_ModuleReader()
38 * Get module name from plugins.xml
41 std::string Config_ModuleReader::getModuleName()
43 xmlNodePtr aRoot = findRoot();
44 return getProperty(aRoot, PLUGINS_MODULE);
50 void Config_ModuleReader::processNode(xmlNodePtr theNode)
52 if (isNode(theNode, NODE_PLUGIN, NULL)) {
53 std::string aPluginConf = getProperty(theNode, PLUGIN_CONFIG);
54 std::string aPluginLibrary = getProperty(theNode, PLUGIN_LIBRARY);
56 importPlugin(aPluginConf, aPluginLibrary);
57 myPluginsMap[aPluginLibrary] = aPluginConf;
61 bool Config_ModuleReader::processChildren(xmlNodePtr theNode)
63 return isNode(theNode, NODE_PLUGINS, NULL);
66 void Config_ModuleReader::importPlugin(const std::string& thePluginName,
67 const std::string& thePluginLibrary)
69 Config_FeatureReader* aReader;
70 if(thePluginLibrary.empty()) {
71 aReader = new Config_FeatureReader(thePluginName);
73 aReader = new Config_FeatureReader(thePluginName, thePluginLibrary);
78 void Config_ModuleReader::setAutoImport(bool theEnabled)
80 myIsAutoImport = theEnabled;
83 const std::map<std::string, std::string>& Config_ModuleReader::plugins() const