diff --git a/Modules/Core/include/mitkNodePredicateOr.h b/Modules/Core/include/mitkNodePredicateOr.h index 297bd0476f..59fb999c52 100644 --- a/Modules/Core/include/mitkNodePredicateOr.h +++ b/Modules/Core/include/mitkNodePredicateOr.h @@ -1,53 +1,57 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef mitkNodePredicateOr_h #define mitkNodePredicateOr_h #include "mitkNodePredicateCompositeBase.h" namespace mitk { //##Documentation //## @brief Composite predicate that forms a logical OR relation from its child predicates //## //## //## //## //## @ingroup DataStorage class MITKCORE_EXPORT NodePredicateOr : public NodePredicateCompositeBase { public: mitkClassMacro(NodePredicateOr, NodePredicateCompositeBase); itkFactorylessNewMacro(NodePredicateOr); mitkNewMacro2Param(NodePredicateOr, const NodePredicateBase *, const NodePredicateBase *); + mitkNewMacro3Param(NodePredicateOr, const NodePredicateBase *, const NodePredicateBase *, const NodePredicateBase *); //##Documentation //## @brief Standard Destructor ~NodePredicateOr() override; //##Documentation //## @brief Checks, if the node fulfills any of the subpredicates conditions bool CheckNode(const DataNode *node) const override; protected: //##Documentation //## @brief Constructor NodePredicateOr(); //##Documentation //## @brief Convenience constructor that adds p1 and p2 to list of child predicates NodePredicateOr(const NodePredicateBase *p1, const NodePredicateBase *p2); + //##Documentation + //## @brief Convenience constructor that adds p1, p2 and p3 to list of child predicates + NodePredicateOr(const NodePredicateBase *p1, const NodePredicateBase *p2, const NodePredicateBase *p3); }; } // namespace mitk #endif diff --git a/Modules/Core/src/DataManagement/mitkNodePredicateOr.cpp b/Modules/Core/src/DataManagement/mitkNodePredicateOr.cpp index 36d744e7bc..8212943fa8 100644 --- a/Modules/Core/src/DataManagement/mitkNodePredicateOr.cpp +++ b/Modules/Core/src/DataManagement/mitkNodePredicateOr.cpp @@ -1,44 +1,52 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "mitkNodePredicateOr.h" mitk::NodePredicateOr::NodePredicateOr() : NodePredicateCompositeBase() { } mitk::NodePredicateOr::NodePredicateOr(const NodePredicateBase *p1, const NodePredicateBase *p2) : NodePredicateCompositeBase() { this->AddPredicate(p1); this->AddPredicate(p2); } +mitk::NodePredicateOr::NodePredicateOr(const NodePredicateBase *p1, const NodePredicateBase *p2, const NodePredicateBase *p3) + : NodePredicateCompositeBase() +{ + this->AddPredicate(p1); + this->AddPredicate(p2); + this->AddPredicate(p3); +} + mitk::NodePredicateOr::~NodePredicateOr() { } bool mitk::NodePredicateOr::CheckNode(const DataNode *node) const { if (m_ChildPredicates.empty()) throw std::invalid_argument("NodePredicateOr: no child predicates available"); if (node == nullptr) throw std::invalid_argument("NodePredicateOr: invalid node"); /* return the disjunction of the child predicate. If any predicate returns true, we return true too. Return false only * if all child predicates return false */ for (auto it = m_ChildPredicates.cbegin(); it != m_ChildPredicates.cend(); ++it) if ((*it)->CheckNode(node) == true) return true; return false; // none of the childs was true, so return false }