1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 * Config_XMLModuleReader.h
6 * Created on: Mar 20, 2014
10 #ifndef CONFIG_MODULEREADER_H_
11 #define CONFIG_MODULEREADER_H_
13 #include <Config_def.h>
14 #include <Config_XMLReader.h>
22 * \class Config_ModuleReader
24 * \brief Class to process plugins.xml - definition of plugins (scripts, libraries).
26 class Config_ModuleReader : public Config_XMLReader
36 CONFIG_EXPORT Config_ModuleReader(const char* theEventGenerated = 0);
38 CONFIG_EXPORT virtual ~Config_ModuleReader();
39 /// Returns map that describes which file contains a feature (the feature is key, the file is value)
40 CONFIG_EXPORT const std::map<std::string, std::string>& featuresInFiles() const;
41 /// Returns list of module's xml files
42 CONFIG_EXPORT const std::set<std::string>& modulePluginFiles() const;
43 /// Returns module name: an xml attribute from the root of the plugins.xml:
44 /// e.g \code <plugins module="PartSet"> \endcode
45 CONFIG_EXPORT std::string getModuleName();
46 /// Detects type of the given plugin and loads it using loadLibrary or loadScript.
47 CONFIG_EXPORT static void loadPlugin(const std::string& thePluginName);
48 /// loads the library with specific name, appends "lib*.dll" or "*.so" depending on the platform
49 CONFIG_EXPORT static void loadLibrary(const std::string& theLibName);
50 /// loads the python module with specified name
51 CONFIG_EXPORT static void loadScript(const std::string& theFileName);
53 * Extends set of modules, used for dependency checking (if there is no
54 * required module in the set, a plugin will not be loaded)
56 CONFIG_EXPORT static void addDependencyModule(const std::string& theModuleName);
59 /// Recursively process the given xmlNode
60 virtual void processNode(xmlNodePtr aNode);
61 /// Defines if the reader should process children of the given node
62 virtual bool processChildren(xmlNodePtr aNode);
63 /// check if dependencies of the given node are in the list of loaded modules
64 bool hasRequiredModules(xmlNodePtr aNode) const;
65 /// reads info about plugin's features from plugin xml description
66 std::list<std::string> importPlugin(const std::string& thePluginLibrary,
67 const std::string& thePluginFile);
68 /// stores information about plugin in the internal cache
69 std::string addPlugin(const std::string& aPluginLibrary,
70 const std::string& aPluginScript,
71 const std::string& aPluginConf);
72 /// Save feature in myFeaturesInFiles. Generates an error if the feature name is already registered.
73 void addFeature(const std::string& theFeatureName, const std::string& thePluginConfig);
76 std::map<std::string, std::string> myFeaturesInFiles; ///< a feature name is key, a file is value
77 std::set<std::string> myPluginFiles; ///< a feature name is key, a file is value
78 static std::map<std::string, PluginType> myPluginTypes; ///< a plugin name is key, a plugin type is value
79 static std::set<std::string> myDependencyModules; ///< set of loaded modules
80 const char* myEventGenerated; ///< gives ability to send Feature_Messages to various listeners
83 #endif /* CONFIG_XMLMODULEREADER_H_ */