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