ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkTreeChangeEvent.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkTreeChangeEvent_h
19 #define itkTreeChangeEvent_h
20 
21 #include "itkMacro.h"
22 #include "itkEventObject.h"
23 #include "itkTreeIteratorBase.h"
24 
25 namespace itk
26 {
32 template< typename TTreeType >
33 class ITK_TEMPLATE_EXPORT TreeChangeEvent:public ModifiedEvent
34 {
35 public:
36 
39  typedef ModifiedEvent Superclass;
40 
43  m_ChangePosition( ITK_NULLPTR )
44  {}
45 
47  TreeChangeEvent(const TreeIteratorBase< TTreeType > & position) { m_ChangePosition = &position; }
48 
50  virtual ~TreeChangeEvent() ITK_OVERRIDE {}
51 
53  virtual const char * GetEventName() const ITK_OVERRIDE { return "TreeChangeEvent"; }
54 
56  virtual bool CheckEvent(const::itk::EventObject *e) const ITK_OVERRIDE { return (dynamic_cast< const Self * >( e ) != ITK_NULLPTR); }
57 
59  virtual::itk::EventObject * MakeObject() const ITK_OVERRIDE { return new Self(*m_ChangePosition); }
60 
62  const TreeIteratorBase< TTreeType > & GetChangePosition() const { return *m_ChangePosition; }
63 
64  // cppcheck-suppress uninitVar
65  TreeChangeEvent(const Self & s):itk::ModifiedEvent(s) {}
66 
67 protected:
68 
70 
71 private:
72  void operator=(const Self &);
73 };
74 
80 template< typename TTreeType >
81 class TreeNodeChangeEvent:public TreeChangeEvent< TTreeType >
82 {
83 public:
86 
88 
90  TreeChangeEvent< TTreeType >(position) {}
91 
92  virtual const char * GetEventName() const { return "TreeNodeChangeEvent"; }
93 
94  virtual bool CheckEvent(const::itk::EventObject *e) const { return dynamic_cast< const Self * >( e ); }
95 
96  virtual::itk::EventObject * MakeObject() const { return new Self(*this->m_ChangePosition); }
97 
98  TreeNodeChangeEvent(const Self & s):TreeChangeEvent< TTreeType >(s) {}
99 
100 private:
101  void operator=(const Self &);
102 };
103 
108 template< typename TTreeType >
109 class ITK_TEMPLATE_EXPORT TreeAddEvent:public TreeChangeEvent< TTreeType >
110 {
111 public:
112 
116 
119 
122  TreeChangeEvent< TTreeType >(position) {}
123 
125  virtual const char * GetEventName() const { return "TreeAddEvent"; }
126 
128  virtual bool CheckEvent(const::itk::EventObject *e) const { return (dynamic_cast< const Self * >( e ) != ITK_NULLPTR); }
129 
131  virtual::itk::EventObject * MakeObject() const { return new Self(*this->m_ChangePosition); }
132 
133  TreeAddEvent(const Self & s):TreeChangeEvent< TTreeType >(s) {}
134 
135 private:
136  void operator=(const Self &);
137 };
138 
143 template< typename TTreeType >
144 class ITK_TEMPLATE_EXPORT TreeRemoveEvent:public TreeChangeEvent< TTreeType >
145 {
146 public:
147 
151 
154 
157  TreeChangeEvent< TTreeType >(position) {}
158 
160  virtual const char * GetEventName() const { return "TreeRemoveEvent"; }
161 
163  virtual bool CheckEvent(const::itk::EventObject *e) const { return (dynamic_cast< const Self * >( e ) != ITK_NULLPTR); }
164 
166  virtual::itk::EventObject * MakeObject() const { return new Self(*this->m_ChangePosition); }
167 
168  TreeRemoveEvent(const Self & s):TreeChangeEvent< TTreeType >(s) {}
169 
170 private:
171  void operator=(const Self &);
172 };
173 
179 template< typename TTreeType >
180 class ITK_TEMPLATE_EXPORT TreePruneEvent:public TreeRemoveEvent< TTreeType >
181 {
182 public:
185 
187 
189  TreeRemoveEvent< TTreeType >(position) {}
190 
191  virtual const char * GetEventName() const { return "TreePruneEvent"; }
192 
193  virtual bool CheckEvent(const::itk::EventObject *e) const { return (dynamic_cast< const Self * >( e ) != ITK_NULLPTR); }
194 
195  virtual::itk::EventObject * MakeObject() const { return new Self(*this->m_ChangePosition); }
196 
197  TreePruneEvent(const Self & s):TreeRemoveEvent< TTreeType >(s) {}
198 
199 private:
200  void operator=(const Self &);
201 };
202 } // namespace itk
203 
204 #endif
TreeChangeEvent(const Self &s)
virtual ::itk::EventObject * MakeObject() const
TreeNodeChangeEvent Self
TreeChangeEvent< TTreeType > Superclass
const TreeIteratorBase< TTreeType > * m_ChangePosition
virtual bool CheckEvent(const ::itk::EventObject *e) const
virtual const char * GetEventName() const
const TreeIteratorBase< TTreeType > & GetChangePosition() const
virtual ::itk::EventObject * MakeObject() const
virtual const char * GetEventName() const
void operator=(const Self &)
TreeNodeChangeEvent(const TreeIteratorBase< TTreeType > &position)
TreePruneEvent(const TreeIteratorBase< TTreeType > &position)
Signals that a node and all its childs will shortly be removed. The position of the top-level removed...
TreeChangeEvent< TTreeType > Superclass
virtual const char * GetEventName() const override
TreeRemoveEvent(const TreeIteratorBase< TTreeType > &position)
TreeAddEvent(const TreeIteratorBase< TTreeType > &position)
virtual bool CheckEvent(const ::itk::EventObject *e) const
virtual ~TreeChangeEvent() override
virtual ::itk::EventObject * MakeObject() const override
virtual bool CheckEvent(const ::itk::EventObject *e) const
Checks if the position of a node in the tree has been changed.
virtual const char * GetEventName() const
virtual bool CheckEvent(const ::itk::EventObject *e) const override
Signals that a node has been set to another value. The position of the changed node is provided...
This class provides the base implementation for tree iterators.
TreeChangeEvent< TTreeType > Superclass
TreePruneEvent(const Self &s)
TreeNodeChangeEvent(const Self &s)
virtual ::itk::EventObject * MakeObject() const
TreeChangeEvent(const TreeIteratorBase< TTreeType > &position)
TreeAddEvent(const Self &s)
virtual ::itk::EventObject * MakeObject() const
TreeRemoveEvent(const Self &s)
TreeRemoveEvent< TTreeType > Superclass
Checks if a node has been removed from the tree.
Checks if a node has been added to the tree.
static ITK_CONSTEXPR_VAR double e
The base of the natural logarithm or Euler&#39;s number
Definition: itkMath.h:56
virtual bool CheckEvent(const ::itk::EventObject *e) const
virtual const char * GetEventName() const