ITK  5.0.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  using Superclass = ModifiedEvent;
40 
43  m_ChangePosition( nullptr )
44  {}
45 
47  TreeChangeEvent(const TreeIteratorBase< TTreeType > & position) { m_ChangePosition = &position; }
48 
50  ~TreeChangeEvent() override = default;
51 
53  const char * GetEventName() const override { return "TreeChangeEvent"; }
54 
56  bool CheckEvent(const::itk::EventObject *e) const override { return (dynamic_cast< const Self * >( e ) != nullptr); }
57 
59  ::itk::EventObject * MakeObject() const 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 &) = delete;
73 };
74 
80 template< typename TTreeType >
81 class TreeNodeChangeEvent:public TreeChangeEvent< TTreeType >
82 {
83 public:
86 
87  TreeNodeChangeEvent() = default;
88 
90  TreeChangeEvent< TTreeType >(position) {}
91 
92  const char * GetEventName() const override { return "TreeNodeChangeEvent"; }
93 
94  bool CheckEvent(const::itk::EventObject *e) const override
95  {
96  auto eSelf = dynamic_cast< const Self* >( e );
97  return eSelf != nullptr;
98  }
99 
100  ::itk::EventObject * MakeObject() const override { return new Self(*this->m_ChangePosition); }
101 
102  TreeNodeChangeEvent(const Self & s):TreeChangeEvent< TTreeType >(s) {}
103 
104 private:
105  void operator=(const Self &) = delete;
106 };
107 
112 template< typename TTreeType >
113 class ITK_TEMPLATE_EXPORT TreeAddEvent:public TreeChangeEvent< TTreeType >
114 {
115 public:
116 
120 
122  TreeAddEvent() = default;
123 
126  TreeChangeEvent< TTreeType >(position) {}
127 
129  const char * GetEventName() const override { return "TreeAddEvent"; }
130 
132  bool CheckEvent(const::itk::EventObject *e) const override { return (dynamic_cast< const Self * >( e ) != nullptr); }
133 
135  ::itk::EventObject * MakeObject() const override { return new Self(*this->m_ChangePosition); }
136 
137  TreeAddEvent(const Self & s):TreeChangeEvent< TTreeType >(s) {}
138 
139 private:
140  void operator=(const Self &) = delete;
141 };
142 
147 template< typename TTreeType >
148 class ITK_TEMPLATE_EXPORT TreeRemoveEvent:public TreeChangeEvent< TTreeType >
149 {
150 public:
151 
155 
157  TreeRemoveEvent()= default;
158 
161  TreeChangeEvent< TTreeType >(position) {}
162 
164  const char * GetEventName() const override { return "TreeRemoveEvent"; }
165 
167  bool CheckEvent(const::itk::EventObject *e) const override { return (dynamic_cast< const Self * >( e ) != nullptr); }
168 
170  ::itk::EventObject * MakeObject() const override { return new Self(*this->m_ChangePosition); }
171 
172  TreeRemoveEvent(const Self & s):TreeChangeEvent< TTreeType >(s) {}
173 
174 private:
175  void operator=(const Self &) = delete;
176 };
177 
183 template< typename TTreeType >
184 class ITK_TEMPLATE_EXPORT TreePruneEvent:public TreeRemoveEvent< TTreeType >
185 {
186 public:
189 
190  TreePruneEvent()= default;
191 
193  TreeRemoveEvent< TTreeType >(position) {}
194 
195  const char * GetEventName() const override { return "TreePruneEvent"; }
196 
197  bool CheckEvent(const::itk::EventObject *e) const override { return (dynamic_cast< const Self * >( e ) != nullptr); }
198 
199  ::itk::EventObject * MakeObject() const override { return new Self(*this->m_ChangePosition); }
200 
201  TreePruneEvent(const Self & s):TreeRemoveEvent< TTreeType >(s) {}
202 
203 private:
204  void operator=(const Self &) = delete;
205 };
206 } // namespace itk
207 
208 #endif
TreeChangeEvent(const Self &s)
bool CheckEvent(const ::itk::EventObject *e) const override
::itk::EventObject * MakeObject() const override
const TreeIteratorBase< TTreeType > * m_ChangePosition
const char * GetEventName() const override
const char * GetEventName() const override
const TreeIteratorBase< TTreeType > & GetChangePosition() const
bool CheckEvent(const ::itk::EventObject *e) const override
TreeNodeChangeEvent(const TreeIteratorBase< TTreeType > &position)
::itk::EventObject * MakeObject() const override
TreePruneEvent(const TreeIteratorBase< TTreeType > &position)
Signals that a node and all its childs will shortly be removed. The position of the top-level removed...
const char * GetEventName() const override
const char * GetEventName() const override
const char * GetEventName() const override
TreeRemoveEvent(const TreeIteratorBase< TTreeType > &position)
TreeAddEvent(const TreeIteratorBase< TTreeType > &position)
::itk::EventObject * MakeObject() const override
bool CheckEvent(const ::itk::EventObject *e) const override
Checks if the position of a node in the tree has been changed.
Abstraction of the Events used to communicating among filters and with GUIs.
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.
void operator=(const Self &)=delete
bool CheckEvent(const ::itk::EventObject *e) const override
TreePruneEvent(const Self &s)
TreeNodeChangeEvent(const Self &s)
bool CheckEvent(const ::itk::EventObject *e) const override
static constexpr double e
The base of the natural logarithm or Euler&#39;s number
Definition: itkMath.h:53
TreeChangeEvent(const TreeIteratorBase< TTreeType > &position)
TreeAddEvent(const Self &s)
TreeRemoveEvent(const Self &s)
TreeNodeChangeEvent Self
::itk::EventObject * MakeObject() const override
Checks if a node has been removed from the tree.
Checks if a node has been added to the tree.
::itk::EventObject * MakeObject() const override