Medical Imaging Interaction Toolkit  2025.12.02
Medical Imaging Interaction Toolkit
mitkNodePredicateDataType.h
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 
13 #ifndef mitkNodePredicateDataType_h
14 #define mitkNodePredicateDataType_h
15 
16 #include "mitkDataNode.h"
17 #include "mitkNodePredicateBase.h"
18 #include <string>
19 
20 namespace mitk
21 {
22  //##Documentation
23  //## @brief Predicate that evaluates if the given DataNodes data object is of a specific data type
24  //##
25  //## The data type must be specified in the constructor as a string. The string must equal the result
26  //## value of the requested data types GetNameOfClass() method.
27  //##
28  //## @ingroup DataStorage
30  {
31  public:
34 
35  //##Documentation
36  //## @brief Standard Destructor
38 
39  //##Documentation
40  //## @brief Checks, if the nodes data object is of a specific data type
41  bool CheckNode(const mitk::DataNode *node) const override;
42 
43  protected:
44  //##Documentation
45  //## @brief Protected constructor, use static instantiation functions instead
46  NodePredicateDataType(const char *datatype);
47 
48  std::string m_ValidDataType;
49  };
50 
59  template <class T>
61  {
62  public:
64  itkFactorylessNewMacro(TNodePredicateDataType);
65 
67  //##Documentation
68  //## @brief Checks, if the nodes data object is of a specific data type (casts)
69  bool CheckNode(const mitk::DataNode *node) const override
70  {
71  return node && node->GetData() && dynamic_cast<T *>(node->GetData());
72  }
73 
74  protected:
75  //##Documentation
76  //## @brief Protected constructor, use static instantiation functions instead
78  };
79 
80 } // namespace mitk
81 
82 #endif
#define MITKCORE_EXPORT
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64
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.
Predicate that evaluates if the given DataNodes data object is of a specific data type.
bool CheckNode(const mitk::DataNode *node) const override
Checks, if the nodes data object is of a specific data type.
NodePredicateDataType(const char *datatype)
Protected constructor, use static instantiation functions instead.
mitkNewMacro1Param(NodePredicateDataType, const char *)
mitkClassMacro(NodePredicateDataType, NodePredicateBase)
~NodePredicateDataType() override
Standard Destructor.
Tests for type compatibility (dynamic_cast).
TNodePredicateDataType()
Protected constructor, use static instantiation functions instead.
mitkClassMacro(TNodePredicateDataType, NodePredicateBase)
bool CheckNode(const mitk::DataNode *node) const override
Checks, if the nodes data object is of a specific data type (casts)
Find image slices visible on a given plane.