Medical Imaging Interaction Toolkit  2018.4.99-9a29ffc6
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 (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 
14 
15 #include "mitkBaseData.h"
16 #include "mitkDataNode.h"
17 
19 {
20  if (datatype == nullptr)
21  throw std::invalid_argument("NodePredicateDataType: invalid datatype");
22 
23  m_ValidDataType = datatype;
24 }
25 
27 {
28 }
29 
31 {
32  if (node == nullptr)
33  throw std::invalid_argument("NodePredicateDataType: invalid node");
34 
35  mitk::BaseData *data = node->GetData();
36 
37  if (data == nullptr)
38  return false; // or should we check if m_ValidDataType == "nullptr" so that nodes without data can be requested?
39 
40  return (m_ValidDataType.compare(data->GetNameOfClass()) == 0); // return true if data type matches
41 }
NodePredicateDataType(const char *datatype)
Protected constructor, use static instantiation functions instead.
Base of all data objects.
Definition: mitkBaseData.h:42
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.
Interface for evaluation conditions used in the DataStorage class GetSubset() method.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57
~NodePredicateDataType() override
Standard Destructor.