ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkEventObject.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 __itkEventObject_h
00019 #define __itkEventObject_h
00020 
00021 #include "itkIndent.h"
00022 
00023 namespace itk
00024 {
00057 class ITKCommon_EXPORT EventObject
00058 {
00059 public:
00062   EventObject() {}
00063 
00064   EventObject(const EventObject &){}
00065 
00067   virtual ~EventObject() {}
00068 
00071   virtual EventObject * MakeObject() const = 0;
00072 
00076   virtual void Print(std::ostream & os) const;
00077 
00079   virtual const char * GetEventName(void) const = 0;
00080 
00082   virtual bool CheckEvent(const EventObject *) const = 0;
00083 
00084 protected:
00089   virtual void PrintSelf(std::ostream & os, Indent indent) const;
00090 
00091   virtual void PrintHeader(std::ostream & os, Indent indent) const;
00092 
00093   virtual void PrintTrailer(std::ostream & os, Indent indent) const;
00094 
00095 private:
00096   typedef  EventObject *EventFactoryFunction ( );
00097   void operator=(const EventObject &);
00098 };
00099 
00101 inline std::ostream & operator<<(std::ostream & os, EventObject & e)
00102 {
00103   ( &e )->Print(os);
00104   return os;
00105 }
00107 
00111 #define itkEventMacro(classname, super)                              \
00112 
00113                                             \
00117 #define itkEventMacro(classname, super)                              \
00118   class ITK_ABI_EXPORT classname:public super                        \
00119   {                                                                  \
00120 public:                                                              \
00121     typedef classname Self;                                          \
00122     typedef super     Superclass;                                    \
00123     classname() {}                                                   \
00124     virtual ~classname() {}                                          \
00125     virtual const char *GetEventName() const { return #classname; } \
00126     virtual bool CheckEvent(const::itk::EventObject * e) const       \
00127                { return ( dynamic_cast< const Self * >( e ) != NULL ); }         \
00128     virtual::itk::EventObject *MakeObject() const                    \
00129                { return new Self; }                                  \
00130     classname(const Self &s):super(s){};                             \
00131 private:                                                             \
00132     void operator=(const Self &);                                    \
00133   };
00134 
00135 
00139 itkEventMacro(NoEvent, EventObject)
00140 itkEventMacro(AnyEvent, EventObject)
00141 itkEventMacro(DeleteEvent, AnyEvent)
00142 itkEventMacro(StartEvent, AnyEvent)
00143 itkEventMacro(EndEvent, AnyEvent)
00144 itkEventMacro(ProgressEvent, AnyEvent)
00145 itkEventMacro(ExitEvent, AnyEvent)
00146 itkEventMacro(AbortEvent, AnyEvent)
00147 itkEventMacro(ModifiedEvent, AnyEvent)
00148 itkEventMacro(InitializeEvent, AnyEvent)
00149 itkEventMacro(IterationEvent, AnyEvent)
00150 itkEventMacro(PickEvent, AnyEvent)
00151 itkEventMacro(StartPickEvent, PickEvent)
00152 itkEventMacro(EndPickEvent, PickEvent)
00153 itkEventMacro(AbortCheckEvent, PickEvent)
00154 itkEventMacro(FunctionEvaluationIterationEvent, IterationEvent)
00155 itkEventMacro(GradientEvaluationIterationEvent, IterationEvent)
00156 itkEventMacro(FunctionAndGradientEvaluationIterationEvent, IterationEvent)
00157 
00158 itkEventMacro(UserEvent, AnyEvent)
00159 } // end namespace itk
00160 
00161 #endif
00162