Medical Imaging Interaction Toolkit  2016.11.0
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,
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 
17 #ifndef MITKNODEPREDICATEDATATYPE_H_HEADER_INCLUDED_
18 #define MITKNODEPREDICATEDATATYPE_H_HEADER_INCLUDED_
19 
20 #include "mitkDataNode.h"
21 #include "mitkNodePredicateBase.h"
22 #include <string>
23 
24 namespace mitk
25 {
26  //##Documentation
27  //## @brief Predicate that evaluates if the given DataNodes data object is of a specific data type
28  //##
29  //## The data type must be specified in the constructor as a string. The string must equal the result
30  //## value of the requested data types GetNameOfClass() method.
31  //##
32  //## @ingroup DataStorage
34  {
35  public:
38 
39  //##Documentation
40  //## @brief Standard Destructor
41  virtual ~NodePredicateDataType();
42 
43  //##Documentation
44  //## @brief Checks, if the nodes data object is of a specific data type
45  virtual bool CheckNode(const mitk::DataNode *node) const override;
46 
47  protected:
48  //##Documentation
49  //## @brief Protected constructor, use static instantiation functions instead
50  NodePredicateDataType(const char *datatype);
51 
52  std::string m_ValidDataType;
53  };
54 
63  template <class T>
65  {
66  public:
68  itkFactorylessNewMacro(TNodePredicateDataType);
69 
71  //##Documentation
72  //## @brief Checks, if the nodes data object is of a specific data type (casts)
73  virtual bool CheckNode(const mitk::DataNode *node) const override
74  {
75  return node && node->GetData() && dynamic_cast<T *>(node->GetData());
76  }
77 
78  protected:
79  //##Documentation
80  //## @brief Protected constructor, use static instantiation functions instead
82  };
83 
84 } // namespace mitk
85 
86 #endif /* MITKNODEPREDICATEDATATYPE_H_HEADER_INCLUDED_ */
#define MITKCORE_EXPORT
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:76
DataCollection - Class to facilitate loading/accessing structured data.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
Tests for type compatibility (dynamic_cast).
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
virtual bool CheckNode(const mitk::DataNode *node) const override
Checks, if the nodes data object is of a specific data type (casts)
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:66
TNodePredicateDataType()
Protected constructor, use static instantiation functions instead.