Salome HOME
FIx for issue #360 : make switching on/off checking of transactions in Session -...
[modules/shaper.git] / src / Config / Config_ModuleReader.h
index 4bd958f5150cdd2b8439a85fcefb3bfbfe20812a..911e5d813c8afa10b11f37a859812378cccb5202 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_XMLModuleReader.h
  *
 #ifndef CONFIG_MODULEREADER_H_
 #define CONFIG_MODULEREADER_H_
 
+#include <Config_def.h>
 #include <Config_XMLReader.h>
 
+#include <map>
 #include <list>
+#include <set>
+#include <string>
 
-class CONFIG_EXPORT Config_ModuleReader: public Config_XMLReader
+/*!
+ * \class Config_ModuleReader
+ * \brief Class to process plugins.xml - definition of plugins (scripts, libraries).
+ */
+class Config_ModuleReader : public Config_XMLReader
 {
+  enum PluginType {
+    Binary = 0,
+    Intrenal = 1,
+    Python = 2
+  };
 
-public:
-  Config_ModuleReader();
-  virtual ~Config_ModuleReader();
+ public:
+  CONFIG_EXPORT Config_ModuleReader(const char* theEventGenerated = 0);
+  CONFIG_EXPORT virtual ~Config_ModuleReader();
 
-  void setAutoImport(bool enabled);
-  const std::list<std::string>& pluginsList() const;
+  CONFIG_EXPORT const std::map<std::string, std::string>& featuresInFiles() const;
 
-  std::string getModuleName();
+  CONFIG_EXPORT std::string getModuleName();
 
-protected:
+  CONFIG_EXPORT static void loadPlugin(const std::string& thePluginName);
+  /// loads the library with specific name, appends "lib*.dll" or "*.so" depending on the platform
+  CONFIG_EXPORT static void loadLibrary(const std::string& theLibName);
+  /// loads the python module with specified name
+  CONFIG_EXPORT static void loadScript(const std::string& theFileName);
+  // extends set of modules, which will be used for dependency 
+  // checking (if there is no required module in the set, a plugin will not be loaded)
+  CONFIG_EXPORT static void addDependencyModule(const std::string& theModuleName);
+
+ protected:
   void processNode(xmlNodePtr aNode);
   bool processChildren(xmlNodePtr aNode);
 
-  void importPlugin(const std::string& thePluginName);
-
-private:
-  bool m_isAutoImport;
-  std::list<std::string> m_pluginsList;
+  bool hasRequiredModules(xmlNodePtr aNode) const;
+  std::list<std::string> importPlugin(const std::string& thePluginLibrary,
+                                      const std::string& thePluginFile);
+  std::string addPlugin(const std::string& aPluginLibrary,
+                        const std::string& aPluginScript,
+                        const std::string& aPluginConf);
 
+ private:
+  std::map<std::string, std::string> myFeaturesInFiles;
+  static std::map<std::string, PluginType> myPluginTypes;
+  static std::set<std::string> myDependencyModules;
+  const char* myEventGenerated;
 };
 
 #endif /* CONFIG_XMLMODULEREADER_H_ */