]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Pipeline/Object.h
yet another refactoring
[cpPlugins.git] / lib / cpPlugins / Pipeline / Object.h
diff --git a/lib/cpPlugins/Pipeline/Object.h b/lib/cpPlugins/Pipeline/Object.h
new file mode 100644 (file)
index 0000000..c920abb
--- /dev/null
@@ -0,0 +1,105 @@
+#ifndef __cpPlugins__Pipeline__Object__h__
+#define __cpPlugins__Pipeline__Object__h__
+
+#include <cpPlugins/Config.h>
+
+#include <itkLightObject.h>
+#include <itkObject.h>
+#include <itkObjectFactory.h>
+#include <vtkSmartPointer.h>
+#include <vtkObjectBase.h>
+
+namespace cpPlugins
+{
+  namespace Pipeline
+  {
+    /**
+     */
+    class cpPlugins_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:
+      itkTypeMacro( Object, itk::Object );
+
+    public:
+      virtual const char* GetClassName( ) const = 0;
+      virtual const char* GetClassCategory( ) const = 0;
+
+      const float& GetViewX( ) const;
+      const float& GetViewY( ) const;
+      void SetViewCoords( float x, float y );
+
+      virtual void Modified( ) const cpPlugins_OVERRIDE;
+
+      virtual void SetITK( itk::LightObject* o );
+      virtual void SetVTK( vtkObjectBase* o );
+
+      template< class _TType = itk::LightObject >
+      inline _TType* GetITK( )
+        {
+          if( this->m_ITK.GetPointer( ) == NULL )
+            this->_UpdateITK( );
+          return( dynamic_cast< _TType* >( this->m_ITK.GetPointer( ) ) );
+        }
+
+      template< class _TType = itk::LightObject >
+      inline const _TType* GetITK( ) const
+        {
+          if( this->m_ITK.GetPointer( ) == NULL )
+            this->_UpdateITK( );
+          return(
+            dynamic_cast< const _TType* >( this->m_ITK.GetPointer( ) )
+            );
+        }
+
+      template< class _TType = vtkObjectBase >
+      inline _TType* GetVTK( )
+        {
+          if( this->m_VTK.GetPointer( ) == NULL )
+            this->_UpdateVTK( );
+          return( dynamic_cast< _TType* >( this->m_VTK.GetPointer( ) ) );
+        }
+
+      template< class _TType = vtkObjectBase >
+      inline const _TType* GetVTK( ) const
+        {
+          if( this->m_VTK.GetPointer( ) == NULL )
+            this->_UpdateVTK( );
+          return(
+            dynamic_cast< const _TType* >( this->m_VTK.GetPointer( ) )
+            );
+        }
+
+    protected:
+      Object( );
+      virtual ~Object( );
+
+      virtual void _UpdateITK( ) const;
+      virtual void _UpdateVTK( ) const;
+
+    private:
+      // Purposely not implemented
+      Object( const Self& );
+      Self& operator=( const Self& );
+
+    protected:
+      itk::LightObject::Pointer        m_ITK;
+      vtkSmartPointer< vtkObjectBase > m_VTK;
+
+      float m_ViewX;
+      float m_ViewY;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __cpPlugins__Pipeline__Object__h__
+
+// eof - $RCSfile$