ITK  5.1.0
Insight 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:
38  using Superclass = ModifiedEvent;
39 
42  : m_ChangePosition(nullptr)
43  {}
44 
46  TreeChangeEvent(const TreeIteratorBase<TTreeType> & position) { m_ChangePosition = &position; }
47 
49  ~TreeChangeEvent() override = default;
50 
52  const char *
53  GetEventName() const override
54  {
55  return "TreeChangeEvent";
56  }
57 
59  bool
60  CheckEvent(const ::itk::EventObject * e) const override
61  {
62  return (dynamic_cast<const Self *>(e) != nullptr);
63  }
64 
67  MakeObject() const override
68  {
69  return new Self(*m_ChangePosition);
70  }
71 
75  {
76  return *m_ChangePosition;
77  }
78 
79  // cppcheck-suppress uninitVar
80  TreeChangeEvent(const Self & s)
81  : itk::ModifiedEvent(s)
82  {}
83 
84 protected:
86 
87 private:
88  void
89  operator=(const Self &) = delete;
90 };
91 
97 template <typename TTreeType>
98 class TreeNodeChangeEvent : public TreeChangeEvent<TTreeType>
99 {
100 public:
103 
104  TreeNodeChangeEvent() = default;
105 
107  : TreeChangeEvent<TTreeType>(position)
108  {}
109 
110  const char *
111  GetEventName() const override
112  {
113  return "TreeNodeChangeEvent";
114  }
115 
116  bool
117  CheckEvent(const ::itk::EventObject * e) const override
118  {
119  auto eSelf = dynamic_cast<const Self *>(e);
120  return eSelf != nullptr;
121  }
122 
124  MakeObject() const override
125  {
126  return new Self(*this->m_ChangePosition);
127  }
128 
130  : TreeChangeEvent<TTreeType>(s)
131  {}
132 
133 private:
134  void
135  operator=(const Self &) = delete;
136 };
137 
142 template <typename TTreeType>
143 class ITK_TEMPLATE_EXPORT TreeAddEvent : public TreeChangeEvent<TTreeType>
144 {
145 public:
149 
151  TreeAddEvent() = default;
152 
155  : TreeChangeEvent<TTreeType>(position)
156  {}
157 
159  const char *
160  GetEventName() const override
161  {
162  return "TreeAddEvent";
163  }
164 
166  bool
167  CheckEvent(const ::itk::EventObject * e) const override
168  {
169  return (dynamic_cast<const Self *>(e) != nullptr);
170  }
171 
174  MakeObject() const override
175  {
176  return new Self(*this->m_ChangePosition);
177  }
178 
179  TreeAddEvent(const Self & s)
180  : TreeChangeEvent<TTreeType>(s)
181  {}
182 
183 private:
184  void
185  operator=(const Self &) = delete;
186 };
187 
192 template <typename TTreeType>
193 class ITK_TEMPLATE_EXPORT TreeRemoveEvent : public TreeChangeEvent<TTreeType>
194 {
195 public:
199 
201  TreeRemoveEvent() = default;
202 
205  : TreeChangeEvent<TTreeType>(position)
206  {}
207 
209  const char *
210  GetEventName() const override
211  {
212  return "TreeRemoveEvent";
213  }
214 
216  bool
217  CheckEvent(const ::itk::EventObject * e) const override
218  {
219  return (dynamic_cast<const Self *>(e) != nullptr);
220  }
221 
224  MakeObject() const override
225  {
226  return new Self(*this->m_ChangePosition);
227  }
228 
230  : TreeChangeEvent<TTreeType>(s)
231  {}
232 
233 private:
234  void
235  operator=(const Self &) = delete;
236 };
237 
243 template <typename TTreeType>
244 class ITK_TEMPLATE_EXPORT TreePruneEvent : public TreeRemoveEvent<TTreeType>
245 {
246 public:
249 
250  TreePruneEvent() = default;
251 
253  : TreeRemoveEvent<TTreeType>(position)
254  {}
255 
256  const char *
257  GetEventName() const override
258  {
259  return "TreePruneEvent";
260  }
261 
262  bool
263  CheckEvent(const ::itk::EventObject * e) const override
264  {
265  return (dynamic_cast<const Self *>(e) != nullptr);
266  }
267 
269  MakeObject() const override
270  {
271  return new Self(*this->m_ChangePosition);
272  }
273 
274  TreePruneEvent(const Self & s)
275  : TreeRemoveEvent<TTreeType>(s)
276  {}
277 
278 private:
279  void
280  operator=(const Self &) = delete;
281 };
282 } // namespace itk
283 
284 #endif
itkTreeIteratorBase.h
itk::TreeChangeEvent::TreeChangeEvent
TreeChangeEvent(const TreeIteratorBase< TTreeType > &position)
Definition: itkTreeChangeEvent.h:46
itk::TreeChangeEvent::GetChangePosition
const TreeIteratorBase< TTreeType > & GetChangePosition() const
Definition: itkTreeChangeEvent.h:74
itk::TreeNodeChangeEvent::TreeNodeChangeEvent
TreeNodeChangeEvent(const TreeIteratorBase< TTreeType > &position)
Definition: itkTreeChangeEvent.h:106
itk::TreeRemoveEvent::MakeObject
::itk::EventObject * MakeObject() const override
Definition: itkTreeChangeEvent.h:224
itk::TreePruneEvent::GetEventName
const char * GetEventName() const override
Definition: itkTreeChangeEvent.h:257
itk::TreeNodeChangeEvent::TreeNodeChangeEvent
TreeNodeChangeEvent(const Self &s)
Definition: itkTreeChangeEvent.h:129
itk::TreeNodeChangeEvent::MakeObject
::itk::EventObject * MakeObject() const override
Definition: itkTreeChangeEvent.h:124
itk::TreeChangeEvent::CheckEvent
bool CheckEvent(const ::itk::EventObject *e) const override
Definition: itkTreeChangeEvent.h:60
itk::TreeChangeEvent::m_ChangePosition
const TreeIteratorBase< TTreeType > * m_ChangePosition
Definition: itkTreeChangeEvent.h:85
itk::TreeIteratorBase
This class provides the base implementation for tree iterators.
Definition: itkTreeIteratorBase.h:58
itk::TreeAddEvent::MakeObject
::itk::EventObject * MakeObject() const override
Definition: itkTreeChangeEvent.h:174
itk::TreeChangeEvent::MakeObject
::itk::EventObject * MakeObject() const override
Definition: itkTreeChangeEvent.h:67
itk::TreePruneEvent
Signals that a node and all its childs will shortly be removed. The position of the top-level removed...
Definition: itkTreeChangeEvent.h:244
itk::TreeNodeChangeEvent::Self
TreeNodeChangeEvent Self
Definition: itkTreeChangeEvent.h:101
itk::TreeNodeChangeEvent::TreeNodeChangeEvent
TreeNodeChangeEvent()=default
itk::TreeChangeEvent::TreeChangeEvent
TreeChangeEvent(const Self &s)
Definition: itkTreeChangeEvent.h:80
itkMacro.h
itk::TreePruneEvent::CheckEvent
bool CheckEvent(const ::itk::EventObject *e) const override
Definition: itkTreeChangeEvent.h:263
itk::TreeChangeEvent::GetEventName
const char * GetEventName() const override
Definition: itkTreeChangeEvent.h:53
itk::TreeRemoveEvent::TreeRemoveEvent
TreeRemoveEvent(const Self &s)
Definition: itkTreeChangeEvent.h:229
itk::TreeChangeEvent::TreeChangeEvent
TreeChangeEvent()
Definition: itkTreeChangeEvent.h:41
itk::TreeRemoveEvent::GetEventName
const char * GetEventName() const override
Definition: itkTreeChangeEvent.h:210
itk::TreeNodeChangeEvent::GetEventName
const char * GetEventName() const override
Definition: itkTreeChangeEvent.h:111
itk::TreeAddEvent
Checks if a node has been added to the tree.
Definition: itkTreeChangeEvent.h:143
itk::TreeAddEvent::TreeAddEvent
TreeAddEvent(const Self &s)
Definition: itkTreeChangeEvent.h:179
itk::TreeNodeChangeEvent::CheckEvent
bool CheckEvent(const ::itk::EventObject *e) const override
Definition: itkTreeChangeEvent.h:117
itk::TreeAddEvent::CheckEvent
bool CheckEvent(const ::itk::EventObject *e) const override
Definition: itkTreeChangeEvent.h:167
itk::TreePruneEvent::MakeObject
::itk::EventObject * MakeObject() const override
Definition: itkTreeChangeEvent.h:269
itk::TreeRemoveEvent
Checks if a node has been removed from the tree.
Definition: itkTreeChangeEvent.h:193
itk::TreeChangeEvent::Superclass
ModifiedEvent Superclass
Definition: itkTreeChangeEvent.h:38
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::TreeChangeEvent
Checks if the position of a node in the tree has been changed.
Definition: itkTreeChangeEvent.h:33
itk::TreeRemoveEvent::TreeRemoveEvent
TreeRemoveEvent(const TreeIteratorBase< TTreeType > &position)
Definition: itkTreeChangeEvent.h:204
itk::Math::e
static constexpr double e
Definition: itkMath.h:54
itk::EventObject
Abstraction of the Events used to communicating among filters and with GUIs.
Definition: itkEventObject.h:57
itkEventObject.h
itk::TreeAddEvent::TreeAddEvent
TreeAddEvent(const TreeIteratorBase< TTreeType > &position)
Definition: itkTreeChangeEvent.h:154
itk::TreeNodeChangeEvent
Signals that a node has been set to another value. The position of the changed node is provided.
Definition: itkTreeChangeEvent.h:98
itk::TreeNodeChangeEvent::operator=
void operator=(const Self &)=delete
itk::TreePruneEvent::TreePruneEvent
TreePruneEvent(const TreeIteratorBase< TTreeType > &position)
Definition: itkTreeChangeEvent.h:252
itk::TreeAddEvent::GetEventName
const char * GetEventName() const override
Definition: itkTreeChangeEvent.h:160
itk::TreePruneEvent::TreePruneEvent
TreePruneEvent(const Self &s)
Definition: itkTreeChangeEvent.h:274
itk::TreeRemoveEvent::CheckEvent
bool CheckEvent(const ::itk::EventObject *e) const override
Definition: itkTreeChangeEvent.h:217