/*============================================================================= 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: 2007-09-01 06:17:25 +1000 (Sat, 01 Sep 2007) $ Revision: $Revision: 2 $ Copyright (c) Queensland University of Technology (QUT) 2007. All rights reserved. Portions of this code are covered under the ITK and VTK copyright. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =============================================================================*/ #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 // 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_WRAPPER@ /// ///This class is a managed interface for itk::@MANAGED_BASE_NAME@. /// /// ///Both the wrapper and type classes derive from this interface. /// public interface class I@MANAGED_BASE_NAME@ { @MANAGED_PROPERTIES_INTERFACE@ @MANAGED_METHODS_INTERFACE@ }; /// ///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::itkImageSource, I@MANAGED_BASE_NAME@ { private: itk::itkImageSource^ m_Instance; protected: ///Protected constructor. @NAMESPACE@@MANAGED_BASE_NAME@ ( ) : itk::itkImageSource( "@MANAGED_BASE_NAME@" ) { } public: ///Dispose of the managed object. ~@NAMESPACE@@MANAGED_BASE_NAME@ ( ) { if (!this->IsDisposed) { this->m_IsDisposed = true; delete m_Instance; } } ///Finalize the managed object. !@NAMESPACE@@MANAGED_BASE_NAME@ ( ) { if (!this->IsDisposed && this->DisposeNativeObjectOnFinalize) delete this; } /// ///Gets/sets if the underlying native object should be disposed when the managed object is finalized. ///The default is true. /// property bool DisposeNativeObjectOnFinalize { virtual bool get() override { return this->m_Instance->DisposeNativeObjectOnFinalize; } virtual void set( bool value ) override { this->m_Instance->DisposeNativeObjectOnFinalize = value; } } /// ///Get/set the pointer to the native ITK object associated with ///this wrapper instance. /// ///The pointer to the native ITK object. property void* NativePointer { virtual void* get() override { return this->m_Instance->NativePointer; } virtual void set ( void* value ) override { this->m_Instance->NativePointer = value; } } ///Get the last modified time. property unsigned long MTime { virtual unsigned long get() override { return this->m_Instance->MTime; } } /// ///Get the size of the input array. This is merely the size of the input array, ///not the number of inputs that have valid DataObject's assigned. /// ///Use NumberOfValidRequiredInputs to determine how many inputs are non-null. property unsigned int NumberOfInputs { virtual unsigned int get() override { return this->m_Instance->NumberOfInputs; } } /// ///Get the number of valid inputs. This is the number of non-null entries in the ///input array in the first NumberOfRequiredInputs slots. This method is used ///to determine whether the necessary required inputs have been set. /// property unsigned int NumberOfValidRequiredInputs { virtual unsigned int get() override { return this->m_Instance->NumberOfValidRequiredInputs; } } ///Return the length of the output array. property unsigned int NumberOfOutputs { virtual unsigned int get() override { return this->m_Instance->NumberOfOutputs; } } ///Get/set the number of threads to create when executing. property unsigned int NumberOfThreads { virtual unsigned int get() override { return this->m_Instance->NumberOfThreads; } virtual void set(unsigned int threads) override { this->m_Instance->NumberOfThreads = threads; } } ///Create a specific type instance using the given types. ///An array of types specifying which instance to create. static @NAMESPACE@@MANAGED_BASE_NAME@^ New ( ... array^ types ) { // Check that types is valid if ( types == nullptr || types->Length == 0 ) throw gcnew itk::itkInvalidWrappedTypeException("The given types array is invalid. A non-empty, valid types array must be specified to create an instance of a wrapped itk::@MANAGED_BASE_NAME@."); // Create the MangledTypeString for the specified explicit instance String^ mangledType = String::Empty; for each ( itk::INativePointer^ type in types ) mangledType += type->MangledTypeString; return @NAMESPACE@@MANAGED_BASE_NAME@::New( mangledType ); } ///Create a specific type instance using the given types. ///A string specifying which instance type to create. Eg. "IUC2", "IF3", etc. static @NAMESPACE@@MANAGED_BASE_NAME@^ New ( String^ mangledType ) { // Create a new managed object @NAMESPACE@@MANAGED_BASE_NAME@^ newManagedObject = gcnew @NAMESPACE@@MANAGED_BASE_NAME@(); newManagedObject->m_MangledTypeString = mangledType; // Get the name of the instance type to create String^ nameInstanceType = "@NAMESPACE@.@NAMESPACE@@MANAGED_BASE_NAME@_" + newManagedObject->MangledTypeString; try { // Create the correct instance class Type^ typeInstance = Assembly::GetExecutingAssembly()->GetType(nameInstanceType); if (typeInstance == nullptr) throw gcnew NullReferenceException("The type '" + nameInstanceType + "' could not be found in " + Assembly::GetExecutingAssembly()->GetName() ); Object^ objInstance = typeInstance->InvokeMember("New", BindingFlags::InvokeMethod, Type::DefaultBinder, nullptr, nullptr); if (objInstance == nullptr) throw gcnew NullReferenceException("Could not invoke the New() method for '" + nameInstanceType + "'."); newManagedObject->m_Instance = safe_cast(objInstance); // Pass events from type to wrapper newManagedObject->PassEventsFromTypeToWrapper( ); // Return return newManagedObject; } catch (Exception^ ex) { throw gcnew itk::itkInvalidWrappedTypeException("Could not create an instance of '" + nameInstanceType + "'. The given type may not be supported or may be invalid.", ex); } } ///Return itk::LightObject::Print( ostream ) as a string. virtual String^ ToString ( ) override { return m_Instance->ToString( ); } /// ///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_Instance->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 { this->m_Instance->AddAnyEventObserver( ); this->PassEventsFromTypeToWrapper( ); } /// ///Bring this filter up-to-date. /// /// ///Update() checks modified times against last execution times, and ///re-executes objects if necessary. A side effect of this method ///ss that the whole pipeline may execute in order to bring this filter ///up-to-date. This method updates the currently prescribed requested region. ///If no requested region has been set on the output, then the requested ///region will be set to the largest possible region. Once the requested ///region is set, Update() will make sure the specified requested region ///is up-to-date. To have a filter always to produce its largest possible ///region, users should call UpdateLargestPossibleRegion() instead. /// virtual void Update ( ) override { this->m_Instance->Update(); } /// ///Bring the largest possible region of this filter up-to-date. /// /// ///Like Update(), but sets the output requested region to the ///largest possible region for the output. This is the method users ///should call if they want the entire dataset to be processed. If ///a user wants to update the same output region as a previous call ///to Update() or a previous call to UpdateLargestPossibleRegion(), ///then they should call the method Update(). /// virtual void UpdateLargestPossibleRegion ( ) override { this->m_Instance->UpdateLargestPossibleRegion(); } /// ///Set the AbortGenerateData flag to true, and try to prematurely terminate the process. /// /// ///Process objects may handle premature termination of execution in different ways. ///Eg. many filters totally ignore this flag. /// virtual void AbortGenerateData( ) override { this->m_Instance->AbortGenerateData(); } ///Get the specified output of the filter object. ///The itkDataObject to make as the output. virtual void GetOutput ( unsigned int index, itk::itkDataObject^ output ) override { this->m_Instance->GetOutput(index, output); } ///Get the first output of the filter object. ///The itkDataObject to make as the output. virtual void GetOutput ( itk::itkDataObject^ output ) override { this->m_Instance->GetOutput(output); } ///Get the specified output of the filter object. ///The output as an IntPtr. virtual System::IntPtr GetOutput( unsigned int index ) override { return this->m_Instance->GetOutput(index); } ///Get the first output of the filter object. ///The output as an IntPtr. virtual System::IntPtr GetOutput( ) override { return this->m_Instance->GetOutput(); } @MANAGED_PROPERTIES_WRAPPER@ @MANAGED_METHODS_WRAPPER@ private: ///Pass managed events from the type instance to this wrapper instance. void PassEventsFromTypeToWrapper() { this->m_Instance->Started += gcnew itk::itkTimedEventHandler(this, &@NAMESPACE@@MANAGED_BASE_NAME@::Instance_StartedHandler); this->m_Instance->Ended += gcnew itk::itkTimedEventHandler(this, &@NAMESPACE@@MANAGED_BASE_NAME@::Instance_EndedHandler); this->m_Instance->Aborted += gcnew itk::itkTimedEventHandler(this, &@NAMESPACE@@MANAGED_BASE_NAME@::Instance_AbortedHandler); this->m_Instance->Iteration += gcnew itk::itkObjectHandler(this, &@NAMESPACE@@MANAGED_BASE_NAME@::Instance_IterationHandler); this->m_Instance->Modified += gcnew itk::itkObjectHandler(this, &@NAMESPACE@@MANAGED_BASE_NAME@::Instance_ModifiedHandler); this->m_Instance->Progress += gcnew itk::itkProgressHandler(this, &@NAMESPACE@@MANAGED_BASE_NAME@::Instance_ProgressHandler); } ///Handle the Started event. void Instance_StartedHandler(itk::itkObject^ sender, System::DateTime time) { this->InvokeStartedEvent(time); } ///Handle the Ended event. void Instance_EndedHandler(itk::itkObject^ sender, System::DateTime time) { this->InvokeEndedEvent(time); } ///Handle the Aborted event. void Instance_AbortedHandler(itk::itkObject^ sender, System::DateTime time) { this->InvokeAbortedEvent(time); } ///Handle the Iteration event. void Instance_IterationHandler(itk::itkObject^ sender) { this->InvokeIterationEvent(); } ///Handle the Modified event. void Instance_ModifiedHandler(itk::itkObject^ sender) { this->InvokeModifiedEvent(); } ///Handle the Progress event. void Instance_ProgressHandler(itk::itkProcessObject^ process, float progress) { this->InvokeProgressEvent(progress); } }; // end ref class } // end namespace @NAMESPACE@ #endif