]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/Events.h
17c55649cece70841cfaa2558b4be6528e604956
[FrontAlgorithms.git] / lib / fpa / Base / Events.h
1 #ifndef __fpa__Base__Events__h__
2 #define __fpa__Base__Events__h__
3
4 // -------------------------------------------------------------------------
5 #define fpa_Base_NewEvent( name )                               \
6   class name                                                    \
7     : public BaseEvent                                          \
8   {                                                             \
9   public:                                                       \
10     name( ) : BaseEvent( ) { }                                  \
11     virtual ~name( ) { }                                        \
12     const char* GetEventName( ) const                           \
13     { return( "fpa::Base::##name" ); }                          \
14     bool CheckEvent( const itk::EventObject* e ) const          \
15     { return( dynamic_cast< const name* >( e ) != NULL ); }     \
16     itk::EventObject* MakeObject( ) const                       \
17     { return( new name( ) ); }                                  \
18   };
19
20 // -------------------------------------------------------------------------
21 #define fpa_Base_NewEventWithVertex( name, type )               \
22   class name                                                    \
23     : public BaseEventWithVertex< type >                        \
24   {                                                             \
25   public:                                                       \
26     name( ) : BaseEventWithVertex< type >( ) { }                \
27     name( const type& v, long fid )                             \
28         : BaseEventWithVertex< type >( v, fid ) { }             \
29     virtual ~name( ) { }                                        \
30     const char* GetEventName( ) const                           \
31     { return( "fpa::Base::##name" ); }                          \
32     bool CheckEvent( const itk::EventObject* e ) const          \
33     { return( dynamic_cast< const name* >( e ) != NULL ); }     \
34     itk::EventObject* MakeObject( ) const                       \
35     { return( new name( ) ); }                                  \
36   };
37
38 namespace fpa
39 {
40   namespace Base
41   {
42     /**
43      */
44     class BaseEvent
45       : public itk::AnyEvent
46     {
47     public:
48       BaseEvent( )
49         : itk::AnyEvent( )
50         { }
51       virtual ~BaseEvent( )
52         { }
53       const char* GetEventName( ) const
54         { return( "fpa::Base::BaseEvent" ); }
55       bool CheckEvent( const itk::EventObject* e ) const
56         { return( dynamic_cast< const BaseEvent* >( e ) != NULL ); }
57       itk::EventObject* MakeObject( ) const
58         { return( new BaseEvent( ) ); }
59     };
60
61     /**
62      */
63     template< class _TVertex >
64     class BaseEventWithVertex
65       : public BaseEvent
66     {
67     public:
68       BaseEventWithVertex( )
69         : BaseEvent( )
70         { }
71       BaseEventWithVertex( const _TVertex& v, long fid )
72         : BaseEvent( ),
73           Vertex( v ),
74           FrontId( fid )
75         { }
76       virtual ~BaseEventWithVertex( )
77         { }
78       const char* GetEventName( ) const
79         { return( "fpa::Base::BaseEventWithVertex" ); }
80       bool CheckEvent( const itk::EventObject* e ) const
81         {
82           return(
83             dynamic_cast< const BaseEventWithVertex< _TVertex >* >( e ) != NULL
84             );
85         }
86       itk::EventObject* MakeObject( ) const
87         { return( new BaseEventWithVertex< _TVertex >( ) ); }
88
89     public:
90       _TVertex Vertex;
91       long     FrontId;
92     };
93
94   } // ecapseman
95
96 } // ecapseman
97
98 #endif // __fpa__Base__Events__h__
99
100 // eof - $RCSfile$