]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Object.h
Garbage collector added
[cpPlugins.git] / lib / cpPlugins / Interface / Object.h
index d4436f68db36a6619947081124fd61275e120a21..33cfdd7079cd61ab1e361369a3af305c271d3872 100644 (file)
@@ -3,8 +3,30 @@
 
 #include <string>
 #include <Pluma/Pluma.hpp>
+#include <itkObject.h>
+#include <itkObjectFactory.h>
 #include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
 
+// -------------------------------------------------------------------------
+#define PLUMA_PROVIDER_HEADER_CPPLUGINS( TYPE )         \
+  PLUMA_PROVIDER_HEADER_BEGIN( TYPE )                   \
+  virtual TYPE::Pointer create( ) const = 0;            \
+  PLUMA_PROVIDER_HEADER_END
+
+// -------------------------------------------------------------------------
+#define PLUMA_INHERIT_PROVIDER_CPPLUGINS( TYPE, SUPER ) \
+  class TYPE##Provider                                  \
+    : public SUPER##Provider                            \
+  {                                                     \
+  public:                                               \
+    SUPER::Pointer create( ) const                      \
+    {                                                   \
+      TYPE::Pointer a = TYPE::New( );                   \
+      SUPER::Pointer b = a.GetPointer( );               \
+      return( b );                                      \
+    }                                                   \
+  };
+
 namespace cpPlugins
 {
   namespace Interface
@@ -12,16 +34,34 @@ 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:
+      virtual std::string GetClassName( ) const;
+      virtual std::string GetClassType( ) const;
+
+    protected:
       Object( );
       virtual ~Object( );
 
-      virtual std::string GetClassName( ) const;
+    private:
+      // Purposely not implemented
+      Object( const Self& );
+      Self& operator=( const Self& );
     };
 
     // TODO: doc
-    PLUMA_PROVIDER_HEADER( Object );
+    PLUMA_PROVIDER_HEADER_CPPLUGINS( Object );
 
   } // ecapseman