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 "mitkNodePredicateProperty.h" 00019 #include "mitkDataNode.h" 00020 00021 00022 00023 mitk::NodePredicateProperty::NodePredicateProperty(const char* propertyName, mitk::BaseProperty* p) 00024 : NodePredicateBase(), m_ValidProperty(p), m_ValidPropertyName(propertyName) 00025 { 00026 } 00027 00028 mitk::NodePredicateProperty::NodePredicateProperty(const char* propertyName) 00029 : NodePredicateBase(), m_ValidProperty(NULL), m_ValidPropertyName(propertyName) 00030 { 00031 } 00032 00033 mitk::NodePredicateProperty::~NodePredicateProperty() 00034 { 00035 } 00036 00037 00038 bool mitk::NodePredicateProperty::CheckNode(const mitk::DataNode* node) const 00039 { 00040 if (node == NULL) 00041 throw std::invalid_argument("NodePredicateProperty: invalid node"); 00042 00043 if (m_ValidPropertyName.empty()) 00044 throw std::invalid_argument("NodePredicateProperty: invalid property name"); 00045 00046 // check, if any of the properties of node are equal to m_ValidProperty. 00047 if (m_ValidProperty.IsNull()) 00048 //if (m_ValidProperty==NULL) 00049 { 00050 return (node->GetPropertyList()->GetProperty(m_ValidPropertyName.c_str()) != NULL); // search only for name 00051 } 00052 else 00053 { 00054 mitk::BaseProperty::Pointer p = node->GetPropertyList()->GetProperty(m_ValidPropertyName.c_str()); 00055 if (p.IsNull()) 00056 return false; 00057 return (*p == *m_ValidProperty); // search for name and property 00058 } 00059 }