SHAPER  9.12.0
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
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.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // Lesser General Public License for more details.
12 //
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
16 //
17 // See or email :
18 //
23 #include <Config_def.h>
24 #include <Config_XMLReader.h>
26 #include <map>
27 #include <list>
28 #include <set>
29 #include <string>
37 {
38  enum PluginType {
39  Binary = 0,
40  Intrenal = 1,
41  Python = 2
42  };
44  public:
46  CONFIG_EXPORT Config_ModuleReader(const char* theEventGenerated = 0);
48  CONFIG_EXPORT virtual ~Config_ModuleReader();
51  CONFIG_EXPORT const std::map<std::string, std::string>& featuresInFiles() const;
55  CONFIG_EXPORT const std::map<std::string, std::string>& proprietaryFeatures() const;
57  CONFIG_EXPORT const std::set<std::string>& proprietaryPlugins() const;
59  CONFIG_EXPORT const std::set<std::string>& modulePluginFiles() const;
62  CONFIG_EXPORT std::string getModuleName();
64  CONFIG_EXPORT static void loadPlugin(const std::string& thePluginName);
66  CONFIG_EXPORT static void loadLibrary(const std::string& theLibName);
70  CONFIG_EXPORT static void loadScript(const std::string& theFileName, bool theSendErr = true);
75  CONFIG_EXPORT static void addDependencyModule(const std::string& theModuleName);
77  protected:
79  virtual void processNode(xmlNodePtr aNode);
81  virtual bool processChildren(xmlNodePtr aNode);
83  bool hasRequiredModules(xmlNodePtr aNode) const;
85  std::list<std::string> importPlugin(const std::string& thePluginLibrary,
86  const std::string& thePluginFile,
87  const std::string& thePluginDocSection);
89  std::string addPlugin(const std::string& aPluginLibrary,
90  const std::string& aPluginScript,
91  const std::string& aPluginConf);
94  void addFeature(const std::string& theFeatureName, const std::string& thePluginConfig);
97  void addFeatureRequireLicense(const std::string& theFeatureName,
98  const std::string& thePluginConfig);
100  private:
101  std::map<std::string, std::string> myFeaturesInFiles;
103  std::map<std::string, std::string> myProprietaryFeatures;
104  std::set<std::string> myPluginFiles;
106  static std::map<std::string, PluginType> myPluginTypes;
107  static std::set<std::string> myDependencyModules;
108  const char* myEventGenerated;
110  std::set<std::string> myProprietaryPlugins;
111 };
Class to process plugins.xml - definition of plugins (scripts, libraries).
Definition: Config_ModuleReader.h:37
CONFIG_EXPORT const std::set< std::string > & proprietaryPlugins() const
Returns proprietary plugins.
Definition: Config_ModuleReader.cpp:70
CONFIG_EXPORT const std::map< std::string, std::string > & proprietaryFeatures() const
Returns map containing features, which have licensed.
Definition: Config_ModuleReader.cpp:65
CONFIG_EXPORT const std::set< std::string > & modulePluginFiles() const
Returns list of module's xml files.
Definition: Config_ModuleReader.cpp:75
CONFIG_EXPORT Config_ModuleReader(const char *theEventGenerated=0)
Definition: Config_ModuleReader.cpp:50
void addFeature(const std::string &theFeatureName, const std::string &thePluginConfig)
Save feature in myFeaturesInFiles.
Definition: Config_ModuleReader.cpp:91
virtual void processNode(xmlNodePtr aNode)
Recursively process the given xmlNode.
Definition: Config_ModuleReader.cpp:124
CONFIG_EXPORT std::string getModuleName()
Returns module name: an xml attribute from the root of the plugins.xml: e.g.
Definition: Config_ModuleReader.cpp:84
static CONFIG_EXPORT void addDependencyModule(const std::string &theModuleName)
Definition: Config_ModuleReader.cpp:425
std::string addPlugin(const std::string &aPluginLibrary, const std::string &aPluginScript, const std::string &aPluginConf)
stores information about plugin in the internal cache
Definition: Config_ModuleReader.cpp:195
virtual CONFIG_EXPORT ~Config_ModuleReader()
Definition: Config_ModuleReader.cpp:56
bool hasRequiredModules(xmlNodePtr aNode) const
check if dependencies of the given node are in the list of loaded modules
Definition: Config_ModuleReader.cpp:166
virtual bool processChildren(xmlNodePtr aNode)
Defines if the reader should process children of the given node.
Definition: Config_ModuleReader.cpp:161
CONFIG_EXPORT const std::map< std::string, std::string > & featuresInFiles() const
Returns map that describes which file contains a feature (the feature is key, the file is value)
Definition: Config_ModuleReader.cpp:60
static CONFIG_EXPORT void loadScript(const std::string &theFileName, bool theSendErr=true)
loads the python module with specified name
Definition: Config_ModuleReader.cpp:369
void addFeatureRequireLicense(const std::string &theFeatureName, const std::string &thePluginConfig)
Save feature in myFeaturesRequireLicense.
Definition: Config_ModuleReader.cpp:109
static CONFIG_EXPORT void loadLibrary(const std::string &theLibName)
loads the library with specific name, appends "lib*.dll" or "*.so" depending on the platform
Definition: Config_ModuleReader.cpp:391
std::list< std::string > importPlugin(const std::string &thePluginLibrary, const std::string &thePluginFile, const std::string &thePluginDocSection)
reads info about plugin's features from plugin xml description
Definition: Config_ModuleReader.cpp:178
static CONFIG_EXPORT void loadPlugin(const std::string &thePluginName)
Detects type of the given plugin and loads it using loadLibrary or loadScript.
Definition: Config_ModuleReader.cpp:217
Base class for all libxml readers. Provides high-level API for all xml operations.
Definition: Config_XMLReader.h:48