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