Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[modules/shaper.git] / src / Config / Config_ModuleReader.h
index 2281eb5cd33910e46bd16949e25b8b8b7afe6f7e..bef9c61246a6c149cce31154c9c9dc5eb1d2d5a1 100644 (file)
 
 #include <map>
 #include <list>
+#include <set>
 #include <string>
 
+/*!
+ * \class Config_ModuleReader
+ * \ingroup Config
+ * \brief Class to process plugins.xml - definition of plugins (scripts, libraries).
+ */
 class Config_ModuleReader : public Config_XMLReader
 {
   enum PluginType {
@@ -26,34 +32,50 @@ class Config_ModuleReader : public Config_XMLReader
   };
 
  public:
+  /// Constructor
   CONFIG_EXPORT Config_ModuleReader(const char* theEventGenerated = 0);
+  /// Destructor
   CONFIG_EXPORT virtual ~Config_ModuleReader();
-
+  /// Returns map that describes which file contains a feature (the feature is key, the file is value)
   CONFIG_EXPORT const std::map<std::string, std::string>& featuresInFiles() const;
-
+  /// Returns list of module's xml files
+  CONFIG_EXPORT const std::set<std::string>& modulePluginFiles() const;
+  /// Returns module name: an xml attribute from the root of the plugins.xml:
+  /// e.g \code <plugins module="PartSet"> \endcode 
   CONFIG_EXPORT std::string getModuleName();
-
-  CONFIG_EXPORT static void loadPlugin(const std::string thePluginName);
+  /// Detects type of the given plugin and loads it using loadLibrary or loadScript.
+  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);
+  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);
+  CONFIG_EXPORT static void loadScript(const std::string& theFileName);
+  /*!
+   * Extends set of modules,  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);
-
+  /// Recursively process the given xmlNode
+  virtual void processNode(xmlNodePtr aNode);
+  /// Defines if the reader should process children of the given node
+  virtual bool processChildren(xmlNodePtr aNode);
+  /// check if dependencies of the given node are in the list of loaded modules
+  bool hasRequiredModules(xmlNodePtr aNode) const;
+  /// reads info about plugin's features from plugin xml description
   std::list<std::string> importPlugin(const std::string& thePluginLibrary,
                                       const std::string& thePluginFile);
+  /// stores information about plugin in the internal cache
   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;
-  const char* myEventGenerated;
-
+  std::map<std::string, std::string> myFeaturesInFiles; ///< a feature name is key, a file is value
+  std::set<std::string> myPluginFiles; ///< a feature name is key, a file is value
+  static std::map<std::string, PluginType> myPluginTypes; ///< a plugin name is key, a plugin type is value
+  static std::set<std::string> myDependencyModules; ///< set of loaded modules
+  const char* myEventGenerated; ///< gives ability to send Feature_Messages to various listeners
 };
 
 #endif /* CONFIG_XMLMODULEREADER_H_ */