00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #include "mitkNodePredicateOr.h" 00019 00020 00021 00022 00023 mitk::NodePredicateOr::NodePredicateOr() 00024 : NodePredicateCompositeBase() 00025 { 00026 } 00027 00028 mitk::NodePredicateOr::NodePredicateOr(const NodePredicateBase* p1, const NodePredicateBase* p2) 00029 : NodePredicateCompositeBase() 00030 { 00031 this->AddPredicate(p1); 00032 this->AddPredicate(p2); 00033 } 00034 00035 mitk::NodePredicateOr::~NodePredicateOr() 00036 { 00037 } 00038 00039 00040 bool mitk::NodePredicateOr::CheckNode(const DataNode* node) const 00041 { 00042 if (m_ChildPredicates.empty()) 00043 throw std::invalid_argument("NodePredicateOr: no child predicates available"); 00044 00045 if (node == NULL) 00046 throw std::invalid_argument("NodePredicateOr: invalid node"); 00047 00048 /* 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 */ 00049 for (ChildPredicates::const_iterator it = m_ChildPredicates.begin(); it != m_ChildPredicates.end(); ++it) 00050 if ((*it)->CheckNode(node) == true) 00051 return true; 00052 return false; // none of the childs was true, so return false 00053 }