Medical Imaging Interaction Toolkit  2018.4.99-9a29ffc6
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_HEADER_INCLUDED_
14 #define MITKNODEPREDICATEDATATYPE_H_HEADER_INCLUDED_
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
37  ~NodePredicateDataType() override;
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 /* MITKNODEPREDICATEDATATYPE_H_HEADER_INCLUDED_ */
#define MITKCORE_EXPORT
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:72
DataCollection - Class to facilitate loading/accessing structured data.
Tests for type compatibility (dynamic_cast).
bool CheckNode(const mitk::DataNode *node) const override
Checks, if the nodes data object is of a specific data type (casts)
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:40
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...
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57
TNodePredicateDataType()
Protected constructor, use static instantiation functions instead.