summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-08-20 01:52:30 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-08-20 01:52:30 +0100
commit07e61f5e729884f8bdc19cf213c919ea6a98369c (patch)
tree4dbb2aa95d56dabf451fd0cad6a6c3ae4d49753a
parentCreate dictionary container/children ModelParts on the stack (diff)
downloadslicer-07e61f5e729884f8bdc19cf213c919ea6a98369c.tar.bz2
slicer-07e61f5e729884f8bdc19cf213c919ea6a98369c.tar.xz
slicer-07e61f5e729884f8bdc19cf213c919ea6a98369c.zip
Create Optional ModelParts as unique_ptrs
-rw-r--r--slicer/slicer/modelParts.h1
-rw-r--r--slicer/slicer/modelPartsTypes.h2
-rw-r--r--slicer/slicer/modelPartsTypes.impl.h4
3 files changed, 4 insertions, 3 deletions
diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h
index 39149fd..f521257 100644
--- a/slicer/slicer/modelParts.h
+++ b/slicer/slicer/modelParts.h
@@ -79,6 +79,7 @@ namespace Slicer {
class HookCommon;
using ModelPartPtr = std::shared_ptr<ModelPart>;
+ using ModelPartUPtr = std::unique_ptr<ModelPart>;
using ModelPartForRootPtr = std::unique_ptr<ModelPartForRootBase>;
using ModelPartParam = any_ptr<ModelPart>;
using ModelPartForRootParam = any_ptr<ModelPartForRootBase>;
diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h
index ab262f3..838bbd0 100644
--- a/slicer/slicer/modelPartsTypes.h
+++ b/slicer/slicer/modelPartsTypes.h
@@ -113,7 +113,7 @@ namespace Slicer {
protected:
virtual bool hasModel() const = 0;
- ModelPartPtr modelPart;
+ ModelPartUPtr modelPart;
};
template<typename T>
diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h
index 7884a02..3a4076e 100644
--- a/slicer/slicer/modelPartsTypes.impl.h
+++ b/slicer/slicer/modelPartsTypes.impl.h
@@ -300,7 +300,7 @@ namespace Slicer {
ModelPartModel<Ice::optional<typename T::element_type>>(h)
{
if (this->Model && *this->Model) {
- modelPart = std::make_shared<T>(&**this->Model);
+ modelPart = std::make_unique<T>(&**this->Model);
}
}
@@ -319,7 +319,7 @@ namespace Slicer {
BOOST_ASSERT(this->Model);
if (!*this->Model) {
*this->Model = typename T::element_type();
- modelPart = std::make_shared<T>(&**this->Model);
+ modelPart = std::make_unique<T>(&**this->Model);
modelPart->Create();
}
}