/*============================================================================= NOTE: THIS FILE WAS AUTOMATICALLY GENERATED BY THE ManagedITK PROJECT. Project: ManagedITK Program: Insight Segmentation & Registration Toolkit Module: @NAMESPACE@Managed@MANAGED_BASE_NAME@.cxx Language: C++/CLI Author: Dan Mueller Date: $Date$ Revision: $Revision$ Portions of this code are covered under the ITK and VTK copyright. See http://www.itk.org/HTML/Copyright.htm for details. See http://www.kitware.com/VTKCopyright.htm for details. Copyright (c) 2008 Dan Mueller Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =============================================================================*/ #pragma once #pragma warning( disable : 4635 ) // Disable warnings about XML doc comments #ifndef __@NAMESPACE@Managed@MANAGED_BASE_NAME@_cxx #define __@NAMESPACE@Managed@MANAGED_BASE_NAME@_cxx // Include some useful ITK headers #pragma unmanaged #include "itkExceptionObject.h" #include "itkObject.h" @MANAGED_INCLUDE_TYPE@ // Include some useful ManagedITK files #pragma managed #include "itkManagedTypes.cxx" #include "itkManagedObjectAutoPtr.cxx" #include "itkManagedObjectCommand.cxx" @MANAGED_INCLUDE_TYPE_AFTER_PRAGMA_MANAGED@ // Use some managed namespaces #using #using #using using namespace System; using namespace System::IO; using namespace System::Reflection; using namespace System::ComponentModel; using namespace System::Diagnostics; namespace @NAMESPACE@ { @MANAGED_EXTRA_TYPE@ /// ///This class is a managed wrapper for @NAMESPACE@::@MANAGED_BASE_NAME@. /// /// ///The actual type instance can be specified by calling the New() ///method with the desired output image type. /// public ref class @NAMESPACE@@MANAGED_BASE_NAME@ : itk::itkImageIOBase { private: // Native type typedef @MANAGED_CLASS@ NativeType; itk::itkObjectAutoPtr m_PointerToNative; protected: ///Protected constructor. @NAMESPACE@@MANAGED_BASE_NAME@ ( ) : itk::itkImageIOBase( ) { } public: ///Dispose of the managed object. ~@NAMESPACE@@MANAGED_BASE_NAME@ ( ) { if (!this->IsDisposed) { this->m_IsDisposed = true; this->m_PointerToNative.Reset(); } } ///Finalize the managed object. !@NAMESPACE@@MANAGED_BASE_NAME@ ( ) { if (!this->IsDisposed && this->DisposeNativeObjectOnFinalize) delete this; } /// ///Get/set the pointer to the native ITK object associated with ///this wrapper instance. /// ///The pointer to the native ITK object. property IntPtr NativePointer { virtual IntPtr get() override { return IntPtr(this->m_PointerToNative.Get()); } virtual void set ( IntPtr value ) override { this->m_PointerToNative.Reset( (NativeType*)value.ToPointer() ); } } ///Get the last modified time. property unsigned long MTime { virtual unsigned long get() override { return this->m_PointerToNative->GetMTime(); } } ///Create an instance of the underlying native itk object. static @NAMESPACE@@MANAGED_BASE_NAME@^ New ( ) { try { // Create a new managed object @NAMESPACE@@MANAGED_BASE_NAME@^ newManagedObject = gcnew @NAMESPACE@@MANAGED_BASE_NAME@(); // Create a new native object NativeType::Pointer nativeObject = NativeType::New(); newManagedObject->m_PointerToNative.Reset( nativeObject ); // Add AnyEvent observer newManagedObject->AddAnyEventObserver(); // Return return newManagedObject; } catch ( itk::ExceptionObject& ex ) { throw gcnew itkExceptionObject( ex.GetDescription(), ex.GetLocation(), ex.GetFile(), ex.GetLine() ); } } ///Return itk::LightObject::Print( ostream ) as a string. virtual String^ ToString ( ) override { std::stringstream ss; m_PointerToNative->Print( ss ); std::string s = ss.str(); return gcnew String( s.c_str() ); } /// ///Remove all observers watching this object. /// /// ///By default, observers are created for all events. Calling this ///method removes all native observers, and therefore prevents ///the firing of managed events. Call AddAnyEventObserver() to ///reset the default observers which enable the managed events. /// virtual void RemoveAllObservers ( ) override { this->m_PointerToNative->RemoveAllObservers(); } /// ///Adds a native observer watching for any event. /// /// ///By default, observers are created for all events. Calling this ///method adds a single native observer for any event. This ///observer invokes the managed events. Therefore, calling this ///method more than once, or calling it without first calling ///RemoveAllObservers(), may cause the managed events to be ///invoked more than once. /// virtual void AddAnyEventObserver ( ) override { itk::itkObjectCommand::Pointer observer = itk::itkObjectCommand::New(); observer->SetManagedObject( this ); this->m_PointerToNative->AddObserver( itk::AnyEvent(), observer ); } /// ///Get/set the number of independent variables (dimensions) in the image being read or written. Note this is not necessarily what is written, rather the IORegion controls that. /// property unsigned int NumberOfDimensions { virtual unsigned int get() override { return this->m_PointerToNative->GetNumberOfDimensions(); } virtual void set(unsigned int value) override { this->m_PointerToNative->SetNumberOfDimensions(value); } } /// ///Get/set a boolean to use the compression or not. /// property bool UseCompression { virtual bool get() override { return this->m_PointerToNative->GetUseCompression(); } virtual void set(bool value) override { this->m_PointerToNative->SetUseCompression(value); } } /// ///Get/set a boolean to use streaming while reading or not. /// property bool UseStreamedReading { virtual bool get() override { return this->m_PointerToNative->GetUseStreamedReading(); } virtual void set(bool value) override { this->m_PointerToNative->SetUseStreamedReading(value); } } /// ///Get/set a boolean to use streaming while writing or not. /// property bool UseStreamedWriting { virtual bool get() override { return this->m_PointerToNative->GetUseStreamedWriting(); } virtual void set(bool value) override { this->m_PointerToNative->SetUseStreamedWriting(value); } } /// ///Get the image dimensions in the x, y, z, etc. directions. GetDimensions() is typically used after reading the data. /// virtual unsigned int GetDimensions(unsigned int i) override { return this->m_PointerToNative->GetDimensions( i ); } /// ///Set the image dimensions in the x, y, z, etc. directions. SetDimensions() is used prior to writing the data. /// virtual void SetDimensions(unsigned int i, unsigned int dim) override { this->m_PointerToNative->SetDimensions( i, dim ); } /// ///Determine the file type. Returns true if this ImageIO can read the file specified. /// virtual bool CanReadFile ( String^ filename ) override { std::string stdfilename; ManagedTypes::ToNativeString( filename, stdfilename ); return this->m_PointerToNative->CanReadFile( stdfilename.c_str() ); } /// ///Determine if the ImageIO can stream reading from this file. Default is false. /// virtual bool CanStreamRead ( ) override { return this->m_PointerToNative->CanStreamRead( ); } /// ///Determine the file type. Returns true if this ImageIO can write the file specified. /// virtual bool CanWriteFile ( String^ filename ) override { std::string stdfilename; ManagedTypes::ToNativeString( filename, stdfilename ); return this->m_PointerToNative->CanWriteFile( stdfilename.c_str() ); } /// ///Determine if the ImageIO can stream writing to this file. Default is false. /// virtual bool CanStreamWrite ( ) override { return this->m_PointerToNative->CanStreamWrite( ); } /// ///The different types of ImageIO's can support data of varying dimensionality. For example, some file formats are strictly 2D while others can support 2D, 3D, or even n-D. This method returns true/false as to whether the ImageIO can support the dimension indicated. /// virtual bool SupportsDimension ( unsigned long dim ) override { return this->m_PointerToNative->SupportsDimension( dim ); } @MANAGED_PROPERTIES_TYPE@ @MANAGED_METHODS_TYPE@ }; // end ref class } // end namespace @NAMESPACE@ #endif