Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkNodePredicateDataProperty.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 
18 #include "mitkDataNode.h"
19 #include "mitkExceptionMacro.h"
20 
22 : NodePredicateBase(), m_ValidProperty(p), m_ValidPropertyName(propertyName)
23 {
24  if (m_ValidPropertyName.empty())
25  mitkThrow() << "NodePredicateDataProperty cannot check invalid (empty) property name";
26 }
27 
29 {
30 }
31 
33 {
34  if (node == nullptr)
35  {
36  mitkThrow() << "NodePredicateDataProperty cannot check invalid node";
37  }
38 
39  if (m_ValidPropertyName.empty())
40  {
41  mitkThrow() << "NodePredicateDataProperty cannot check invalid (empty) property name";
42  }
43 
44  bool result = false;
45  auto data = node->GetData();
46  if (data)
47  {
48  if (m_ValidProperty.IsNull())
49  {
50  result = data->GetProperty(m_ValidPropertyName.c_str()).IsNotNull(); // search only for name
51  }
52  else
53  {
54  mitk::BaseProperty::Pointer p = data->GetProperty(m_ValidPropertyName.c_str());
55 
56  if (p.IsNotNull())
57  {
58  result = (*p == *m_ValidProperty);
59  }
60  }
61  }
62  return result;
63 }
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
virtual bool CheckNode(const mitk::DataNode *node) const override
Checks, if the nodes contains a property that is equal to m_ValidProperty.
Abstract base class for properties.
virtual ~NodePredicateDataProperty()
Standard Destructor.
#define mitkThrow()
NodePredicateDataProperty(const char *propertyName, mitk::BaseProperty *p=nullptr)
Constructor to check for a named property.
Interface for evaluation conditions used in the DataStorage class GetSubset() method.
mitk::BaseProperty::Pointer GetProperty(const char *propertyKey) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList, and set it to this, respectively;.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66