]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Object.h
...
[cpPlugins.git] / lib / cpPlugins / Interface / Object.h
1 #ifndef __CPPLUGINS__INTERFACE__OBJECT__H__
2 #define __CPPLUGINS__INTERFACE__OBJECT__H__
3
4 #include <string>
5 #include <Pluma/Pluma.hpp>
6 #include <cpPlugins/cpPlugins_Export.h>
7
8 #define ITK_MANUAL_INSTANTIATION
9 #include <itkObject.h>
10 #include <itkObjectFactory.h>
11
12 // -------------------------------------------------------------------------
13 #define CPPLUGINS_PROVIDER_HEADER_BEGIN( TYPE )                 \
14   class cpPlugins_EXPORT TYPE##Provider               \
15     : public pluma::Provider                                    \
16   {                                                             \
17   private:                                                      \
18     friend class pluma::Pluma;                                  \
19     static const unsigned int PLUMA_INTERFACE_VERSION;          \
20     static const unsigned int PLUMA_INTERFACE_LOWEST_VERSION;   \
21     static const std::string PLUMA_PROVIDER_TYPE;               \
22     std::string plumaGetType( ) const                           \
23     { return( PLUMA_PROVIDER_TYPE ); }                          \
24   public:                                                       \
25     unsigned int getVersion( ) const                            \
26     { return( PLUMA_INTERFACE_VERSION ); }
27
28 // -------------------------------------------------------------------------
29 #define CPPLUGINS_PROVIDER_HEADER_END };
30
31 // -------------------------------------------------------------------------
32 #define CPPLUGINS_PROVIDER_HEADER( TYPE )               \
33   CPPLUGINS_PROVIDER_HEADER_BEGIN( TYPE )               \
34     virtual TYPE::Pointer create( ) const = 0;          \
35   CPPLUGINS_PROVIDER_HEADER_END
36
37 // -------------------------------------------------------------------------
38 #define CPPLUGINS_PROVIDER_SOURCE( TYPE, Version, LowestVersion )       \
39   PLUMA_PROVIDER_SOURCE( TYPE, Version, LowestVersion )
40
41 // -------------------------------------------------------------------------
42 #define CPPLUGINS_INHERIT_PROVIDER( TYPE )                              \
43   class TYPE##Provider                                                  \
44     : public cpPlugins::Interface::ObjectProvider                       \
45   {                                                                     \
46   public:                                                               \
47     cpPlugins::Interface::Object::Pointer create( ) const               \
48     {                                                                   \
49       TYPE::Pointer a = TYPE::New( );                                   \
50       cpPlugins::Interface::Object::Pointer b = a.GetPointer( );        \
51       return( b );                                                      \
52     }                                                                   \
53   };
54
55 namespace cpPlugins
56 {
57   namespace Interface
58   {
59     /**
60      */
61     class cpPlugins_EXPORT Object
62       : public itk::Object
63     {
64     public:
65       typedef Object                          Self;
66       typedef itk::Object                     Superclass;
67       typedef itk::SmartPointer< Self >       Pointer;
68       typedef itk::SmartPointer< const Self > ConstPointer;
69
70     public:
71       itkNewMacro( Self );
72       itkTypeMacro( Object, itkObject );
73
74     public:
75       itkGetConstMacro( ClassName, std::string );
76       itkGetConstMacro( ClassCategory, std::string );
77
78     protected:
79       Object( );
80       virtual ~Object( );
81
82     private:
83       // Purposely not implemented
84       Object( const Self& );
85       Self& operator=( const Self& );
86
87     protected:
88       std::string m_ClassName;
89       std::string m_ClassCategory;
90     };
91
92     /**
93      * Plugin provider
94      */
95     CPPLUGINS_PROVIDER_HEADER( Object );
96
97   } // ecapseman
98
99 } // ecapseman
100
101 #endif // __CPPLUGINS__INTERFACE__OBJECT__H__
102
103 // eof - $RCSfile$