Medical Imaging Interaction Toolkit  2018.4.99-389bf124
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 (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 "mitkNodePredicateAnd.h"
14 
16 {
17 }
18 
21 {
22  this->AddPredicate(p1);
23  this->AddPredicate(p2);
24 }
25 
27  const NodePredicateBase *p2,
28  const NodePredicateBase *p3)
30 {
31  this->AddPredicate(p1);
32  this->AddPredicate(p2);
33  this->AddPredicate(p3);
34 }
35 
37 {
38 }
39 
41 {
42  if (m_ChildPredicates.empty())
43  throw std::invalid_argument("NodePredicateAnd: no child predicates available");
44 
45  if (node == nullptr)
46  throw std::invalid_argument("NodePredicateAnd: invalid node");
47 
48  // return the conjunction of the child predicate. If any predicate returns false, we return false too
49  for (auto it = m_ChildPredicates.cbegin(); (it != m_ChildPredicates.cend()); ++it)
50  if ((*it)->CheckNode(node) == false)
51  return false; // if one element of the conjunction is false, the whole conjunction gets false
52  return true; // none of the childs was false, so return true
53 }
ChildPredicates m_ChildPredicates
list of child predicates
virtual void AddPredicate(const NodePredicateBase *p)
Adds a child predicate.
~NodePredicateAnd() override
Standard Destructor.
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:57