]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Object.h
5b0ebd6de87f9e79dd152d6465e3d1043ab06187
[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 // -------------------------------------------------------------------------
55 #define cpPlugins_Id_Macro( name, category )                            \
56   public:                                                               \
57   static std::string GetClassName( ) { return( #name ); }               \
58   static std::string GetClassCategory( ) { return( category ); }
59
60 namespace cpPlugins
61 {
62   namespace Interface
63   {
64     /**
65      */
66     class cpPlugins_Interface_EXPORT Object
67       : public itk::Object
68     {
69     public:
70       typedef Object                          Self;
71       typedef itk::Object                     Superclass;
72       typedef itk::SmartPointer< Self >       Pointer;
73       typedef itk::SmartPointer< const Self > ConstPointer;
74
75     public:
76       itkNewMacro( Self );
77       itkTypeMacro( Object, itkObject );
78       cpPlugins_Id_Macro( cpPlugins::Interface::Object, "BaseObject" );
79
80       itkGetStringMacro( Name );
81       itkSetStringMacro( Name );
82
83     protected:
84       Object( );
85       virtual ~Object( );
86
87     private:
88       // Purposely not implemented
89       Object( const Self& );
90       Self& operator=( const Self& );
91
92     protected:
93       std::string m_Name;
94     };
95
96     /**
97      * Plugin provider
98      */
99     CPPLUGINS_PROVIDER_HEADER( Object );
100
101   } // ecapseman
102
103 } // ecapseman
104
105 #endif // __CPPLUGINS__INTERFACE__OBJECT__H__
106
107 // eof - $RCSfile$