From: mpv Date: Tue, 1 Apr 2014 10:19:18 +0000 (+0400) Subject: Remove Boost shared_ptr, use std instead X-Git-Tag: V_0.1~41^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=90bbd2eb64d0fa76030e5b93f4436ae2ec2a2e65;p=modules%2Fshaper.git Remove Boost shared_ptr, use std instead --- diff --git a/src/Model/CMakeLists.txt b/src/Model/CMakeLists.txt index 5f0b4e883..c7b23b3a0 100644 --- a/src/Model/CMakeLists.txt +++ b/src/Model/CMakeLists.txt @@ -2,7 +2,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11) INCLUDE(Common) INCLUDE(FindCAS) -INCLUDE(FindBoost) SET(PROJECT_HEADERS Model.h @@ -19,7 +18,7 @@ SET(PROJECT_SOURCES Model_Feature.cxx ) -ADD_DEFINITIONS(-DMODEL_EXPORTS ${CAS_DEFINITIONS} ${BOOST_DEFINITIONS}) +ADD_DEFINITIONS(-DMODEL_EXPORTS ${CAS_DEFINITIONS}) ADD_LIBRARY(Model SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) TARGET_LINK_LIBRARIES(Model ${PROJECT_LIBRARIES} ${CAS_OCAF} ModelAPI Event Config) diff --git a/src/Model/Model_Application.cxx b/src/Model/Model_Application.cxx index 560f5805c..ac1eeb896 100644 --- a/src/Model/Model_Application.cxx +++ b/src/Model/Model_Application.cxx @@ -23,12 +23,12 @@ Handle(Model_Application) Model_Application::getApplication() //function : getDocument //purpose : //======================================================================= -boost::shared_ptr Model_Application::getDocument(std::string theDocID) +std::shared_ptr Model_Application::getDocument(std::string theDocID) { if (myDocs.find(theDocID) != myDocs.end()) return myDocs[theDocID]; - boost::shared_ptr aNew(new Model_Document("BinOcaf")); + std::shared_ptr aNew(new Model_Document); myDocs[theDocID] = aNew; return aNew; } diff --git a/src/Model/Model_Application.h b/src/Model/Model_Application.h index 265eafbe1..75aa172af 100644 --- a/src/Model/Model_Application.h +++ b/src/Model/Model_Application.h @@ -30,7 +30,7 @@ public: //! Retuns the application: one per process MODEL_EXPORT static Handle_Model_Application getApplication(); //! Returns the main document (on first call creates it) by the string identifier - MODEL_EXPORT boost::shared_ptr getDocument(std::string theDocID); + MODEL_EXPORT std::shared_ptr getDocument(std::string theDocID); public: // Redefined OCAF methods @@ -46,7 +46,7 @@ public: private: /// Map from string identifiers to created documents of an application - std::map > myDocs; + std::map > myDocs; }; #endif diff --git a/src/Model/Model_Document.cxx b/src/Model/Model_Document.cxx index ddbdfc53a..ffce8a452 100644 --- a/src/Model/Model_Document.cxx +++ b/src/Model/Model_Document.cxx @@ -7,9 +7,6 @@ #include -IMPLEMENT_STANDARD_HANDLE(Model_Document, MMgt_TShared) -IMPLEMENT_STANDARD_RTTIEXT(Model_Document, MMgt_TShared) - static const int UNDO_LIMIT = 10; // number of possible undo operations static const int TAG_GENERAL = 1; // general properties tag @@ -99,28 +96,28 @@ bool Model_Document::Save(const char* theFileName) void Model_Document::Close() { - TDocStd_Document::Close(); + myDoc->Close(); } void Model_Document::StartOperation() { - TDocStd_Document::NewCommand(); + myDoc->NewCommand(); } void Model_Document::FinishOperation() { - TDocStd_Document::CommitCommand(); + myDoc->CommitCommand(); myTransactionsAfterSave++; } void Model_Document::AbortOperation() { - TDocStd_Document::AbortCommand(); + myDoc->AbortCommand(); } bool Model_Document::IsOperation() { - return TDocStd_Document::HasOpenCommand() == Standard_True ; + return myDoc->HasOpenCommand() == Standard_True ; } bool Model_Document::IsModified() @@ -130,42 +127,42 @@ bool Model_Document::IsModified() bool Model_Document::CanUndo() { - return TDocStd_Document::GetAvailableUndos() > 0; + return myDoc->GetAvailableUndos() > 0; } void Model_Document::Undo() { - TDocStd_Document::Undo(); + myDoc->Undo(); myTransactionsAfterSave--; } bool Model_Document::CanRedo() { - return TDocStd_Document::GetAvailableRedos() > 0; + return myDoc->GetAvailableRedos() > 0; } void Model_Document::Redo() { - TDocStd_Document::Redo(); + myDoc->Redo(); myTransactionsAfterSave++; } void Model_Document::AddObject( - boost::shared_ptr theFeature, const int theGroupID) + std::shared_ptr theFeature, const int theGroupID) { - boost::shared_ptr aModelFeature = - boost::dynamic_pointer_cast(theFeature); + std::shared_ptr aModelFeature = + std::dynamic_pointer_cast(theFeature); if (aModelFeature) { - TDF_Label aGroupLab = Main().FindChild(TAG_OBJECTS).FindChild(theGroupID + 1); + TDF_Label aGroupLab = myDoc->Main().FindChild(TAG_OBJECTS).FindChild(theGroupID + 1); TDF_Label anObjLab = aGroupLab.NewChild(); aModelFeature->setLabel(anObjLab); } } -Model_Document::Model_Document(const TCollection_ExtendedString& theStorageFormat) - : TDocStd_Document(theStorageFormat) +Model_Document::Model_Document() + : myDoc(new TDocStd_Document("BinOcaf")) // binary OCAF format { - SetUndoLimit(UNDO_LIMIT); + myDoc->SetUndoLimit(UNDO_LIMIT); myTransactionsAfterSave = 0; } diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 3e7c1c980..22ad95fa0 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -20,14 +20,12 @@ class Handle_Model_Document; * to provide access to all stored data. */ -class Model_Document: public TDocStd_Document, public ModelAPI_Document +class Model_Document: public ModelAPI_Document { public: - DEFINE_STANDARD_RTTI(Model_Document); - - //! Creates new document by the format string of a storage - Model_Document(const TCollection_ExtendedString& theStorageFormat); + //! Creates new document with binary file format + Model_Document(); //! Deletes all high-level data, managed this document ~Model_Document(); @@ -68,16 +66,14 @@ public: //! Adds to the document the new object of the given group id //! \param theFeature a feature object that will be connected to the document in this method //! \param theGroupID identifier of the groups of objects (must be greater than zero) - MODEL_EXPORT virtual void AddObject(boost::shared_ptr theFeature, + MODEL_EXPORT virtual void AddObject(std::shared_ptr theFeature, const int theGroupID); protected: private: + Handle_TDocStd_Document myDoc; ///< OCAF document int myTransactionsAfterSave; ///< number of transactions after the last "save" call, used for "IsModified" method }; -// Define handle class -DEFINE_STANDARD_HANDLE(Model_Document, TDocStd_Document) - #endif diff --git a/src/Model/Model_PluginManager.cxx b/src/Model/Model_PluginManager.cxx index e9990eed4..2ef8883f4 100644 --- a/src/Model/Model_PluginManager.cxx +++ b/src/Model/Model_PluginManager.cxx @@ -16,7 +16,7 @@ using namespace std; static Model_PluginManager* myImpl = new Model_PluginManager(); -boost::shared_ptr Model_PluginManager::createFeature(string theFeatureID) +std::shared_ptr Model_PluginManager::createFeature(string theFeatureID) { if (this != myImpl) return myImpl->createFeature(theFeatureID); @@ -28,17 +28,17 @@ boost::shared_ptr Model_PluginManager::createFeature(string th loadLibrary(myCurrentPluginName); } if (myPluginObjs.find(myCurrentPluginName) != myPluginObjs.end()) { - boost::shared_ptr aCreated = + std::shared_ptr aCreated = myPluginObjs[myCurrentPluginName]->createFeature(theFeatureID); } } - return boost::shared_ptr(); // return nothing + return std::shared_ptr(); // return nothing } -boost::shared_ptr Model_PluginManager::rootDocument() +std::shared_ptr Model_PluginManager::rootDocument() { - return boost::shared_ptr( + return std::shared_ptr( Model_Application::getApplication()->getDocument("root")); } @@ -48,7 +48,7 @@ Model_PluginManager::Model_PluginManager() myPluginsInfoLoaded = false; static Event_ID aFeatureEvent = Event_Loop::eventByName("RegisterFeature"); - ModelAPI_PluginManager::SetPluginManager(boost::shared_ptr(this)); + ModelAPI_PluginManager::SetPluginManager(std::shared_ptr(this)); // register the configuration reading listener Event_Loop* aLoop = Event_Loop::loop(); aLoop->registerListener(this, aFeatureEvent); diff --git a/src/Model/Model_PluginManager.h b/src/Model/Model_PluginManager.h index 5f9fdb73c..47b326ac2 100644 --- a/src/Model/Model_PluginManager.h +++ b/src/Model/Model_PluginManager.h @@ -28,10 +28,10 @@ class Model_PluginManager : public ModelAPI_PluginManager, public Event_Listener std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently public: /// Creates the feature object using plugins functionality - MODEL_EXPORT virtual boost::shared_ptr createFeature(std::string theFeatureID); + MODEL_EXPORT virtual std::shared_ptr createFeature(std::string theFeatureID); /// Returns the root document of the application (that may contains sub-documents) - virtual boost::shared_ptr rootDocument(); + virtual std::shared_ptr rootDocument(); /// Registers the plugin that creates features. /// It is obligatory for each plugin to call this function on loading to be found by diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 33fe1bcf8..0a4868ddc 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -4,7 +4,6 @@ INCLUDE(Common) FIND_PACKAGE(SWIG REQUIRED) INCLUDE(${SWIG_USE_FILE}) INCLUDE(FindPython) -INCLUDE(FindBoost) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) SET(PROJECT_HEADERS diff --git a/src/ModelAPI/ModelAPI.i b/src/ModelAPI/ModelAPI.i index 6deac8560..bbb3d7a41 100644 --- a/src/ModelAPI/ModelAPI.i +++ b/src/ModelAPI/ModelAPI.i @@ -15,9 +15,9 @@ %include "std_string.i" // boost pointers -%include -%shared_ptr(ModelAPI_PluginManager) -%shared_ptr(ModelAPI_Feature) +// %include +// %shared_ptr(ModelAPI_PluginManager) +// %shared_ptr(ModelAPI_Feature) // all supported interfaces %include "ModelAPI_Document.h" diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index 2f60c2643..6f7205264 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -6,7 +6,7 @@ #define ModelAPI_Document_HeaderFile #include -#include +#include class ModelAPI_Feature; @@ -60,7 +60,7 @@ public: //! Adds to the document the new object of the given group id //! \param theFeature a feature object that will be connected to the document in this method //! \param theGroupID identifier of the groups of objects (must be greater than zero) - MODELAPI_EXPORT virtual void AddObject(boost::shared_ptr theFeature, + MODELAPI_EXPORT virtual void AddObject(std::shared_ptr theFeature, const int theGroupID) = 0; protected: diff --git a/src/ModelAPI/ModelAPI_Plugin.h b/src/ModelAPI/ModelAPI_Plugin.h index 5d2d0430c..0605d8b6f 100644 --- a/src/ModelAPI/ModelAPI_Plugin.h +++ b/src/ModelAPI/ModelAPI_Plugin.h @@ -7,7 +7,7 @@ #include "ModelAPI.h" #include -#include +#include class ModelAPI_Feature; @@ -20,7 +20,7 @@ class MODELAPI_EXPORT ModelAPI_Plugin { public: /// Creates the feature object of this plugin by the feature string ID - virtual boost::shared_ptr createFeature(std::string theFeatureID) = 0; + virtual std::shared_ptr createFeature(std::string theFeatureID) = 0; protected: /// Is needed for python wrapping by swig diff --git a/src/ModelAPI/ModelAPI_PluginManager.cxx b/src/ModelAPI/ModelAPI_PluginManager.cxx index d4a20feae..6ec5a9d7a 100644 --- a/src/ModelAPI/ModelAPI_PluginManager.cxx +++ b/src/ModelAPI/ModelAPI_PluginManager.cxx @@ -22,19 +22,19 @@ using namespace std; string library(const string& theLibName); /// Manager that will be initialized from Model package, one per application -boost::shared_ptr MY_MANAGER; +std::shared_ptr MY_MANAGER; ModelAPI_PluginManager::ModelAPI_PluginManager() { } void ModelAPI_PluginManager::SetPluginManager( - boost::shared_ptr theManager) + std::shared_ptr theManager) { MY_MANAGER = theManager; } -boost::shared_ptr ModelAPI_PluginManager::get() +std::shared_ptr ModelAPI_PluginManager::get() { if (!MY_MANAGER) { // import Model library that implements this interface of ModelAPI loadLibrary("Model"); @@ -62,6 +62,7 @@ string library(const string& theLibName) return aLibName; } +#include void ModelAPI_PluginManager::loadLibrary(const string theLibName) { string aFileName = library(theLibName); diff --git a/src/ModelAPI/ModelAPI_PluginManager.h b/src/ModelAPI/ModelAPI_PluginManager.h index a7b0c7bcd..b53a66336 100644 --- a/src/ModelAPI/ModelAPI_PluginManager.h +++ b/src/ModelAPI/ModelAPI_PluginManager.h @@ -7,7 +7,7 @@ #include "ModelAPI.h" #include -#include +#include class ModelAPI_Feature; class ModelAPI_Plugin; @@ -24,10 +24,10 @@ class MODELAPI_EXPORT ModelAPI_PluginManager { public: /// Creates the feature object using plugins functionality - virtual boost::shared_ptr createFeature(std::string theFeatureID) = 0; + virtual std::shared_ptr createFeature(std::string theFeatureID) = 0; /// Returns the real implementation (the alone instance per application) of the plugin manager - static boost::shared_ptr get(); + static std::shared_ptr get(); /// Registers the plugin that creates features. /// It is obligatory for each plugin to call this function on loading to be found by @@ -35,7 +35,7 @@ public: virtual void registerPlugin(ModelAPI_Plugin* thePlugin) = 0; /// Returns the root document of the application (that may contains sub-documents) - virtual boost::shared_ptr rootDocument() = 0; + virtual std::shared_ptr rootDocument() = 0; /// loads the library with specific name, appends "lib*.dll" or "*.so" depending on the platform static void ModelAPI_PluginManager::loadLibrary(const std::string theLibName); @@ -44,7 +44,7 @@ public: ModelAPI_PluginManager(); protected: - static void SetPluginManager(boost::shared_ptr theManager); + static void SetPluginManager(std::shared_ptr theManager); }; #endif diff --git a/src/PartSetPlugin/CMakeLists.txt b/src/PartSetPlugin/CMakeLists.txt index ab07cdc88..10d71fce7 100644 --- a/src/PartSetPlugin/CMakeLists.txt +++ b/src/PartSetPlugin/CMakeLists.txt @@ -1,7 +1,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11) INCLUDE(Common) -INCLUDE(FindBoost) SET(PROJECT_HEADERS PartSetPlugin.h diff --git a/src/PartSetPlugin/PartSetPlugin_Plugin.cxx b/src/PartSetPlugin/PartSetPlugin_Plugin.cxx index d94a74f30..91baf0bc4 100644 --- a/src/PartSetPlugin/PartSetPlugin_Plugin.cxx +++ b/src/PartSetPlugin/PartSetPlugin_Plugin.cxx @@ -17,11 +17,11 @@ PartSetPlugin_Plugin::PartSetPlugin_Plugin() ModelAPI_PluginManager::get()->registerPlugin(this); } -boost::shared_ptr PartSetPlugin_Plugin::createFeature(string theFeatureID) +std::shared_ptr PartSetPlugin_Plugin::createFeature(string theFeatureID) { - boost::shared_ptr aCreated; + std::shared_ptr aCreated; if (theFeatureID == "new_part") { - aCreated = boost::shared_ptr(new PartSetPlugin_NewPart()); + aCreated = std::shared_ptr(new PartSetPlugin_NewPart()); } // add to a root document for the current moment if (aCreated) diff --git a/src/PartSetPlugin/PartSetPlugin_Plugin.h b/src/PartSetPlugin/PartSetPlugin_Plugin.h index ff577f79a..74f6e73c0 100644 --- a/src/PartSetPlugin/PartSetPlugin_Plugin.h +++ b/src/PartSetPlugin/PartSetPlugin_Plugin.h @@ -13,7 +13,7 @@ class PARTSETPLUGIN_EXPORT PartSetPlugin_Plugin: public ModelAPI_Plugin { public: /// Creates the feature object of this plugin by the feature string ID - virtual boost::shared_ptr createFeature(std::string theFeatureID); + virtual std::shared_ptr createFeature(std::string theFeatureID); public: /// Is needed for python wrapping by swig