Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkNodePredicateAnd.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 "mitkNodePredicateAnd.h"
18 
20 {
21 }
22 
25 {
26  this->AddPredicate(p1);
27  this->AddPredicate(p2);
28 }
29 
31  const NodePredicateBase *p2,
32  const NodePredicateBase *p3)
34 {
35  this->AddPredicate(p1);
36  this->AddPredicate(p2);
37  this->AddPredicate(p3);
38 }
39 
41 {
42 }
43 
45 {
46  if (m_ChildPredicates.empty())
47  throw std::invalid_argument("NodePredicateAnd: no child predicates available");
48 
49  if (node == nullptr)
50  throw std::invalid_argument("NodePredicateAnd: invalid node");
51 
52  // return the conjunction of the child predicate. If any predicate returns false, we return false too
53  for (auto it = m_ChildPredicates.cbegin(); (it != m_ChildPredicates.cend()); ++it)
54  if ((*it)->CheckNode(node) == false)
55  return false; // if one element of the conjunction is false, the whole conjunction gets false
56  return true; // none of the childs was false, so return true
57 }
virtual void AddPredicate(const NodePredicateBase *p)
Adds a child predicate.
virtual bool CheckNode(const DataNode *node) const override
Checks, if the node fulfills all of the subpredicates conditions.
NodePredicateAnd()
Protected constructor, use static instantiation functions instead.
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:66
virtual ~NodePredicateAnd()
Standard Destructor.