Salome HOME
911e5d813c8afa10b11f37a859812378cccb5202
[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 /*!
22  * \class Config_ModuleReader
23  * \brief Class to process plugins.xml - definition of plugins (scripts, libraries).
24  */
25 class Config_ModuleReader : public Config_XMLReader
26 {
27   enum PluginType {
28     Binary = 0,
29     Intrenal = 1,
30     Python = 2
31   };
32
33  public:
34   CONFIG_EXPORT Config_ModuleReader(const char* theEventGenerated = 0);
35   CONFIG_EXPORT virtual ~Config_ModuleReader();
36
37   CONFIG_EXPORT const std::map<std::string, std::string>& featuresInFiles() const;
38
39   CONFIG_EXPORT std::string getModuleName();
40
41   CONFIG_EXPORT static void loadPlugin(const std::string& thePluginName);
42   /// loads the library with specific name, appends "lib*.dll" or "*.so" depending on the platform
43   CONFIG_EXPORT static void loadLibrary(const std::string& theLibName);
44   /// loads the python module with specified name
45   CONFIG_EXPORT static void loadScript(const std::string& theFileName);
46   // extends set of modules, which will be used for dependency 
47   // checking (if there is no required module in the set, a plugin will not be loaded)
48   CONFIG_EXPORT static void addDependencyModule(const std::string& theModuleName);
49
50  protected:
51   void processNode(xmlNodePtr aNode);
52   bool processChildren(xmlNodePtr aNode);
53
54   bool hasRequiredModules(xmlNodePtr aNode) const;
55   std::list<std::string> importPlugin(const std::string& thePluginLibrary,
56                                       const std::string& thePluginFile);
57   std::string addPlugin(const std::string& aPluginLibrary,
58                         const std::string& aPluginScript,
59                         const std::string& aPluginConf);
60
61  private:
62   std::map<std::string, std::string> myFeaturesInFiles;
63   static std::map<std::string, PluginType> myPluginTypes;
64   static std::set<std::string> myDependencyModules;
65   const char* myEventGenerated;
66 };
67
68 #endif /* CONFIG_XMLMODULEREADER_H_ */