X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConfig%2FConfig_ModuleReader.h;h=a50fd028c75e90540dd09235a2e5382dd608a790;hb=28f4045c9be1df4b9fb76b5b01f32f4c78293dfe;hp=3bd5d39f3f75c8289f5566e5fc44ec8bfc1e553f;hpb=47933cff9cf39f2d420b8a772ac125d2a969d2b5;p=modules%2Fshaper.git diff --git a/src/Config/Config_ModuleReader.h b/src/Config/Config_ModuleReader.h index 3bd5d39f3..a50fd028c 100644 --- a/src/Config/Config_ModuleReader.h +++ b/src/Config/Config_ModuleReader.h @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + /* * Config_XMLModuleReader.h * @@ -13,35 +15,69 @@ #include #include +#include #include - -class Config_ModuleReader: public Config_XMLReader +/*! + * \class Config_ModuleReader + * \ingroup Config + * \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: + 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& featuresInFiles() const; - + /// Returns list of module's xml files + CONFIG_EXPORT const std::set& modulePluginFiles() const; + /// Returns module name: an xml attribute from the root of the plugins.xml: + /// e.g \code \endcode CONFIG_EXPORT std::string getModuleName(); - + /// 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); - -protected: - void processNode(xmlNodePtr aNode); - bool processChildren(xmlNodePtr aNode); + 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, 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: + /// 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 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); + /// Save feature in myFeaturesInFiles. Generates an error if the feature name is already registered. + void addFeature(const std::string& theFeatureName, const std::string& thePluginConfig); - -private: - std::map myFeaturesInFiles; - const char* myEventGenerated; - + private: + std::map myFeaturesInFiles; ///< a feature name is key, a file is value + std::set myPluginFiles; ///< a feature name is key, a file is value + static std::map myPluginTypes; ///< a plugin name is key, a plugin type is value + static std::set myDependencyModules; ///< set of loaded modules + const char* myEventGenerated; ///< gives ability to send Feature_Messages to various listeners }; #endif /* CONFIG_XMLMODULEREADER_H_ */