ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkEventObject.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 __itkEventObject_h
19 #define __itkEventObject_h
20 
21 #include "itkIndent.h"
22 
23 namespace itk
24 {
57 class ITKCommon_EXPORT EventObject
58 {
59 public:
63 
65 
67  virtual ~EventObject() {}
68 
71  virtual EventObject * MakeObject() const = 0;
72 
76  virtual void Print(std::ostream & os) const;
77 
79  virtual const char * GetEventName(void) const = 0;
80 
82  virtual bool CheckEvent(const EventObject *) const = 0;
83 
84 protected:
89  virtual void PrintSelf(std::ostream & os, Indent indent) const;
90 
91  virtual void PrintHeader(std::ostream & os, Indent indent) const;
92 
93  virtual void PrintTrailer(std::ostream & os, Indent indent) const;
94 
95 private:
97  void operator=(const EventObject &);
98 };
99 
101 inline std::ostream & operator<<(std::ostream & os, EventObject & e)
102 {
103  ( &e )->Print(os);
104  return os;
105 }
107 
111 #define itkEventMacro(classname, super) \
112 
113  \
117 #define itkEventMacro(classname, super) \
118  class ITK_ABI_EXPORT classname:public super \
119  { \
120 public: \
121  typedef classname Self; \
122  typedef super Superclass; \
123  classname() {} \
124  virtual ~classname() {} \
125  virtual const char *GetEventName() const { return #classname; } \
126  virtual bool CheckEvent(const::itk::EventObject * e) const \
127  { return ( dynamic_cast< const Self * >( e ) != NULL ); } \
128  virtual::itk::EventObject *MakeObject() const \
129  { return new Self; } \
130  classname(const Self &s):super(s){}; \
131 private: \
132  void operator=(const Self &); \
133  };
134 
135 
157 
159 } // end namespace itk
160 
161 #endif
162