Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkNodePredicateOr.h"
18 
20 {
21 }
22 
25 {
26  this->AddPredicate(p1);
27  this->AddPredicate(p2);
28 }
29 
31 {
32 }
33 
35 {
36  if (m_ChildPredicates.empty())
37  throw std::invalid_argument("NodePredicateOr: no child predicates available");
38 
39  if (node == nullptr)
40  throw std::invalid_argument("NodePredicateOr: invalid node");
41 
42  /* return the disjunction of the child predicate. If any predicate returns true, we return true too. Return false only
43  * if all child predicates return false */
44  for (auto it = m_ChildPredicates.cbegin(); it != m_ChildPredicates.cend(); ++it)
45  if ((*it)->CheckNode(node) == true)
46  return true;
47  return false; // none of the childs was true, so return false
48 }
virtual bool CheckNode(const DataNode *node) const override
Checks, if the node fulfills any of the subpredicates conditions.
virtual void AddPredicate(const NodePredicateBase *p)
Adds a child predicate.
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)
virtual ~NodePredicateOr()
Standard Destructor.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66