]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Macros.h
...
[cpPlugins.git] / lib / cpPlugins / Interface / Macros.h
1 #ifndef __CPPLUGINS__INTERFACE__MACROS__H__
2 #define __CPPLUGINS__INTERFACE__MACROS__H__
3
4 #include <Pluma/Pluma.hpp>
5 #include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
6 #include <cpPlugins/Interface/Config.h>
7
8 // -------------------------------------------------------------------------
9 #define cpPlugins_Id_Macro( N, C )                                      \
10   public:                                                               \
11   virtual const char* GetClassName( ) const     { return( #N ); }       \
12   virtual const char* GetClassCategory( ) const { return( #C ); }
13
14 // -------------------------------------------------------------------------
15 #define CPPLUGINS_PROVIDER_HEADER_BEGIN( TYPE )                 \
16   class cpPlugins_Interface_EXPORT TYPE##Provider               \
17     : public pluma::Provider                                    \
18   {                                                             \
19 private:                                                        \
20     friend class pluma::Pluma;                                  \
21     static const unsigned int PLUMA_INTERFACE_VERSION;          \
22     static const unsigned int PLUMA_INTERFACE_LOWEST_VERSION;   \
23     static const std::string PLUMA_PROVIDER_TYPE;               \
24     std::string plumaGetType( ) const                           \
25     { return( PLUMA_PROVIDER_TYPE ); }                          \
26 public:                                                         \
27     unsigned int getVersion( ) const                            \
28     { return( PLUMA_INTERFACE_VERSION ); }
29
30 // -------------------------------------------------------------------------
31 #define CPPLUGINS_PROVIDER_HEADER_END };
32
33 // -------------------------------------------------------------------------
34 #define CPPLUGINS_PROVIDER_HEADER( TYPE )               \
35   CPPLUGINS_PROVIDER_HEADER_BEGIN( TYPE )               \
36   virtual TYPE::Pointer create( ) const = 0;            \
37   CPPLUGINS_PROVIDER_HEADER_END
38
39 // -------------------------------------------------------------------------
40 #define CPPLUGINS_PROVIDER_SOURCE( TYPE, Version, LowestVersion )       \
41   PLUMA_PROVIDER_SOURCE( TYPE, Version, LowestVersion )
42
43 // -------------------------------------------------------------------------
44 #define CPPLUGINS_INHERIT_PROVIDER( TYPE )                              \
45   class TYPE##Provider                                                  \
46     : public cpPlugins::Interface::ProcessObjectProvider                \
47   {                                                                     \
48   public:                                                               \
49     cpPlugins::Interface::ProcessObject::Pointer create( ) const        \
50     {                                                                   \
51       TYPE::Pointer a = TYPE::New( );                                   \
52       cpPlugins::Interface::ProcessObject::Pointer b = a.GetPointer( ); \
53       return( b );                                                      \
54     }                                                                   \
55   };
56
57 /**
58  * Based upon: http://www.itk.org/Wiki/Proposals:Explicit_Instantiation
59  */
60 // -------------------------------------------------------------------------
61 #define cpPlugins_TEMPLATE_1( X1 )              \
62   X1
63 #define cpPlugins_TEMPLATE_2( X1, X2 )          \
64   X1,X2
65 #define cpPlugins_TEMPLATE_3( X1, X2, X3 )      \
66   X1,X2,X3
67 #define cpPlugins_TEMPLATE_4( X1, X2, X3, X4 )  \
68   X1,X2,X3,X4
69 #define cpPlugins_TEMPLATE_5( X1, X2, X3, X4, X5 )      \
70   X1,X2,X3,X4,X5
71 #define cpPlugins_TEMPLATE_6( X1, X2, X3, X4, X5, X6 )  \
72   X1,X2,X3,X4,X5,X6
73 #define cpPlugins_TEMPLATE_7( X1, X2, X3, X4, X5, X6, X7 )      \
74   X1,X2,X3,X4,X5,X6,X7
75 #define cpPlugins_TEMPLATE_8( X1, X2, X3, X4, X5, X6, X7, X8 )  \
76   X1,X2,X3,X4,X5,X6,X7,X8
77 #define cpPlugins_TEMPLATE_9( X1, X2, X3, X4, X5, X6, X7, X8, X9 )      \
78   X1,X2,X3,X4,X5,X6,X7,X8,X9
79   
80 #define cpPlugins_TEMPLATE_EXPORT( X )          \
81   template cpPlugins_TEMPLATE_##X;
82 #define cpPlugins_TEMPLATE_IMPORT( X )          \
83   extern template cpPlugins_TEMPLATE_##X;
84
85 #endif // __CPPLUGINS__INTERFACE__MACROS__H__
86
87 // eof - $RCSfile$