ADD_SUBDIRECTORY (src/GeomApp)
ADD_SUBDIRECTORY (src/ExchangePlugin)
ADD_SUBDIRECTORY (src/GeomValidators)
-ADD_SUBDIRECTORY (src/ConnectorPlugin)
IF(${HAVE_SALOME})
ADD_SUBDIRECTORY (src/NewGeom)
+ ADD_SUBDIRECTORY (src/ConnectorPlugin)
ENDIF(${HAVE_SALOME})
ENABLE_TESTING()
const static char* PLUGIN_CONFIG = "configuration";
const static char* PLUGIN_LIBRARY = "library";
const static char* PLUGIN_SCRIPT = "script";
-const static char* PLUGIN_PLATFORM = "platform";
+const static char* PLUGIN_DEPENDENCY = "dependency";
const static char* PLUGIN_PLATFORM_SALOME = "salome";
const static char* PLUGIN_PLATFORM_NEWGEOM = "openparts";
#endif
std::map<std::string, Config_ModuleReader::PluginType> Config_ModuleReader::myPluginTypes;
+std::set<std::string> Config_ModuleReader::myDependencyModules;
Config_ModuleReader::Config_ModuleReader(const char* theEventGenerated)
: Config_XMLReader(PLUGIN_FILE),
myEventGenerated(theEventGenerated)
{
- myHaveSalome = false;
- char* anEnv = getenv("SALOME_ROOT_DIR");
- std::string value = normalize(anEnv);
- if (!value.empty()) {
- myHaveSalome = true;
- }
-
}
Config_ModuleReader::~Config_ModuleReader()
void Config_ModuleReader::processNode(xmlNodePtr theNode)
{
if (isNode(theNode, NODE_PLUGIN, NULL)) {
- bool isAvailable = isAvaliableOnThisPlatform(getProperty(theNode, PLUGIN_PLATFORM));
- if (!isAvailable)
+ if (!hasRequiredModules(theNode))
return;
std::string aPluginConf = getProperty(theNode, PLUGIN_CONFIG);
std::string aPluginLibrary = getProperty(theNode, PLUGIN_LIBRARY);
return isNode(theNode, NODE_PLUGINS, NULL);
}
+bool Config_ModuleReader::hasRequiredModules(xmlNodePtr theNode) const
+{
+ std::string aRequiredModule = normalize(getProperty(theNode, PLUGIN_DEPENDENCY));
+ if(aRequiredModule.empty())
+ return true;
+ std::set<std::string>::iterator it = myDependencyModules.begin();
+ for ( ; it != myDependencyModules.end(); it++ ) {
+ if (*it == aRequiredModule) return true;
+ }
+ return false;
+}
+
std::list<std::string> Config_ModuleReader::importPlugin(const std::string& thePluginLibrary,
const std::string& thePluginXmlConf)
{
if(!aPluginName.empty()) {
myPluginTypes[aPluginName] = aType;
}
-
+ addDependencyModule(aPluginName);
return aPluginName;
}
-void Config_ModuleReader::loadPlugin(const std::string thePluginName)
+void Config_ModuleReader::loadPlugin(const std::string& thePluginName)
{
PluginType aType = Config_ModuleReader::Binary;
if(myPluginTypes.find(thePluginName) != myPluginTypes.end()) {
}
}
-bool Config_ModuleReader::isAvaliableOnThisPlatform(const std::string& thePluginPlatform)
-{
- bool result = true;
- PluginPlatform aPlatform = All;
- std::string aPlatformName = normalize(thePluginPlatform) ;
- if (aPlatformName == PLUGIN_PLATFORM_SALOME) {
- aPlatform = Salome;
- } else if (aPlatformName == PLUGIN_PLATFORM_NEWGEOM) {
- aPlatform = OpenParts;
- } else if (!thePluginPlatform.empty()) {
- Events_Error::send("Unknown platform: " + thePluginPlatform);
- }
- if (aPlatform == All) {
- result = true;
- } else if (myHaveSalome) {
- result = aPlatform == Salome;
- } else {
- result = aPlatform == OpenParts;
- }
- return result;
-
-}
-
-void Config_ModuleReader::loadScript(const std::string theFileName)
+void Config_ModuleReader::loadScript(const std::string& theFileName)
{
/* aquire python thread */
PyGILState_STATE gstate = PyGILState_Ensure();
PyGILState_Release(gstate);
}
-void Config_ModuleReader::loadLibrary(const std::string theLibName)
+void Config_ModuleReader::loadLibrary(const std::string& theLibName)
{
std::string aFileName = library(theLibName);
if (aFileName.empty())
}
}
+void Config_ModuleReader::addDependencyModule(const std::string& theModuleName)
+{
+ myDependencyModules.insert(normalize(theModuleName));
+}
+
#include <map>
#include <list>
+#include <set>
#include <string>
class Config_ModuleReader : public Config_XMLReader
Intrenal = 1,
Python = 2
};
- enum PluginPlatform {
- All = 0,
- OpenParts = 1,
- Salome = 2
- };
public:
CONFIG_EXPORT Config_ModuleReader(const char* theEventGenerated = 0);
CONFIG_EXPORT std::string getModuleName();
- CONFIG_EXPORT static void loadPlugin(const std::string thePluginName);
+ 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, which will be 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);
- bool isAvaliableOnThisPlatform(const std::string& thePluginPlatform);
+ bool hasRequiredModules(xmlNodePtr aNode) const;
std::list<std::string> importPlugin(const std::string& thePluginLibrary,
const std::string& thePluginFile);
std::string addPlugin(const std::string& aPluginLibrary,
private:
std::map<std::string, std::string> myFeaturesInFiles;
static std::map<std::string, PluginType> myPluginTypes;
+ static std::set<std::string> myDependencyModules;
const char* myEventGenerated;
- bool myHaveSalome;
-
};
#endif /* CONFIG_XMLMODULEREADER_H_ */
<plugin library="ConstructionPlugin" configuration="plugin-Construction.xml"/>
<plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
<plugin library="ExchangePlugin" configuration="plugin-Exchange.xml"/>
- <plugin script="ConnectorPlugin" configuration="plugin-Connector.xml" platform="Salome"/>
+ <plugin script="ConnectorPlugin" configuration="plugin-Connector.xml" dependency="Geometry"/>
<plugin library="SketchSolver"/>
<plugin library="GeomValidators"/>
<plugin library="DFBrowser" internal="true"/>
#include <QtxResourceMgr.h>
#include <Config_PropManager.h>
+#include <Config_ModuleReader.h>
#include <QDockWidget>
#include <QAction>
void NewGeom_Module::initialize(CAM_Application* theApp)
{
LightApp_Module::initialize(theApp);
+ inspectSalomeModules();
myWorkshop->startApplication();
LightApp_Application* anApp = dynamic_cast<LightApp_Application*>(theApp);
aProp->setValue(aValue);
}
+
+void NewGeom_Module::inspectSalomeModules()
+{
+ QStringList aModuleNames;
+ getApp()->modules(aModuleNames, false);
+ foreach(QString eachModule, aModuleNames) {
+ Config_ModuleReader::addDependencyModule(eachModule.toStdString());
+ }
+}
void setIsOpened(bool theOpened) { myIsOpened = theOpened; }
+ void inspectSalomeModules();
+
public slots:
virtual bool activateModule(SUIT_Study* theStudy);
virtual bool deactivateModule(SUIT_Study* theStudy);