From b6a71601408da2d6a5c5a3f149b47ce230691e88 Mon Sep 17 00:00:00 2001 From: Miklos Espak Date: Fri, 12 Aug 2011 16:10:20 +0200 Subject: [PATCH] Atomic node predicates --- .../DataManagement/mitkNodePredicateAtomic.cpp | 47 ++++++++++++++++ Core/Code/DataManagement/mitkNodePredicateAtomic.h | 59 ++++++++++++++++++++ Core/Code/files.cmake | 1 + 3 files changed, 107 insertions(+), 0 deletions(-) create mode 100644 Core/Code/DataManagement/mitkNodePredicateAtomic.cpp create mode 100644 Core/Code/DataManagement/mitkNodePredicateAtomic.h diff --git a/Core/Code/DataManagement/mitkNodePredicateAtomic.cpp b/Core/Code/DataManagement/mitkNodePredicateAtomic.cpp new file mode 100644 index 0000000..486564e --- /dev/null +++ b/Core/Code/DataManagement/mitkNodePredicateAtomic.cpp @@ -0,0 +1,47 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "mitkNodePredicateAtomic.h" + +#include "mitkDataNode.h" + + +mitk::NodePredicateAtomic::NodePredicateAtomic(bool value) +: NodePredicateBase() +{ + m_Value = value; +} + + +mitk::NodePredicateAtomic::~NodePredicateAtomic() +{ +} + + +bool mitk::NodePredicateAtomic::CheckNode(const mitk::DataNode* node) const +{ + if (node == NULL) + throw std::invalid_argument("NodePredicateAtomic: invalid node"); + + return m_Value; +} + +mitk::NodePredicateAtomic* mitk::NodePredicateAtomic::FALSE = + new mitk::NodePredicateAtomic(false); + +mitk::NodePredicateAtomic* mitk::NodePredicateAtomic::TRUE = + new mitk::NodePredicateAtomic(true); diff --git a/Core/Code/DataManagement/mitkNodePredicateAtomic.h b/Core/Code/DataManagement/mitkNodePredicateAtomic.h new file mode 100644 index 0000000..12a22d9 --- /dev/null +++ b/Core/Code/DataManagement/mitkNodePredicateAtomic.h @@ -0,0 +1,59 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef MITKNODEPREDICATEATOMIC_H_HEADER_INCLUDED_ +#define MITKNODEPREDICATEATOMIC_H_HEADER_INCLUDED_ + +#include "mitkNodePredicateBase.h" + +namespace mitk { + + //##Documentation + //## @brief Atomic predicates that evaluate 'true' or 'false' for every valid node + //## + //## The class cannot be instantiated. You can refer to its two predefined objects by + //## mitk::NodePredicateAtomic::FALSE and mitk::NodePredicateAtomic::TRUE, respectively. + //## + //## @ingroup DataStorage + class MITK_CORE_EXPORT NodePredicateAtomic : public NodePredicateBase + { + public: +// mitkClassMacro(NodePredicateAtomic, NodePredicateBase); + + //##Documentation + //## @brief Standard Destructor + virtual ~NodePredicateAtomic(); + + //##Documentation + //## @brief Returns 'true' or 'false' for every valid node. If the parameter is NULL, an exception is thrown. + virtual bool CheckNode(const mitk::DataNode* node) const; + + // Smart pointers are not needed, since only these two instances will exist. + static NodePredicateAtomic* FALSE; + static NodePredicateAtomic* TRUE; + + private: + //##Documentation + //## @brief Protected constructor, use static instantiation functions instead + NodePredicateAtomic(bool value); + + bool m_Value; + }; +} // namespace mitk + +#endif /* MITKNODEPREDICATEATOMIC_H_HEADER_INCLUDED_ */ diff --git a/Core/Code/files.cmake b/Core/Code/files.cmake index a0c3235..8ca9efa 100644 --- a/Core/Code/files.cmake +++ b/Core/Code/files.cmake @@ -138,6 +138,7 @@ SET(CPP_FILES DataManagement/mitkModeOperation.cpp DataManagement/mitkNodePredicateAnd.cpp DataManagement/mitkNodePredicateBase.cpp + DataManagement/mitkNodePredicateAtomic.cpp DataManagement/mitkNodePredicateCompositeBase.cpp DataManagement/mitkNodePredicateData.cpp DataManagement/mitkNodePredicateDataType.cpp -- 1.7.4.1