00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 00019 #ifndef MITKNODEPREDICATEDATATYPE_H_HEADER_INCLUDED_ 00020 #define MITKNODEPREDICATEDATATYPE_H_HEADER_INCLUDED_ 00021 00022 #include "mitkNodePredicateBase.h" 00023 #include "mitkDataNode.h" 00024 #include <string> 00025 00026 namespace mitk { 00027 00028 //##Documentation 00029 //## @brief Predicate that evaluates if the given DataNodes data object is of a specific data type 00030 //## 00031 //## The data type must be specified in the constructor as a string. The string must equal the result 00032 //## value of the requested data types GetNameOfClass() method. 00033 //## 00034 //## @ingroup DataStorage 00035 class MITK_CORE_EXPORT NodePredicateDataType : public NodePredicateBase 00036 { 00037 public: 00038 mitkClassMacro(NodePredicateDataType, NodePredicateBase); 00039 mitkNewMacro1Param(NodePredicateDataType, const char*); 00040 00041 //##Documentation 00042 //## @brief Standard Destructor 00043 virtual ~NodePredicateDataType(); 00044 00045 //##Documentation 00046 //## @brief Checks, if the nodes data object is of a specific data type 00047 virtual bool CheckNode(const mitk::DataNode* node) const; 00048 00049 protected: 00050 //##Documentation 00051 //## @brief Protected constructor, use static instantiation functions instead 00052 NodePredicateDataType(const char* datatype); 00053 00054 std::string m_ValidDataType; 00055 }; 00056 00065 template <class T> 00066 class TNodePredicateDataType : public NodePredicateBase 00067 { 00068 public: 00069 mitkClassMacro(TNodePredicateDataType, NodePredicateBase); 00070 itkFactorylessNewMacro(TNodePredicateDataType); 00071 00072 virtual ~TNodePredicateDataType() 00073 { 00074 } 00075 00076 //##Documentation 00077 //## @brief Checks, if the nodes data object is of a specific data type (casts) 00078 virtual bool CheckNode(const mitk::DataNode* node) const 00079 { 00080 return node && node->GetData() && dynamic_cast<T*>(node->GetData()); 00081 } 00082 protected: 00083 //##Documentation 00084 //## @brief Protected constructor, use static instantiation functions instead 00085 TNodePredicateDataType() 00086 { 00087 } 00088 }; 00089 00090 } // namespace mitk 00091 00092 #endif /* MITKNODEPREDICATEDATATYPE_H_HEADER_INCLUDED_ */ 00093