diff --git a/src/simplnx/DataStructure/AttributeMatrix.cpp b/src/simplnx/DataStructure/AttributeMatrix.cpp index 43e995fa4d..6d10e3df0f 100644 --- a/src/simplnx/DataStructure/AttributeMatrix.cpp +++ b/src/simplnx/DataStructure/AttributeMatrix.cpp @@ -78,7 +78,7 @@ std::string AttributeMatrix::getTypeName() const return k_TypeName; } -Result AttributeMatrix::canInsert(const DataObject* obj) const +Result<> AttributeMatrix::canInsert(const DataObject* obj) const { auto result = BaseGroup::canInsert(obj); if(result.invalid()) @@ -90,7 +90,7 @@ Result AttributeMatrix::canInsert(const DataObject* obj) const if(arrayObjectPtr == nullptr) { - return MakeErrorResult(-1673, "BaseGroup::canInsert() Error: DataObject being inserted is null"); + return MakeErrorResult<>(-1673, "BaseGroup::canInsert() Error: DataObject being inserted is null"); } const IArray::ShapeType arrayTupleShape = arrayObjectPtr->getTupleShape(); @@ -99,9 +99,9 @@ Result AttributeMatrix::canInsert(const DataObject* obj) const const usize incomingTupleCount = std::accumulate(arrayTupleShape.cbegin(), arrayTupleShape.cend(), static_cast(1), std::multiplies<>()); if(totalTuples != incomingTupleCount) { - return MakeErrorResult(-1674, fmt::format("AttributeMatrix: CanInsert() Failed with object {}. totalTuples={} incomingTupleCount={}", obj->getName(), totalTuples, incomingTupleCount)); + return MakeErrorResult<>(-1674, fmt::format("AttributeMatrix: CanInsert() Failed with object {}. totalTuples={} incomingTupleCount={}", obj->getName(), totalTuples, incomingTupleCount)); } - return {true}; + return {}; } const AttributeMatrix::ShapeType& AttributeMatrix::getShape() const diff --git a/src/simplnx/DataStructure/AttributeMatrix.hpp b/src/simplnx/DataStructure/AttributeMatrix.hpp index 65801370eb..8ec5b2f8a9 100644 --- a/src/simplnx/DataStructure/AttributeMatrix.hpp +++ b/src/simplnx/DataStructure/AttributeMatrix.hpp @@ -171,7 +171,7 @@ class SIMPLNX_EXPORT AttributeMatrix : public BaseGroup * @param obj * @return bool */ - Result canInsert(const DataObject* obj) const override; + Result<> canInsert(const DataObject* obj) const override; private: ShapeType m_TupleShape; diff --git a/src/simplnx/DataStructure/BaseGroup.cpp b/src/simplnx/DataStructure/BaseGroup.cpp index 5bfa42f35e..edcad07233 100644 --- a/src/simplnx/DataStructure/BaseGroup.cpp +++ b/src/simplnx/DataStructure/BaseGroup.cpp @@ -100,22 +100,22 @@ const DataObject& BaseGroup::at(const std::string& name) const return m_DataMap.at(name); } -Result BaseGroup::canInsert(const DataObject* obj) const +Result<> BaseGroup::canInsert(const DataObject* obj) const { if(obj == nullptr) { - return MakeErrorResult(-1663, "BaseGroup::canInsert() Error: DataObject being inserted is null"); + return MakeErrorResult<>(-1663, "BaseGroup::canInsert() Error: DataObject being inserted is null"); } if(contains(obj) || contains(obj->getName())) { - return MakeErrorResult(-1664, fmt::format("BaseGroup::canInsert() Error: DataObject with name='{}' and type='{}' already exists in the DataMap", obj->getName(), obj->getTypeName())); + return MakeErrorResult<>(-1664, fmt::format("BaseGroup::canInsert() Error: DataObject with name='{}' and type='{}' already exists in the DataMap", obj->getName(), obj->getTypeName())); } if(const auto* objGroup = dynamic_cast(obj); objGroup != nullptr && objGroup->isParentOf(this)) { - return MakeErrorResult(-1665, fmt::format("BaseGroup::canInsert() Error: DataObject with name='{}' and type='{}' is a parent of the current DataObject. A circular reference would occur.", - obj->getName(), obj->getTypeName())); + return MakeErrorResult<>(-1665, fmt::format("BaseGroup::canInsert() Error: DataObject with name='{}' and type='{}' is a parent of the current DataObject. A circular reference would occur.", + obj->getName(), obj->getTypeName())); } - return {true}; + return {}; } void BaseGroup::setDataStructure(DataStructure* dataStructure) @@ -140,7 +140,7 @@ bool BaseGroup::isParentOf(const DataObject* dataObj) const return std::find_if(origDataPaths.begin(), origDataPaths.end(), [dataObj](const DataPath& path) { return dataObj->hasParent(path); }) != origDataPaths.end(); } -Result BaseGroup::insert(const std::weak_ptr& obj) +Result<> BaseGroup::insert(const std::weak_ptr& obj) { auto ptr = obj.lock(); auto result = canInsert(ptr.get()); @@ -151,10 +151,10 @@ Result BaseGroup::insert(const std::weak_ptr& obj) if(m_DataMap.insert(ptr)) { ptr->addParent(this); - return {true}; + return {}; } - return MakeErrorResult( - -1666, fmt::format("BaseGroup::insert() Error: DataObject with name='{}' and type='{}' could not be inserted into the DataMap.", obj.lock()->getName(), obj.lock()->getTypeName())); + return MakeErrorResult<>(-1666, + fmt::format("BaseGroup::insert() Error: DataObject with name='{}' and type='{}' could not be inserted into the DataMap.", obj.lock()->getName(), obj.lock()->getTypeName())); } bool BaseGroup::remove(DataObject* obj) diff --git a/src/simplnx/DataStructure/BaseGroup.hpp b/src/simplnx/DataStructure/BaseGroup.hpp index f36ac5bb7c..e3b2fd3f71 100644 --- a/src/simplnx/DataStructure/BaseGroup.hpp +++ b/src/simplnx/DataStructure/BaseGroup.hpp @@ -252,7 +252,7 @@ class SIMPLNX_EXPORT BaseGroup : public DataObject * @param obj * @return bool */ - Result insert(const std::weak_ptr& obj); + Result<> insert(const std::weak_ptr& obj); /** * Attempts to remove the specified DataObject from the container. Returns @@ -374,7 +374,7 @@ class SIMPLNX_EXPORT BaseGroup : public DataObject * @param obj * @return bool */ - virtual Result canInsert(const DataObject* obj) const; + virtual Result<> canInsert(const DataObject* obj) const; /** * @brief Sets a new DataStructure for the BaseGroup. Updates the DataMap diff --git a/src/simplnx/DataStructure/DataGroup.cpp b/src/simplnx/DataStructure/DataGroup.cpp index 415c10168e..b37db5e53c 100644 --- a/src/simplnx/DataStructure/DataGroup.cpp +++ b/src/simplnx/DataStructure/DataGroup.cpp @@ -79,7 +79,7 @@ std::string DataGroup::getTypeName() const return k_TypeName; } -Result DataGroup::canInsert(const DataObject* obj) const +Result<> DataGroup::canInsert(const DataObject* obj) const { return BaseGroup::canInsert(obj); } diff --git a/src/simplnx/DataStructure/DataGroup.hpp b/src/simplnx/DataStructure/DataGroup.hpp index c1f0bb1374..4ff9607cb6 100644 --- a/src/simplnx/DataStructure/DataGroup.hpp +++ b/src/simplnx/DataStructure/DataGroup.hpp @@ -126,6 +126,6 @@ class SIMPLNX_EXPORT DataGroup : public BaseGroup * @param obj * @return bool */ - Result canInsert(const DataObject* obj) const override; + Result<> canInsert(const DataObject* obj) const override; }; } // namespace nx::core diff --git a/src/simplnx/DataStructure/DataStructure.cpp b/src/simplnx/DataStructure/DataStructure.cpp index 60c6ffb12f..34b010411b 100644 --- a/src/simplnx/DataStructure/DataStructure.cpp +++ b/src/simplnx/DataStructure/DataStructure.cpp @@ -567,7 +567,7 @@ bool DataStructure::finishAddingObject(const std::shared_ptr& dataOb { return false; } - if(!parentContainer->insert(dataObject)) + if(parentContainer->insert(dataObject).invalid()) { return false; } @@ -658,7 +658,7 @@ bool DataStructure::insertIntoParent(const std::shared_ptr& dataObje return false; } - if(!parentGroup->insert(dataObject)) + if(parentGroup->insert(dataObject).invalid()) { return false; } @@ -692,7 +692,7 @@ bool DataStructure::setAdditionalParent(DataObject::IdType targetId, DataObject: return false; } - if(!newParent->insert(target)) + if(newParent->insert(target).invalid()) { return false; } diff --git a/src/simplnx/DataStructure/Montage/AbstractMontage.cpp b/src/simplnx/DataStructure/Montage/AbstractMontage.cpp index c134296d26..aaa468b490 100644 --- a/src/simplnx/DataStructure/Montage/AbstractMontage.cpp +++ b/src/simplnx/DataStructure/Montage/AbstractMontage.cpp @@ -102,11 +102,11 @@ const AbstractMontage::CollectionType& AbstractMontage::getCollection() const return m_Collection; } -Result AbstractMontage::canInsert(const DataObject* obj) const +Result<> AbstractMontage::canInsert(const DataObject* obj) const { if(!dynamic_cast(obj)) { - return MakeErrorResult(-1676, fmt::format("AbstractMontage::canInsert() Error: DataObject with name='{}' and type='{}' is not subclass of IGeometry", obj->getName(), obj->getTypeName())); + return MakeErrorResult<>(-1676, fmt::format("AbstractMontage::canInsert() Error: DataObject with name='{}' and type='{}' is not subclass of IGeometry", obj->getName(), obj->getTypeName())); } return BaseGroup::canInsert(obj); } diff --git a/src/simplnx/DataStructure/Montage/AbstractMontage.hpp b/src/simplnx/DataStructure/Montage/AbstractMontage.hpp index 90fb6d4d70..8d0cfdf8dd 100644 --- a/src/simplnx/DataStructure/Montage/AbstractMontage.hpp +++ b/src/simplnx/DataStructure/Montage/AbstractMontage.hpp @@ -162,7 +162,7 @@ class SIMPLNX_EXPORT AbstractMontage : public BaseGroup * @param obj * @return bool */ - Result canInsert(const DataObject* obj) const override; + Result<> canInsert(const DataObject* obj) const override; /** * @brief Returns a reference of the collection for use in derived classes.