ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkTreeChangeEvent.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkTreeChangeEvent_h
00019 #define __itkTreeChangeEvent_h
00020 
00021 #include "itkMacro.h"
00022 #include "itkEventObject.h"
00023 #include "itkTreeIteratorBase.h"
00024 
00025 namespace itk
00026 {
00032 template< class TTreeType >
00033 class TreeChangeEvent:public ModifiedEvent
00034 {
00035 public:
00036 
00038   typedef TreeChangeEvent Self;
00039   typedef ModifiedEvent   Superclass;
00040 
00042   TreeChangeEvent() { m_ChangePosition = NULL; }
00043 
00045   TreeChangeEvent(const TreeIteratorBase< TTreeType > & position) { m_ChangePosition = &position; }
00046 
00048   virtual ~TreeChangeEvent() {}
00049 
00051   virtual const char * GetEventName() const { return "TreeChangeEvent"; }
00052 
00054   virtual bool CheckEvent(const::itk::EventObject *e) const { return (dynamic_cast< const Self * >( e ) != NULL); }
00055 
00057   virtual::itk::EventObject * MakeObject() const { return new Self(*m_ChangePosition); }
00058 
00060   const TreeIteratorBase< TTreeType > & GetChangePosition() const { return *m_ChangePosition; }
00061 
00062   // cppcheck-suppress uninitVar
00063   TreeChangeEvent(const Self & s):itk::ModifiedEvent(s) {}
00064 protected:
00065 
00066   const TreeIteratorBase< TTreeType > *m_ChangePosition;
00067 private:
00068   void operator=(const Self &);
00069 };
00070 
00076 template< class TTreeType >
00077 class TreeNodeChangeEvent:public TreeChangeEvent< TTreeType >
00078 {
00079 public:
00080   typedef TreeNodeChangeEvent          Self;
00081   typedef TreeChangeEvent< TTreeType > Superclass;
00082 
00083   TreeNodeChangeEvent() {}
00084 
00085   TreeNodeChangeEvent(const TreeIteratorBase< TTreeType > & position):
00086     TreeChangeEvent< TTreeType >(position) {}
00087 
00088   virtual const char * GetEventName() const { return "TreeNodeChangeEvent"; }
00089 
00090   virtual bool CheckEvent(const::itk::EventObject *e) const { return dynamic_cast< const Self * >( e ); }
00091 
00092   virtual::itk::EventObject * MakeObject() const { return new Self(*this->m_ChangePosition); }
00093 
00094   TreeNodeChangeEvent(const Self & s):TreeChangeEvent< TTreeType >(s) {}
00095 private:
00096   void operator=(const Self &);
00097 };
00098 
00103 template< class TTreeType >
00104 class TreeAddEvent:public TreeChangeEvent< TTreeType >
00105 {
00106 public:
00107 
00109   typedef TreeAddEvent                 Self;
00110   typedef TreeChangeEvent< TTreeType > Superclass;
00111 
00113   TreeAddEvent() {}
00114 
00116   TreeAddEvent(const TreeIteratorBase< TTreeType > & position):
00117     TreeChangeEvent< TTreeType >(position) {}
00118 
00120   virtual const char * GetEventName() const { return "TreeAddEvent"; }
00121 
00123   virtual bool CheckEvent(const::itk::EventObject *e) const { return (dynamic_cast< const Self * >( e ) != NULL); }
00124 
00126   virtual::itk::EventObject * MakeObject() const { return new Self(*this->m_ChangePosition); }
00127 
00128   TreeAddEvent(const Self & s):TreeChangeEvent< TTreeType >(s) {}
00129 private:
00130   void operator=(const Self &);
00131 };
00132 
00137 template< class TTreeType >
00138 class TreeRemoveEvent:public TreeChangeEvent< TTreeType >
00139 {
00140 public:
00141 
00143   typedef TreeRemoveEvent              Self;
00144   typedef TreeChangeEvent< TTreeType > Superclass;
00145 
00147   TreeRemoveEvent(){}
00148 
00150   TreeRemoveEvent(const TreeIteratorBase< TTreeType > & position):
00151     TreeChangeEvent< TTreeType >(position) {}
00152 
00154   virtual const char * GetEventName() const { return "TreeRemoveEvent"; }
00155 
00157   virtual bool CheckEvent(const::itk::EventObject *e) const { return (dynamic_cast< const Self * >( e ) != NULL); }
00158 
00160   virtual::itk::EventObject * MakeObject() const { return new Self(*this->m_ChangePosition); }
00161 
00162   TreeRemoveEvent(const Self & s):TreeChangeEvent< TTreeType >(s) {}
00163 private:
00164   void operator=(const Self &);
00165 };
00166 
00172 template< class TTreeType >
00173 class TreePruneEvent:public TreeRemoveEvent< TTreeType >
00174 {
00175 public:
00176   typedef TreePruneEvent               Self;
00177   typedef TreeRemoveEvent< TTreeType > Superclass;
00178 
00179   TreePruneEvent(){}
00180 
00181   TreePruneEvent(const TreeIteratorBase< TTreeType > & position):
00182   TreeRemoveEvent< TTreeType >(position) {}
00183 
00184   virtual const char * GetEventName() const { return "TreePruneEvent"; }
00185 
00186   virtual bool CheckEvent(const::itk::EventObject *e) const { return (dynamic_cast< const Self * >( e ) != NULL); }
00187 
00188   virtual::itk::EventObject * MakeObject() const { return new Self(*this->m_ChangePosition); }
00189 
00190   TreePruneEvent(const Self & s):TreeRemoveEvent< TTreeType >(s) {}
00191 private:
00192   void operator=(const Self &);
00193 };
00194 } // namespace itk
00195 
00196 #endif
00197