From 7bc80aeb9d0bf426306a47c247a4af44aac6b5b0 Mon Sep 17 00:00:00 2001 From: mpv Date: Mon, 31 Mar 2014 14:41:03 +0400 Subject: [PATCH] Changing ".hxx" to ".h" headers files extensions --- CMakeLists.txt | 1 + src/Config/Config_FeatureMessage.h | 4 +- src/Config/Config_FeatureReader.cpp | 2 +- src/Config/Config_XMLReader.cpp | 2 +- src/Event/CMakeLists.txt | 8 +-- src/Event/{Event.hxx => Event.h} | 0 src/Event/Event_Listener.cxx | 2 +- .../{Event_Listener.hxx => Event_Listener.h} | 5 +- src/Event/Event_Loop.cxx | 2 +- src/Event/{Event_Loop.hxx => Event_Loop.h} | 19 +++--- src/Event/Event_Message.cxx | 2 +- .../{Event_Message.hxx => Event_Message.h} | 37 +++------- src/Model/CMakeLists.txt | 8 +-- src/Model/{Model.hxx => Model.h} | 0 ...el_Application.hxx => Model_Application.h} | 0 src/Model/Model_Document.cxx | 2 +- .../{Model_Document.hxx => Model_Document.h} | 4 +- src/Model/Model_Feature.cxx | 2 +- .../{Model_Feature.hxx => Model_Feature.h} | 4 +- src/Model/Model_PluginManager.cxx | 55 ++++++++++++--- ...luginManager.hxx => Model_PluginManager.h} | 20 ++++-- src/ModelAPI/CMakeLists.txt | 10 +-- src/ModelAPI/{ModelAPI.hxx => ModelAPI.h} | 0 src/ModelAPI/ModelAPI.i | 14 ++-- ...elAPI_Document.hxx => ModelAPI_Document.h} | 2 +- ...odelAPI_Feature.hxx => ModelAPI_Feature.h} | 2 +- ...API_Interface.hxx => ModelAPI_Interface.h} | 2 +- src/ModelAPI/ModelAPI_PluginManager.cxx | 67 +++++++++++++++++-- ...inManager.hxx => ModelAPI_PluginManager.h} | 2 +- src/PartSet/PartSet_Message.h | 2 +- src/PartSet/PartSet_Module.cpp | 2 +- src/PartSetPlugin/CMakeLists.txt | 24 +++++++ src/PartSetPlugin/PartSetPlugin.cxx | 16 +++++ src/PartSetPlugin/PartSetPlugin.h | 18 +++++ src/PartSetPlugin/PartSetPlugin_NewPart.cxx | 9 +++ src/PartSetPlugin/PartSetPlugin_NewPart.h | 26 +++++++ src/PartSetPlugin/PartSetPlugin_NewPart.hxx | 26 +++++++ src/XGUI/XGUI_Workshop.cpp | 2 +- src/XGUI/XGUI_Workshop.h | 4 +- 39 files changed, 303 insertions(+), 104 deletions(-) rename src/Event/{Event.hxx => Event.h} (100%) rename src/Event/{Event_Listener.hxx => Event_Listener.h} (90%) rename src/Event/{Event_Loop.hxx => Event_Loop.h} (83%) rename src/Event/{Event_Message.hxx => Event_Message.h} (75%) rename src/Model/{Model.hxx => Model.h} (100%) rename src/Model/{Model_Application.hxx => Model_Application.h} (100%) rename src/Model/{Model_Document.hxx => Model_Document.h} (97%) rename src/Model/{Model_Feature.hxx => Model_Feature.h} (91%) rename src/Model/{Model_PluginManager.hxx => Model_PluginManager.h} (50%) rename src/ModelAPI/{ModelAPI.hxx => ModelAPI.h} (100%) rename src/ModelAPI/{ModelAPI_Document.hxx => ModelAPI_Document.h} (98%) rename src/ModelAPI/{ModelAPI_Feature.hxx => ModelAPI_Feature.h} (96%) rename src/ModelAPI/{ModelAPI_Interface.hxx => ModelAPI_Interface.h} (97%) rename src/ModelAPI/{ModelAPI_PluginManager.hxx => ModelAPI_PluginManager.h} (97%) create mode 100644 src/PartSetPlugin/CMakeLists.txt create mode 100644 src/PartSetPlugin/PartSetPlugin.cxx create mode 100644 src/PartSetPlugin/PartSetPlugin.h create mode 100644 src/PartSetPlugin/PartSetPlugin_NewPart.cxx create mode 100644 src/PartSetPlugin/PartSetPlugin_NewPart.h create mode 100644 src/PartSetPlugin/PartSetPlugin_NewPart.hxx diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a43d598d..68d6a4f2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,4 +12,5 @@ ADD_SUBDIRECTORY (src/Model) ADD_SUBDIRECTORY (src/ModelAPI) ADD_SUBDIRECTORY (src/Config) ADD_SUBDIRECTORY (src/PartSet) +ADD_SUBDIRECTORY (src/PartSetPlugin) ADD_SUBDIRECTORY (src/XGUI) diff --git a/src/Config/Config_FeatureMessage.h b/src/Config/Config_FeatureMessage.h index 1a0f99477..64f2881e6 100644 --- a/src/Config/Config_FeatureMessage.h +++ b/src/Config/Config_FeatureMessage.h @@ -3,7 +3,7 @@ #include "Config.h" -#include +#include #include class CONFIG_EXPORT Config_FeatureMessage: public Event_Message @@ -42,4 +42,4 @@ public: void setWorkbenchId(const std::string& workbenchId); }; -#endif // CONFIG_MESSAGE_H \ No newline at end of file +#endif // CONFIG_MESSAGE_H \ No newline at end of file diff --git a/src/Config/Config_FeatureReader.cpp b/src/Config/Config_FeatureReader.cpp index 03e5f3abd..db68af656 100644 --- a/src/Config/Config_FeatureReader.cpp +++ b/src/Config/Config_FeatureReader.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include #include diff --git a/src/Config/Config_XMLReader.cpp b/src/Config/Config_XMLReader.cpp index e9a31e207..83e883a5f 100644 --- a/src/Config/Config_XMLReader.cpp +++ b/src/Config/Config_XMLReader.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include #include diff --git a/src/Event/CMakeLists.txt b/src/Event/CMakeLists.txt index 70b6b3a6d..4b2c1d86e 100644 --- a/src/Event/CMakeLists.txt +++ b/src/Event/CMakeLists.txt @@ -3,10 +3,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11) INCLUDE(Common) SET(PROJECT_HEADERS - Event.hxx - Event_Message.hxx - Event_Listener.hxx - Event_Loop.hxx + Event.h + Event_Message.h + Event_Listener.h + Event_Loop.h ) SET(PROJECT_SOURCES diff --git a/src/Event/Event.hxx b/src/Event/Event.h similarity index 100% rename from src/Event/Event.hxx rename to src/Event/Event.h diff --git a/src/Event/Event_Listener.cxx b/src/Event/Event_Listener.cxx index 633dd4ad8..ffb56c7b6 100644 --- a/src/Event/Event_Listener.cxx +++ b/src/Event/Event_Listener.cxx @@ -2,4 +2,4 @@ // Created: Thu Mar 13 2014 // Author: Mikhail PONIKAROV -#include +#include diff --git a/src/Event/Event_Listener.hxx b/src/Event/Event_Listener.h similarity index 90% rename from src/Event/Event_Listener.hxx rename to src/Event/Event_Listener.h index 87bf0464a..80719d42d 100644 --- a/src/Event/Event_Listener.hxx +++ b/src/Event/Event_Listener.h @@ -5,7 +5,7 @@ #ifndef Event_Listener_HeaderFile #define Event_Listener_HeaderFile -#include +#include class Event_Message; /**\class Event_Listener @@ -15,8 +15,7 @@ class Event_Message; * If some object wants to listen some events it must inherit * this class and register in the Loop. */ -class EVENT_EXPORT Event_Listener -{ +class EVENT_EXPORT Event_Listener { public: //! This method is called by loop when the event is started to process. diff --git a/src/Event/Event_Loop.cxx b/src/Event/Event_Loop.cxx index 558edd0da..ffcd6c6e5 100644 --- a/src/Event/Event_Loop.cxx +++ b/src/Event/Event_Loop.cxx @@ -2,7 +2,7 @@ // Created: Thu Mar 13 2014 // Author: Mikhail PONIKAROV -#include +#include #include using namespace std; diff --git a/src/Event/Event_Loop.hxx b/src/Event/Event_Loop.h similarity index 83% rename from src/Event/Event_Loop.hxx rename to src/Event/Event_Loop.h index d50e6633f..d93b942eb 100644 --- a/src/Event/Event_Loop.hxx +++ b/src/Event/Event_Loop.h @@ -5,8 +5,8 @@ #ifndef Event_Loop_HeaderFile #define Event_Loop_HeaderFile -#include -#include +#include +#include #include #include @@ -21,15 +21,12 @@ * Performing of events is processed in separated thread, so, sender takes * control back immideately. */ -class Event_Loop -{ - std::map > > myListeners; ///< map from event ID to sender pointer to listeners that must be called for this +class Event_Loop { + std::map > > + myListeners; ///< map from event ID to sender pointer to listeners that must be called for this //! The empty constructor, will be called at startup of the application, only once - Event_Loop() - { - } - ; + Event_Loop() {}; public: ///! Returns the main object of the loop, one per application. EVENT_EXPORT static Event_Loop* Loop(); @@ -42,8 +39,8 @@ public: //! Registers (or adds if such listener is already registered) a listener //! that will be called on the event and from the defined sender - EVENT_EXPORT void RegisterListener(Event_Listener* theListener, const Event_ID theID, - void* theSender = 0); + EVENT_EXPORT void RegisterListener(Event_Listener* theListener, const Event_ID theID, + void* theSender = 0); }; #endif diff --git a/src/Event/Event_Message.cxx b/src/Event/Event_Message.cxx index 96097b409..ecf88a1e8 100644 --- a/src/Event/Event_Message.cxx +++ b/src/Event/Event_Message.cxx @@ -2,7 +2,7 @@ // Created: Thu Mar 13 2014 // Author: Mikhail PONIKAROV -#include +#include Event_Message::Event_Message(const Event_ID theID, const void* theSender) : myEventId(theID), mySender((void*) theSender) diff --git a/src/Event/Event_Message.hxx b/src/Event/Event_Message.h similarity index 75% rename from src/Event/Event_Message.hxx rename to src/Event/Event_Message.h index 66346be3a..27608b7bf 100644 --- a/src/Event/Event_Message.hxx +++ b/src/Event/Event_Message.h @@ -5,7 +5,7 @@ #ifndef Event_Message_HeaderFile #define Event_Message_HeaderFile -#include +#include /**\class Event_ID * \ingroup EventLoop @@ -17,27 +17,17 @@ * used as an identifier (this is usefull for debugging of the events * with log files and in debugger). */ -class EVENT_EXPORT Event_ID -{ +class EVENT_EXPORT Event_ID { char* myID; ///< pointer to the text-identifier of the event, unique pointer for all events of such type - Event_ID(char* theID) - { - myID = theID; - } + Event_ID(char* theID) {myID = theID;} friend class Event_Loop; public: /// Returns the text-identifier of the event (for debugging reasons) - char* EventText() const - { - return myID; - } + char* EventText() const {return myID;} /// Allows to compare identifiers - bool operator==(const Event_ID& theID) const - { - return myID == theID.myID; - } + bool operator==(const Event_ID& theID) const {return myID == theID.myID;} }; /**\class Event_Message @@ -45,8 +35,7 @@ public: * \brief Message for communication between sender and listener of event. * Normally it is inherited by the higher-level */ -class EVENT_EXPORT Event_Message -{ +class EVENT_EXPORT Event_Message { Event_ID myEventId; ///< identifier of the event void* mySender; ///< the sender object @@ -54,21 +43,13 @@ public: //! Creates the message Event_Message(const Event_ID theID, const void* theSender = 0); - virtual ~Event_Message() - { - } + virtual ~Event_Message() {} //! Returns identifier of the message - const Event_ID& EventID() const - { - return myEventId; - } + const Event_ID& EventID() const {return myEventId;} //! Returns sender of the message or NULL if it is anonymous message - void* Sender() - { - return mySender; - } + void* Sender() {return mySender;} }; #endif diff --git a/src/Model/CMakeLists.txt b/src/Model/CMakeLists.txt index c7d2585c2..42ee4f4c6 100644 --- a/src/Model/CMakeLists.txt +++ b/src/Model/CMakeLists.txt @@ -5,10 +5,10 @@ INCLUDE(FindCAS) INCLUDE(FindBoost) SET(PROJECT_HEADERS - Model.hxx - Model_Document.hxx - Model_PluginManager.hxx - Model_Feature.hxx + Model.h + Model_Document.h + Model_PluginManager.h + Model_Feature.h ) SET(PROJECT_SOURCES diff --git a/src/Model/Model.hxx b/src/Model/Model.h similarity index 100% rename from src/Model/Model.hxx rename to src/Model/Model.h diff --git a/src/Model/Model_Application.hxx b/src/Model/Model_Application.h similarity index 100% rename from src/Model/Model_Application.hxx rename to src/Model/Model_Application.h diff --git a/src/Model/Model_Document.cxx b/src/Model/Model_Document.cxx index ed000dea6..dd34e598b 100644 --- a/src/Model/Model_Document.cxx +++ b/src/Model/Model_Document.cxx @@ -3,7 +3,7 @@ // Author: Mikhail PONIKAROV // Copyright: CEA 2011 -#include +#include #include diff --git a/src/Model/Model_Document.hxx b/src/Model/Model_Document.h similarity index 97% rename from src/Model/Model_Document.hxx rename to src/Model/Model_Document.h index 9a0235f97..bdd5d8e0c 100644 --- a/src/Model/Model_Document.hxx +++ b/src/Model/Model_Document.h @@ -6,8 +6,8 @@ #ifndef Model_Document_HeaderFile #define Model_Document_HeaderFile -#include -#include +#include +#include #include class Handle_Model_Document; diff --git a/src/Model/Model_Feature.cxx b/src/Model/Model_Feature.cxx index 379beb456..0ff283892 100644 --- a/src/Model/Model_Feature.cxx +++ b/src/Model/Model_Feature.cxx @@ -2,7 +2,7 @@ // Created: 21 Mar 2014 // Author: Mikhail PONIKAROV -#include +#include using namespace std; diff --git a/src/Model/Model_Feature.hxx b/src/Model/Model_Feature.h similarity index 91% rename from src/Model/Model_Feature.hxx rename to src/Model/Model_Feature.h index fa632f183..0b51f725f 100644 --- a/src/Model/Model_Feature.hxx +++ b/src/Model/Model_Feature.h @@ -5,8 +5,8 @@ #ifndef Model_Feature_HeaderFile #define Model_Feature_HeaderFile -#include "Model.hxx" -#include +#include "Model.h" +#include /**\class Model_Feature * \ingroup DataModel diff --git a/src/Model/Model_PluginManager.cxx b/src/Model/Model_PluginManager.cxx index f84205c7d..e06c66518 100644 --- a/src/Model/Model_PluginManager.cxx +++ b/src/Model/Model_PluginManager.cxx @@ -2,25 +2,47 @@ // Created: 20 Mar 2014 // Author: Mikhail PONIKAROV -#include -#include -#include -#include +#include +#include +#include +#include #include +#include + +#include using namespace std; +static Model_PluginManager* myImpl = new Model_PluginManager(); + boost::shared_ptr Model_PluginManager::CreateFeature(string theFeatureID) { - return boost::shared_ptr(new Model_Feature()); + if (this != myImpl) return myImpl->CreateFeature(theFeatureID); + + LoadPluginsInfo(); + if (myPlugins.find(theFeatureID) != myPlugins.end()) { + string aLibName = myPlugins[theFeatureID]; +#ifdef WIN32 + aLibName += ".dll"; +#else + aLibName += ".so"; +#endif + Standard_CString aLibNameCStr = aLibName.c_str(); + OSD_SharedLibrary aLib(aLibNameCStr); + if (aLib.DlOpen(OSD_RTLD_NOW)) { + OSD_Function aFunc = aLib.DlSymb("CreateFeature"); + } + } + + return boost::shared_ptr(); // return nothing } Model_PluginManager::Model_PluginManager() { + myPluginsInfoLoaded = false; static Event_ID aFeatureEvent = Event_Loop::EventByName("Feature"); - static Model_PluginManager* myImpl = new Model_PluginManager(); - ModelAPI_PluginManager::SetPluginManager(boost::shared_ptr(myImpl)); + ModelAPI_PluginManager::SetPluginManager(boost::shared_ptr(this)); // register the configuration reading listener Event_Loop* aLoop = Event_Loop::Loop(); aLoop->RegisterListener(myImpl, aFeatureEvent); @@ -28,8 +50,25 @@ Model_PluginManager::Model_PluginManager() void Model_PluginManager::ProcessEvent(const Event_Message* theMessage) { - const Config_FeatureMessage* aMsg = dynamic_cast(theMessage); + const Config_FeatureMessage* aMsg = + dynamic_cast( theMessage ); if (aMsg) { // proccess the plugin info, load plugin + if (myPlugins.find(aMsg->id()) == myPlugins.end()) { + myPlugins[aMsg->id()] = "PartSetPlugin"; // TO DO: plugin name must be also imported from XMLs + } } + // plugins information was started to load, so, it will be loaded + myPluginsInfoLoaded = true; +} + +void Model_PluginManager::LoadPluginsInfo() +{ + if (myPluginsInfoLoaded) // nothing to do + return; + + // Read plugins information from XML files + Config_ModuleReader aXMLReader; + aXMLReader.setAutoImport(true); + aXMLReader.readAll(); } diff --git a/src/Model/Model_PluginManager.hxx b/src/Model/Model_PluginManager.h similarity index 50% rename from src/Model/Model_PluginManager.hxx rename to src/Model/Model_PluginManager.h index b41ee74e8..44dbef3b5 100644 --- a/src/Model/Model_PluginManager.hxx +++ b/src/Model/Model_PluginManager.h @@ -5,9 +5,10 @@ #ifndef Model_PluginManager_HeaderFile #define Model_PluginManager_HeaderFile -#include "Model.hxx" -#include -#include +#include "Model.h" +#include +#include +#include /**\class Model_PluginManager * \ingroup DataModel @@ -16,18 +17,23 @@ * the feature functionality request. */ -class MODEL_EXPORT Model_PluginManager: public ModelAPI_PluginManager, public Event_Listener +class Model_PluginManager : public ModelAPI_PluginManager, public Event_Listener { + bool myPluginsInfoLoaded; ///< it true if plugins information is loaded + std::map myPlugins; ///< map of feature IDs to plugin name public: /// Creates the feature object using plugins functionality - virtual boost::shared_ptr CreateFeature(std::string theFeatureID); + MODEL_EXPORT virtual boost::shared_ptr CreateFeature(std::string theFeatureID); /// Processes the configuration file reading - virtual void ProcessEvent(const Event_Message* theMessage); + MODEL_EXPORT virtual void ProcessEvent(const Event_Message* theMessage); -private: /// Is called only once, on startup of the application Model_PluginManager(); + +private: + /// Loads (if not done yet) the information about the features and plugins + void LoadPluginsInfo(); }; #endif diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index e45b8eece..399d32f8b 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -8,11 +8,11 @@ INCLUDE(FindBoost) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) SET(PROJECT_HEADERS - ModelAPI.hxx - ModelAPI_Interface.hxx - ModelAPI_PluginManager.hxx - ModelAPI_Feature.hxx - ModelAPI_Document.hxx + ModelAPI.h + ModelAPI_Interface.h + ModelAPI_PluginManager.h + ModelAPI_Feature.h + ModelAPI_Document.h ) SET(PROJECT_SOURCES diff --git a/src/ModelAPI/ModelAPI.hxx b/src/ModelAPI/ModelAPI.h similarity index 100% rename from src/ModelAPI/ModelAPI.hxx rename to src/ModelAPI/ModelAPI.h diff --git a/src/ModelAPI/ModelAPI.i b/src/ModelAPI/ModelAPI.i index 1f63f6c29..6deac8560 100644 --- a/src/ModelAPI/ModelAPI.i +++ b/src/ModelAPI/ModelAPI.i @@ -1,10 +1,10 @@ /* ModelAPI.i */ %module ModelAPI %{ - #include "ModelAPI.hxx" - #include "ModelAPI_Document.hxx" - #include "ModelAPI_PluginManager.hxx" - #include "ModelAPI_Feature.hxx" + #include "ModelAPI.h" + #include "ModelAPI_Document.h" + #include "ModelAPI_PluginManager.h" + #include "ModelAPI_Feature.h" %} // to avoid error on this @@ -20,6 +20,6 @@ %shared_ptr(ModelAPI_Feature) // all supported interfaces -%include "ModelAPI_Document.hxx" -%include "ModelAPI_PluginManager.hxx" -%include "ModelAPI_Feature.hxx" +%include "ModelAPI_Document.h" +%include "ModelAPI_PluginManager.h" +%include "ModelAPI_Feature.h" diff --git a/src/ModelAPI/ModelAPI_Document.hxx b/src/ModelAPI/ModelAPI_Document.h similarity index 98% rename from src/ModelAPI/ModelAPI_Document.hxx rename to src/ModelAPI/ModelAPI_Document.h index 5232771a5..e2941745d 100644 --- a/src/ModelAPI/ModelAPI_Document.hxx +++ b/src/ModelAPI/ModelAPI_Document.h @@ -6,7 +6,7 @@ #ifndef ModelAPI_Document_HeaderFile #define ModelAPI_Document_HeaderFile -#include +#include /**\class Model_Document * \ingroup DataModel diff --git a/src/ModelAPI/ModelAPI_Feature.hxx b/src/ModelAPI/ModelAPI_Feature.h similarity index 96% rename from src/ModelAPI/ModelAPI_Feature.hxx rename to src/ModelAPI/ModelAPI_Feature.h index f29a3a73c..ffa5448c4 100644 --- a/src/ModelAPI/ModelAPI_Feature.hxx +++ b/src/ModelAPI/ModelAPI_Feature.h @@ -5,7 +5,7 @@ #ifndef ModelAPI_Feature_HeaderFile #define ModelAPI_Feature_HeaderFile -#include "ModelAPI.hxx" +#include "ModelAPI.h" #include class ModelAPI_Feature; diff --git a/src/ModelAPI/ModelAPI_Interface.hxx b/src/ModelAPI/ModelAPI_Interface.h similarity index 97% rename from src/ModelAPI/ModelAPI_Interface.hxx rename to src/ModelAPI/ModelAPI_Interface.h index 6fdb28dbc..8535be86e 100644 --- a/src/ModelAPI/ModelAPI_Interface.hxx +++ b/src/ModelAPI/ModelAPI_Interface.h @@ -5,7 +5,7 @@ #ifndef ModelAPI_Interface_HeaderFile #define ModelAPI_Interface_HeaderFile -#include +#include /**\class ModelAPI_Interface * \ingroup DataModel diff --git a/src/ModelAPI/ModelAPI_PluginManager.cxx b/src/ModelAPI/ModelAPI_PluginManager.cxx index 2afb0ceb8..cde7f69bf 100644 --- a/src/ModelAPI/ModelAPI_PluginManager.cxx +++ b/src/ModelAPI/ModelAPI_PluginManager.cxx @@ -2,11 +2,24 @@ // Created: 20 Mar 2014 // Author: Mikhail PONIKAROV -#include +#include // to avoid unresolved ModelAPI_Document() -#include +#include // to avoid unresolved ModelAPI_Feature() -#include +#include + +#ifdef WIN32 +#include +#else +#include +#endif + +using namespace std; + +/// loads the library with specific name, appends "lib*.dll" or "*.so" depending on the platform +void loadLibrary(const string theLibName); +/// Converts library name to the operation system file name +string library(const string& theLibName); /// Manager that will be initialized from Model package, one per application boost::shared_ptr MY_MANAGER; @@ -15,12 +28,56 @@ ModelAPI_PluginManager::ModelAPI_PluginManager() { } +void ModelAPI_PluginManager::SetPluginManager( + boost::shared_ptr theManager) +{ + MY_MANAGER = theManager; +} + boost::shared_ptr ModelAPI_PluginManager::Get() { + if (!MY_MANAGER) { // import Model library that implements this interface of ModelAPI + loadLibrary("Model"); + } return MY_MANAGER; } -void ModelAPI_PluginManager::SetPluginManager(boost::shared_ptr theManager) +string library(const string& theLibName) { - MY_MANAGER = theManager; + string aLibName = theLibName; + +#ifndef WIN32 + static string aLibExt( ".so" ); + if (aLibName.size() < 3 || aLibName.substr(0, 3) !="lib") + aLibName = ".lib" + aLibName; +#else + static string aLibExt( ".dll" ); +#endif + + string anExt = aLibName.substr(aLibName.size() - 4); + + if ( anExt != aLibExt) + aLibName += aLibExt; + + return aLibName; +} + +void loadLibrary(const string theLibName) +{ + string aFileName = library(theLibName); + if ( aFileName.empty() ) + { + cerr<<"Library "< #include diff --git a/src/PartSet/PartSet_Message.h b/src/PartSet/PartSet_Message.h index 4ceccc1a3..9d15f0863 100644 --- a/src/PartSet/PartSet_Message.h +++ b/src/PartSet/PartSet_Message.h @@ -12,7 +12,7 @@ #include -#include +#include class PARTSET_EXPORT PartSet_Message: public Event_Message { diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 908587d52..447270c9b 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include diff --git a/src/PartSetPlugin/CMakeLists.txt b/src/PartSetPlugin/CMakeLists.txt new file mode 100644 index 000000000..d6d5787f7 --- /dev/null +++ b/src/PartSetPlugin/CMakeLists.txt @@ -0,0 +1,24 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11) + +INCLUDE(Common) +INCLUDE(FindBoost) + +SET(PROJECT_HEADERS + PartSetPlugin.h + PartSetPlugin_NewPart.h +) + +SET(PROJECT_SOURCES + PartSetPlugin.cxx + PartSetPlugin_NewPart.cxx +) + +ADD_DEFINITIONS(-DPARTSETPLUGIN_EXPORTS ${BOOST_DEFINITIONS}) +ADD_LIBRARY(PartSetPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) +TARGET_LINK_LIBRARIES(PartSetPlugin ${PROJECT_LIBRARIES} ModelAPI) + +INCLUDE_DIRECTORIES( + ../ModelAPI +) + +INSTALL(TARGETS PartSetPlugin DESTINATION plugins) diff --git a/src/PartSetPlugin/PartSetPlugin.cxx b/src/PartSetPlugin/PartSetPlugin.cxx new file mode 100644 index 000000000..1b641c3a1 --- /dev/null +++ b/src/PartSetPlugin/PartSetPlugin.cxx @@ -0,0 +1,16 @@ +#include "PartSetPlugin.h" + +#include +#include + +using namespace std; + +/// Standard method of the plugin that creates a specific feature instance by the feature kind +PARTSETPLUGIN_EXPORT boost::shared_ptr CreateFeature(const string& theFeatureKind) +{ + if (theFeatureKind == "new_part") { + return boost::shared_ptr(new PartSetPlugin_NewPart()); + } + // feature of such kind is not found + return boost::shared_ptr(); +} diff --git a/src/PartSetPlugin/PartSetPlugin.h b/src/PartSetPlugin/PartSetPlugin.h new file mode 100644 index 000000000..50b7e8ef0 --- /dev/null +++ b/src/PartSetPlugin/PartSetPlugin.h @@ -0,0 +1,18 @@ +#ifndef PARTSETPLUGIN_H +#define PARTSETPLUGIN_H + +#if defined PARTSETPLUGIN_EXPORTS +#if defined WIN32 +#define PARTSETPLUGIN_EXPORT __declspec( dllexport ) +#else +#define PARTSETPLUGIN_EXPORT +#endif +#else +#if defined WIN32 +#define PARTSETPLUGIN_EXPORT __declspec( dllimport ) +#else +#define PARTSETPLUGIN_EXPORT +#endif +#endif + +#endif diff --git a/src/PartSetPlugin/PartSetPlugin_NewPart.cxx b/src/PartSetPlugin/PartSetPlugin_NewPart.cxx new file mode 100644 index 000000000..7959ef044 --- /dev/null +++ b/src/PartSetPlugin/PartSetPlugin_NewPart.cxx @@ -0,0 +1,9 @@ +// File: PartSetPlugin_NewPart.cxx +// Created: 27 Mar 2014 +// Author: Mikhail PONIKAROV + +#include "PartSetPlugin_NewPart.hxx" + +PartSetPlugin_NewPart::PartSetPlugin_NewPart() +{ +} diff --git a/src/PartSetPlugin/PartSetPlugin_NewPart.h b/src/PartSetPlugin/PartSetPlugin_NewPart.h new file mode 100644 index 000000000..9b824c0ee --- /dev/null +++ b/src/PartSetPlugin/PartSetPlugin_NewPart.h @@ -0,0 +1,26 @@ +// File: PartSetPlugin_NewPart.hxx +// Created: 27 Mar 2014 +// Author: Mikhail PONIKAROV + +#ifndef PartSetPlugin_NewPart_HeaderFile +#define PartSetPlugin_NewPart_HeaderFile + +#include "PartSetPlugin.h" +#include + +/**\class PartSetPlugin_NewPart + * \ingroup DataModel + * \brief Feature for creation of the new part in PartSet. + */ + +class PartSetPlugin_NewPart: public ModelAPI_Feature +{ +public: + /// Returns the kind of a feature + PARTSETPLUGIN_EXPORT virtual std::string GetKind() {return "new_part";} + + /// Use plugin manager for features creation + PartSetPlugin_NewPart(); +}; + +#endif diff --git a/src/PartSetPlugin/PartSetPlugin_NewPart.hxx b/src/PartSetPlugin/PartSetPlugin_NewPart.hxx new file mode 100644 index 000000000..9b824c0ee --- /dev/null +++ b/src/PartSetPlugin/PartSetPlugin_NewPart.hxx @@ -0,0 +1,26 @@ +// File: PartSetPlugin_NewPart.hxx +// Created: 27 Mar 2014 +// Author: Mikhail PONIKAROV + +#ifndef PartSetPlugin_NewPart_HeaderFile +#define PartSetPlugin_NewPart_HeaderFile + +#include "PartSetPlugin.h" +#include + +/**\class PartSetPlugin_NewPart + * \ingroup DataModel + * \brief Feature for creation of the new part in PartSet. + */ + +class PartSetPlugin_NewPart: public ModelAPI_Feature +{ +public: + /// Returns the kind of a feature + PARTSETPLUGIN_EXPORT virtual std::string GetKind() {return "new_part";} + + /// Use plugin manager for features creation + PartSetPlugin_NewPart(); +}; + +#endif diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index be82600eb..50208485c 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -9,7 +9,7 @@ #include "XGUI_Viewer.h" #include -#include +#include #include #include diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index f25f355fb..aa115e9bd 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -1,8 +1,8 @@ #ifndef XGUI_WORKSHOP_H #define XGUI_WORKSHOP_H -#include -#include +#include +#include #include #include -- 2.39.2