00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkTreeChangeEvent.h,v $ 00005 Language: C++ 00006 Date: $Date: 2004/12/21 22:47:32 $ 00007 Version: $Revision: 1.2 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 #ifndef __TreeChangeEvent_h 00018 #define __TreeChangeEvent_h 00019 00020 #include "itkMacro.h" 00021 #include <itkObject.h> 00022 #include <itkTreeIteratorBase.h> 00023 00024 namespace itk 00025 { 00026 00031 template <class TTreeType> 00032 class TreeChangeEvent : public ModifiedEvent 00033 { 00034 public: 00035 00037 typedef TreeChangeEvent Self; 00038 typedef ModifiedEvent Superclass; 00039 00041 TreeChangeEvent() 00042 { 00043 m_ChangePosition = NULL; 00044 } 00045 00047 TreeChangeEvent(const TreeIteratorBase<TTreeType>& position) 00048 { 00049 m_ChangePosition = &position; 00050 } 00051 00053 virtual ~TreeChangeEvent() {} 00054 00056 virtual const char * GetEventName() const 00057 { 00058 return "TreeChangeEvent"; 00059 } 00060 00062 virtual bool CheckEvent(const ::itk::EventObject* e) const 00063 { 00064 return dynamic_cast<const Self*>(e); 00065 } 00066 00068 virtual ::itk::EventObject* MakeObject() const 00069 { 00070 return new Self( *m_ChangePosition ); 00071 } 00072 00074 const TreeIteratorBase<TTreeType>& GetChangePosition() const 00075 { 00076 return *m_ChangePosition; 00077 } 00078 00079 private: 00080 00081 // TreeChangeEvent(const Self&); 00082 void operator=(const Self&); 00083 00084 protected: 00085 00086 const TreeIteratorBase<TTreeType>* m_ChangePosition; 00087 }; 00088 00089 00094 template <class TTreeType> 00095 class TreeAddEvent : public TreeChangeEvent<TTreeType> 00096 { 00097 public: 00098 00100 typedef TreeAddEvent Self; 00101 typedef TreeChangeEvent<TTreeType> Superclass; 00102 00104 TreeAddEvent() {} 00105 00107 TreeAddEvent( const TreeIteratorBase<TTreeType>& position ) : 00108 TreeChangeEvent<TTreeType>(position) {} 00109 00111 virtual const char * GetEventName() const 00112 { 00113 return "TreeAddEvent"; 00114 } 00115 00117 virtual bool CheckEvent(const ::itk::EventObject* e) const 00118 { 00119 return dynamic_cast<const Self*>(e); 00120 } 00121 00123 virtual ::itk::EventObject* MakeObject() const 00124 { 00125 return new Self( *this->m_ChangePosition ); 00126 } 00127 }; 00129 00130 00135 template <class TTreeType> 00136 class TreeRemoveEvent : public TreeChangeEvent<TTreeType> 00137 { 00138 public: 00139 00141 typedef TreeRemoveEvent Self; 00142 typedef TreeChangeEvent<TTreeType> Superclass; 00143 00145 TreeRemoveEvent(){} 00146 00148 TreeRemoveEvent( const TreeIteratorBase<TTreeType>& position ) : 00149 TreeChangeEvent<TTreeType>(position) {} 00150 00152 virtual const char * GetEventName() const 00153 { 00154 return "TreeRemoveEvent"; 00155 } 00156 00158 virtual bool CheckEvent(const ::itk::EventObject* e) const 00159 { 00160 return dynamic_cast<const Self*>(e); 00161 } 00162 00164 virtual ::itk::EventObject* MakeObject() const 00165 { 00166 return new Self( *this->m_ChangePosition ); 00167 } 00168 }; 00170 00171 } // namespace itk 00172 00173 #endif 00174