]> SALOME platform Git repositories - modules/shaper.git/blob - src/Config/Config_ModuleReader.h
Salome HOME
cdfae0a43f46eaa6e8e2310a3c25a728708febbb
[modules/shaper.git] / src / Config / Config_ModuleReader.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * Config_XMLModuleReader.h
5  *
6  *  Created on: Mar 20, 2014
7  *      Author: sbh
8  */
9
10 #ifndef CONFIG_MODULEREADER_H_
11 #define CONFIG_MODULEREADER_H_
12
13 #include <Config_def.h>
14 #include <Config_XMLReader.h>
15
16 #include <map>
17 #include <list>
18 #include <set>
19 #include <string>
20
21 class Config_ModuleReader : public Config_XMLReader
22 {
23   enum PluginType {
24     Binary = 0,
25     Intrenal = 1,
26     Python = 2
27   };
28
29  public:
30   CONFIG_EXPORT Config_ModuleReader(const char* theEventGenerated = 0);
31   CONFIG_EXPORT virtual ~Config_ModuleReader();
32
33   CONFIG_EXPORT const std::map<std::string, std::string>& featuresInFiles() const;
34
35   CONFIG_EXPORT std::string getModuleName();
36
37   CONFIG_EXPORT static void loadPlugin(const std::string& thePluginName);
38   /// loads the library with specific name, appends "lib*.dll" or "*.so" depending on the platform
39   CONFIG_EXPORT static void loadLibrary(const std::string& theLibName);
40   /// loads the python module with specified name
41   CONFIG_EXPORT static void loadScript(const std::string& theFileName);
42   // extends set of modules, which will be used for dependency 
43   // checking (if there is no required module in the set, a plugin will not be loaded)
44   CONFIG_EXPORT static void addDependencyModule(const std::string& theModuleName);
45
46  protected:
47   void processNode(xmlNodePtr aNode);
48   bool processChildren(xmlNodePtr aNode);
49
50   bool hasRequiredModules(xmlNodePtr aNode) const;
51   std::list<std::string> importPlugin(const std::string& thePluginLibrary,
52                                       const std::string& thePluginFile);
53   std::string addPlugin(const std::string& aPluginLibrary,
54                         const std::string& aPluginScript,
55                         const std::string& aPluginConf);
56
57  private:
58   std::map<std::string, std::string> myFeaturesInFiles;
59   static std::map<std::string, PluginType> myPluginTypes;
60   static std::set<std::string> myDependencyModules;
61   const char* myEventGenerated;
62 };
63
64 #endif /* CONFIG_XMLMODULEREADER_H_ */