X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FObject.h;h=6e273f174264f5fe3ea7f822c5254a76102557e8;hb=75dc4945344b4a5a7be10a3ca33fa2e6fff87df8;hp=d4436f68db36a6619947081124fd61275e120a21;hpb=c29448936abc15d110205b2da435035131398a87;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/Object.h b/lib/cpPlugins/Interface/Object.h index d4436f6..6e273f1 100644 --- a/lib/cpPlugins/Interface/Object.h +++ b/lib/cpPlugins/Interface/Object.h @@ -5,6 +5,52 @@ #include #include +#include +#include + +// ------------------------------------------------------------------------- +#define CPPLUGINS_PROVIDER_HEADER_BEGIN( TYPE ) \ + class cpPlugins_Interface_EXPORT TYPE##Provider \ + : public pluma::Provider \ + { \ +private: \ + friend class pluma::Pluma; \ + static const unsigned int PLUMA_INTERFACE_VERSION; \ + static const unsigned int PLUMA_INTERFACE_LOWEST_VERSION; \ + static const std::string PLUMA_PROVIDER_TYPE; \ + std::string plumaGetType( ) const \ + { return( PLUMA_PROVIDER_TYPE ); } \ +public: \ + unsigned int getVersion( ) const \ + { return( PLUMA_INTERFACE_VERSION ); } + +// ------------------------------------------------------------------------- +#define CPPLUGINS_PROVIDER_HEADER_END }; + +// ------------------------------------------------------------------------- +#define CPPLUGINS_PROVIDER_HEADER( TYPE ) \ + CPPLUGINS_PROVIDER_HEADER_BEGIN( TYPE ) \ + virtual TYPE::Pointer create( ) const = 0; \ + CPPLUGINS_PROVIDER_HEADER_END + +// ------------------------------------------------------------------------- +#define CPPLUGINS_PROVIDER_SOURCE( TYPE, Version, LowestVersion ) \ + PLUMA_PROVIDER_SOURCE( TYPE, Version, LowestVersion ) + +// ------------------------------------------------------------------------- +#define CPPLUGINS_INHERIT_PROVIDER( TYPE ) \ + class TYPE##Provider \ + : public cpPlugins::Interface::ObjectProvider \ + { \ + public: \ + cpPlugins::Interface::Object::Pointer create( ) const \ + { \ + TYPE::Pointer a = TYPE::New( ); \ + cpPlugins::Interface::Object::Pointer b = a.GetPointer( ); \ + return( b ); \ + } \ + }; + namespace cpPlugins { namespace Interface @@ -12,16 +58,40 @@ namespace cpPlugins /** */ class cpPlugins_Interface_EXPORT Object + : public itk::Object { public: + typedef Object Self; + typedef itk::Object Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( Object, itkObject ); + + public: + itkGetConstMacro( ClassName, std::string ); + itkGetConstMacro( ClassCategory, std::string ); + + protected: Object( ); virtual ~Object( ); - virtual std::string GetClassName( ) const; + private: + // Purposely not implemented + Object( const Self& ); + Self& operator=( const Self& ); + + protected: + std::string m_ClassName; + std::string m_ClassCategory; }; - // TODO: doc - PLUMA_PROVIDER_HEADER( Object ); + /** + * Plugin provider + */ + CPPLUGINS_PROVIDER_HEADER( Object ); } // ecapseman