Salome HOME
Remove Boost shared_ptr, use std instead
authormpv <mikhail.ponikarov@opencascade.com>
Tue, 1 Apr 2014 10:19:18 +0000 (14:19 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Tue, 1 Apr 2014 10:19:18 +0000 (14:19 +0400)
16 files changed:
src/Model/CMakeLists.txt
src/Model/Model_Application.cxx
src/Model/Model_Application.h
src/Model/Model_Document.cxx
src/Model/Model_Document.h
src/Model/Model_PluginManager.cxx
src/Model/Model_PluginManager.h
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI.i
src/ModelAPI/ModelAPI_Document.h
src/ModelAPI/ModelAPI_Plugin.h
src/ModelAPI/ModelAPI_PluginManager.cxx
src/ModelAPI/ModelAPI_PluginManager.h
src/PartSetPlugin/CMakeLists.txt
src/PartSetPlugin/PartSetPlugin_Plugin.cxx
src/PartSetPlugin/PartSetPlugin_Plugin.h

index 5f0b4e883b31d06e2ea68736159c63a1a497ee4b..c7b23b3a090d7a16121acf70c3bf6e489f797fe4 100644 (file)
@@ -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)
 
index 560f5805c980b9d0143baaa0fdaa974e6f5c86be..ac1eeb896c8cb9ce1eb51564de0902ad3cc987a2 100644 (file)
@@ -23,12 +23,12 @@ Handle(Model_Application) Model_Application::getApplication()
 //function : getDocument
 //purpose  : 
 //=======================================================================
-boost::shared_ptr<Model_Document> Model_Application::getDocument(std::string theDocID)
+std::shared_ptr<Model_Document> Model_Application::getDocument(std::string theDocID)
 {
   if (myDocs.find(theDocID) != myDocs.end())
     return myDocs[theDocID];
 
-  boost::shared_ptr<Model_Document> aNew(new Model_Document("BinOcaf"));
+  std::shared_ptr<Model_Document> aNew(new Model_Document);
   myDocs[theDocID] = aNew;
   return aNew;
 }
index 265eafbe174ed28b67d455e934d521e623aa112c..75aa172afbaae4798eac9f331427a73551aa4362 100644 (file)
@@ -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<Model_Document> getDocument(std::string theDocID);
+  MODEL_EXPORT std::shared_ptr<Model_Document> 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<std::string, boost::shared_ptr<Model_Document> > myDocs;
+  std::map<std::string, std::shared_ptr<Model_Document> > myDocs;
 };
 
 #endif
index ddbdfc53a4ec6518bf18603a73ae88e905568c94..ffce8a4520513b5346e0aece5540b12973d40947 100644 (file)
@@ -7,9 +7,6 @@
 
 #include <TDataStd_Integer.hxx>
 
-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<ModelAPI_Feature> theFeature, const int theGroupID)
+  std::shared_ptr<ModelAPI_Feature> theFeature, const int theGroupID)
 {
-  boost::shared_ptr<Model_Feature> aModelFeature = 
-    boost::dynamic_pointer_cast<Model_Feature>(theFeature);
+  std::shared_ptr<Model_Feature> aModelFeature = 
+    std::dynamic_pointer_cast<Model_Feature>(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;
 }
 
index 3e7c1c9800b0c4b73d1f9cc909769c646619008f..22ad95fa0cb72e7ddb8f19a32b23c2c43cb9837b 100644 (file)
@@ -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<ModelAPI_Feature> theFeature,
+  MODEL_EXPORT virtual void AddObject(std::shared_ptr<ModelAPI_Feature> 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
index e9990eed4f1f0ec0a6a45a11aa7dbe6edcbb62a9..2ef8883f44202d166c16838bc0a210380cafaf58 100644 (file)
@@ -16,7 +16,7 @@ using namespace std;
 
 static Model_PluginManager* myImpl = new Model_PluginManager();
 
-boost::shared_ptr<ModelAPI_Feature> Model_PluginManager::createFeature(string theFeatureID)
+std::shared_ptr<ModelAPI_Feature> Model_PluginManager::createFeature(string theFeatureID)
 {
   if (this != myImpl) return myImpl->createFeature(theFeatureID);
 
@@ -28,17 +28,17 @@ boost::shared_ptr<ModelAPI_Feature> Model_PluginManager::createFeature(string th
       loadLibrary(myCurrentPluginName);
     }
     if (myPluginObjs.find(myCurrentPluginName) != myPluginObjs.end()) {
-      boost::shared_ptr<ModelAPI_Feature> aCreated = 
+      std::shared_ptr<ModelAPI_Feature> aCreated = 
         myPluginObjs[myCurrentPluginName]->createFeature(theFeatureID);
     }
   }
 
-  return boost::shared_ptr<ModelAPI_Feature>(); // return nothing
+  return std::shared_ptr<ModelAPI_Feature>(); // return nothing
 }
 
-boost::shared_ptr<ModelAPI_Document> Model_PluginManager::rootDocument()
+std::shared_ptr<ModelAPI_Document> Model_PluginManager::rootDocument()
 {
-  return boost::shared_ptr<ModelAPI_Document>(
+  return std::shared_ptr<ModelAPI_Document>(
     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<ModelAPI_PluginManager>(this));
+  ModelAPI_PluginManager::SetPluginManager(std::shared_ptr<ModelAPI_PluginManager>(this));
   // register the configuration reading listener
   Event_Loop* aLoop = Event_Loop::loop();
   aLoop->registerListener(this, aFeatureEvent);
index 5f9fdb73c1e0de410f5182d1b61342613de4a5dc..47b326ac2d3121a15d2578b3df1a3cb1bd07f2ff 100644 (file)
@@ -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<ModelAPI_Feature> createFeature(std::string theFeatureID);
+  MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
 
   /// Returns the root document of the application (that may contains sub-documents)
-  virtual boost::shared_ptr<ModelAPI_Document> rootDocument();
+  virtual std::shared_ptr<ModelAPI_Document> rootDocument();
 
   /// Registers the plugin that creates features.
   /// It is obligatory for each plugin to call this function on loading to be found by 
index 33fe1bcf872463b28e92cc516c38076fd8bf63ae..0a4868ddc9fb8b84e49900458456a64e565f1504 100644 (file)
@@ -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
index 6deac8560d12022d94d480dbdb03a81772a588b1..bbb3d7a412dbb25d7dd6ac3335829ea0028d2677 100644 (file)
@@ -15,9 +15,9 @@
 %include "std_string.i"
 
 // boost pointers
-%include <boost_shared_ptr.i>
-%shared_ptr(ModelAPI_PluginManager)
-%shared_ptr(ModelAPI_Feature)
+// %include <boost_shared_ptr.i>
+// %shared_ptr(ModelAPI_PluginManager)
+// %shared_ptr(ModelAPI_Feature)
 
 // all supported interfaces
 %include "ModelAPI_Document.h"
index 2f60c2643f09ad9bec00354a87e7d9a730c9a3c6..6f720526442bebb8f237a40ebd298136242663c7 100644 (file)
@@ -6,7 +6,7 @@
 #define ModelAPI_Document_HeaderFile
 
 #include <ModelAPI.h>
-#include <boost/shared_ptr.hpp>
+#include <memory>
 
 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<ModelAPI_Feature> theFeature,
+  MODELAPI_EXPORT virtual void AddObject(std::shared_ptr<ModelAPI_Feature> theFeature,
     const int theGroupID) = 0;
 
 protected:
index 5d2d0430ceec5c39db9222803d1f184a9869b76c..0605d8b6f1997c5bedc6f5a18b965ec709dc5e71 100644 (file)
@@ -7,7 +7,7 @@
 
 #include "ModelAPI.h"
 #include <string>
-#include <boost/shared_ptr.hpp>
+#include <memory>
 
 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<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
+  virtual std::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
 
 protected:
   /// Is needed for python wrapping by swig
index d4a20feaeeed02c0db864f2e2f50e7dc7524ab63..6ec5a9d7ab1c39025fe92e18c4a3556166460098 100644 (file)
@@ -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<ModelAPI_PluginManager> MY_MANAGER;
+std::shared_ptr<ModelAPI_PluginManager> MY_MANAGER;
 
 ModelAPI_PluginManager::ModelAPI_PluginManager()
 {
 }
 
 void ModelAPI_PluginManager::SetPluginManager(
-  boost::shared_ptr<ModelAPI_PluginManager> theManager)
+  std::shared_ptr<ModelAPI_PluginManager> theManager)
 {
   MY_MANAGER = theManager;
 }
 
-boost::shared_ptr<ModelAPI_PluginManager> ModelAPI_PluginManager::get()
+std::shared_ptr<ModelAPI_PluginManager> 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 <iostream>
 void ModelAPI_PluginManager::loadLibrary(const string theLibName)
 {
   string aFileName = library(theLibName);
index a7b0c7bcd769895137a649fc16d3874b734123f1..b53a66336d512b13dd815dcdb6bbd3318f6c8190 100644 (file)
@@ -7,7 +7,7 @@
 
 #include "ModelAPI.h"
 #include <string>
-#include <boost/shared_ptr.hpp>
+#include <memory>
 
 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<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
+  virtual std::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
 
   /// Returns the real implementation (the alone instance per application) of the plugin manager
-  static boost::shared_ptr<ModelAPI_PluginManager> get();
+  static std::shared_ptr<ModelAPI_PluginManager> 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<ModelAPI_Document> rootDocument() = 0;
+  virtual std::shared_ptr<ModelAPI_Document> 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<ModelAPI_PluginManager> theManager);
+  static void SetPluginManager(std::shared_ptr<ModelAPI_PluginManager> theManager);
 };
 
 #endif
index ab07cdc88c95c8d495c2127794685c3ff07cf55c..10d71fce75c5f3a173699115416a23a07bce5762 100644 (file)
@@ -1,7 +1,6 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
 
 INCLUDE(Common)
-INCLUDE(FindBoost)
 
 SET(PROJECT_HEADERS
     PartSetPlugin.h
index d94a74f30f14e513ab4aadec38cd3146f37e2e80..91baf0bc4e37b040e300aecba81a1b415140c292 100644 (file)
@@ -17,11 +17,11 @@ PartSetPlugin_Plugin::PartSetPlugin_Plugin()
   ModelAPI_PluginManager::get()->registerPlugin(this);
 }
 
-boost::shared_ptr<ModelAPI_Feature> PartSetPlugin_Plugin::createFeature(string theFeatureID)
+std::shared_ptr<ModelAPI_Feature> PartSetPlugin_Plugin::createFeature(string theFeatureID)
 {
-  boost::shared_ptr<ModelAPI_Feature> aCreated;
+  std::shared_ptr<ModelAPI_Feature> aCreated;
   if (theFeatureID == "new_part") {
-    aCreated = boost::shared_ptr<ModelAPI_Feature>(new PartSetPlugin_NewPart());
+    aCreated = std::shared_ptr<ModelAPI_Feature>(new PartSetPlugin_NewPart());
   }
   // add to a root document for the current moment
   if (aCreated)
index ff577f79a3adec8e2003a43ece502a805e536255..74f6e73c02d90caa136d918152b0ce52d2f5c650 100644 (file)
@@ -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<ModelAPI_Feature> createFeature(std::string theFeatureID);
+  virtual std::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
 
 public:
   /// Is needed for python wrapping by swig