1 // Copyright (C) 2014-2023 CEA, EDF
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef CONFIG_MODULEREADER_H_
21 #define CONFIG_MODULEREADER_H_
23 #include <Config_def.h>
24 #include <Config_XMLReader.h>
32 * \class Config_ModuleReader
34 * \brief Class to process plugins.xml - definition of plugins (scripts, libraries).
36 class Config_ModuleReader : public Config_XMLReader
46 CONFIG_EXPORT Config_ModuleReader(const char* theEventGenerated = 0);
48 CONFIG_EXPORT virtual ~Config_ModuleReader();
49 /// Returns map that describes which file contains a feature
50 /// (the feature is key, the file is value)
51 CONFIG_EXPORT const std::map<std::string, std::string>& featuresInFiles() const;
52 /// Returns map containing features, which have licensed.
53 /// The valid license should be confirmed first
54 /// (the feature is key, the file is value)
55 CONFIG_EXPORT const std::map<std::string, std::string>& proprietaryFeatures() const;
56 /// Returns proprietary plugins
57 CONFIG_EXPORT const std::set<std::string>& proprietaryPlugins() const;
58 /// Returns list of module's xml files
59 CONFIG_EXPORT const std::set<std::string>& modulePluginFiles() const;
60 /// Returns module name: an xml attribute from the root of the plugins.xml:
61 /// e.g \code <plugins module="PartSet"> \endcode
62 CONFIG_EXPORT std::string getModuleName();
63 /// Detects type of the given plugin and loads it using loadLibrary or loadScript.
64 CONFIG_EXPORT static void loadPlugin(const std::string& thePluginName);
65 /// loads the library with specific name, appends "lib*.dll" or "*.so" depending on the platform
66 CONFIG_EXPORT static void loadLibrary(const std::string& theLibName);
67 /// loads the python module with specified name
68 /// \param theFileName name of the script
69 /// \param theSendErr send error message in case of faile
70 CONFIG_EXPORT static void loadScript(const std::string& theFileName, bool theSendErr = true);
72 * Extends set of modules, used for dependency checking (if there is no
73 * required module in the set, a plugin will not be loaded)
75 CONFIG_EXPORT static void addDependencyModule(const std::string& theModuleName);
78 /// Recursively process the given xmlNode
79 virtual void processNode(xmlNodePtr aNode);
80 /// Defines if the reader should process children of the given node
81 virtual bool processChildren(xmlNodePtr aNode);
82 /// check if dependencies of the given node are in the list of loaded modules
83 bool hasRequiredModules(xmlNodePtr aNode) const;
84 /// reads info about plugin's features from plugin xml description
85 std::list<std::string> importPlugin(const std::string& thePluginLibrary,
86 const std::string& thePluginFile,
87 const std::string& thePluginDocSection);
88 /// stores information about plugin in the internal cache
89 std::string addPlugin(const std::string& aPluginLibrary,
90 const std::string& aPluginScript,
91 const std::string& aPluginConf);
92 /// Save feature in myFeaturesInFiles.
93 /// Generates an error if the feature name is already registered.
94 void addFeature(const std::string& theFeatureName, const std::string& thePluginConfig);
95 /// Save feature in myFeaturesRequireLicense.
96 /// Generates an error if the feature name is already registered.
97 void addFeatureRequireLicense(const std::string& theFeatureName,
98 const std::string& thePluginConfig);
101 std::map<std::string, std::string> myFeaturesInFiles; ///< a feature name is key, a file is value
102 /// list of features, which need a license, and their config files
103 std::map<std::string, std::string> myProprietaryFeatures;
104 std::set<std::string> myPluginFiles; ///< a feature name is key, a file is value
105 /// a plugin name is key, a plugin type is value
106 static std::map<std::string, PluginType> myPluginTypes;
107 static std::set<std::string> myDependencyModules; ///< set of loaded modules
108 const char* myEventGenerated; ///< gives ability to send Feature_Messages to various listeners
110 std::set<std::string> myProprietaryPlugins; ///< list of plugins protected by license
113 #endif /* CONFIG_XMLMODULEREADER_H_ */