INCLUDE(Common)
INCLUDE(FindCAS)
-INCLUDE(FindBoost)
SET(PROJECT_HEADERS
Model.h
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)
//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;
}
//! 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
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
#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
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()
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;
}
* 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();
//! 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
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);
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"));
}
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);
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
FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})
INCLUDE(FindPython)
-INCLUDE(FindBoost)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
SET(PROJECT_HEADERS
%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"
#define ModelAPI_Document_HeaderFile
#include <ModelAPI.h>
-#include <boost/shared_ptr.hpp>
+#include <memory>
class ModelAPI_Feature;
//! 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:
#include "ModelAPI.h"
#include <string>
-#include <boost/shared_ptr.hpp>
+#include <memory>
class ModelAPI_Feature;
{
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
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");
return aLibName;
}
+#include <iostream>
void ModelAPI_PluginManager::loadLibrary(const string theLibName)
{
string aFileName = library(theLibName);
#include "ModelAPI.h"
#include <string>
-#include <boost/shared_ptr.hpp>
+#include <memory>
class ModelAPI_Feature;
class ModelAPI_Plugin;
{
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
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);
ModelAPI_PluginManager();
protected:
- static void SetPluginManager(boost::shared_ptr<ModelAPI_PluginManager> theManager);
+ static void SetPluginManager(std::shared_ptr<ModelAPI_PluginManager> theManager);
};
#endif
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
INCLUDE(Common)
-INCLUDE(FindBoost)
SET(PROJECT_HEADERS
PartSetPlugin.h
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)
{
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