Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkNodePredicateDataType.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 
19 #include "mitkBaseData.h"
20 #include "mitkDataNode.h"
21 
23 {
24  if (datatype == nullptr)
25  throw std::invalid_argument("NodePredicateDataType: invalid datatype");
26 
27  m_ValidDataType = datatype;
28 }
29 
31 {
32 }
33 
35 {
36  if (node == nullptr)
37  throw std::invalid_argument("NodePredicateDataType: invalid node");
38 
39  mitk::BaseData *data = node->GetData();
40 
41  if (data == nullptr)
42  return false; // or should we check if m_ValidDataType == "NULL" so that nodes without data can be requested?
43 
44  return (m_ValidDataType.compare(data->GetNameOfClass()) == 0); // return true if data type matches
45 }
NodePredicateDataType(const char *datatype)
Protected constructor, use static instantiation functions instead.
Base of all data objects.
Definition: mitkBaseData.h:39
virtual bool CheckNode(const mitk::DataNode *node) const override
Checks, if the nodes data object is of a specific data type.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
virtual ~NodePredicateDataType()
Standard Destructor.
Interface for evaluation conditions used in the DataStorage class GetSubset() method.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66