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