Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkNodePredicateOr.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "mitkNodePredicateOr.h"
14 
16 {
17 }
18 
21 {
22  this->AddPredicate(p1);
23  this->AddPredicate(p2);
24 }
25 
27 {
28 }
29 
31 {
32  if (m_ChildPredicates.empty())
33  throw std::invalid_argument("NodePredicateOr: no child predicates available");
34 
35  if (node == nullptr)
36  throw std::invalid_argument("NodePredicateOr: invalid node");
37 
38  /* return the disjunction of the child predicate. If any predicate returns true, we return true too. Return false only
39  * if all child predicates return false */
40  for (auto it = m_ChildPredicates.cbegin(); it != m_ChildPredicates.cend(); ++it)
41  if ((*it)->CheckNode(node) == true)
42  return true;
43  return false; // none of the childs was true, so return false
44 }
bool CheckNode(const DataNode *node) const override
Checks, if the node fulfills any of the subpredicates conditions.
ChildPredicates m_ChildPredicates
list of child predicates
virtual void AddPredicate(const NodePredicateBase *p)
Adds a child predicate.
~NodePredicateOr() override
Standard Destructor.
Interface for evaluation conditions used in the DataStorage class GetSubset() method.
Base class for all predicates that can have child predicates (e.g. AND/OR)
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57