diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-07-16 14:51:59 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-07-16 14:51:59 +0100 |
commit | 4db623074133380ca2378c1166c7f2ae7e6e5003 (patch) | |
tree | b0e68cb35c70f62df93412eb4d010a4be3eea418 | |
parent | Support getting a ModelPart for the elements in a container (with no actual m... (diff) | |
download | slicer-4db623074133380ca2378c1166c7f2ae7e6e5003.tar.bz2 slicer-4db623074133380ca2378c1166c7f2ae7e6e5003.tar.xz slicer-4db623074133380ca2378c1166c7f2ae7e6e5003.zip |
Remove the need for quirky 'on first item' initialisation of SQL statements
-rw-r--r-- | slicer/db/sqlInsertSerializer.cpp | 5 | ||||
-rw-r--r-- | slicer/db/sqlUpdateSerializer.cpp | 5 | ||||
-rw-r--r-- | slicer/slicer/modelPartsTypes.impl.h | 6 |
3 files changed, 4 insertions, 12 deletions
diff --git a/slicer/db/sqlInsertSerializer.cpp b/slicer/db/sqlInsertSerializer.cpp index 6c4cf31..e90fbf2 100644 --- a/slicer/db/sqlInsertSerializer.cpp +++ b/slicer/db/sqlInsertSerializer.cpp @@ -41,11 +41,8 @@ namespace Slicer { void SqlInsertSerializer::SerializeSequence(Slicer::ModelPartPtr mp) const { - ModifyPtr ins; + ModifyPtr ins = createInsert(mp->GetContainedModelPart()); mp->OnEachChild([&ins, this](const std::string &, ModelPartPtr cmp, HookCommonPtr) { - if (!ins) { - ins = createInsert(cmp); - } bindObjectAndExecute(cmp, ins.get()); }); } diff --git a/slicer/db/sqlUpdateSerializer.cpp b/slicer/db/sqlUpdateSerializer.cpp index a2a1fc2..ce9d868 100644 --- a/slicer/db/sqlUpdateSerializer.cpp +++ b/slicer/db/sqlUpdateSerializer.cpp @@ -40,11 +40,8 @@ namespace Slicer { void SqlUpdateSerializer::SerializeSequence(Slicer::ModelPartPtr mp) const { - ModifyPtr ins; + ModifyPtr ins = createUpdate(mp->GetContainedModelPart()); mp->OnEachChild([&ins, this](const std::string &, ModelPartPtr cmp, HookCommonPtr) { - if (!ins) { - ins = createUpdate(cmp); - } bindObjectAndExecute(cmp, ins.get()); }); } diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h index 43adc1e..9b9a5a7 100644 --- a/slicer/slicer/modelPartsTypes.impl.h +++ b/slicer/slicer/modelPartsTypes.impl.h @@ -164,8 +164,7 @@ namespace Slicer { ModelPartForOptional<T>::ModelPartForOptional(IceUtil::Optional< typename T::element_type > * h) : ModelPartModel<IceUtil::Optional< typename T::element_type> >(h) { - BOOST_ASSERT(this->Model); - if (*this->Model) { + if (hasModel()) { modelPart = new T(&**this->Model); } } @@ -173,8 +172,7 @@ namespace Slicer { template<typename T> bool ModelPartForOptional<T>::hasModel() const { - BOOST_ASSERT(this->Model); - return *this->Model; + return this->Model && *this->Model; } template<typename T> |