C# Class Wombat.MamaWrapper

Base class for all wrapped native objects. Provides common facilities to the base classes.
Inheritance: IDisposable
Datei anzeigen Open project: OpenMAMA/OpenMAMA Class Usage Examples

Protected Properties

Property Type Description
nativeHandle System.IntPtr

Public Methods

Method Description
Dispose ( ) : void

Destroys the underlying peer object and unbinds the wrapper from it.

setNativeHandle ( IntPtr nHandle ) : void

Sets the native handle of the native peer object. Should only be used by subclasses and in the same assembly.

Protected Methods

Method Description
CheckResultCode ( int code ) : void

Helper method for the sub classes

CheckResultCodeIgnoreNotFound ( int code ) : MamaStatus.mamaStatus

Helper method for the sub classes which will not throw exception for not found

DestroyNativePeer ( ) : MamaStatus.mamaStatus

Subclasses must do whatever is necessary with the native handle in the overridden method in order to destroy the native peer object. If the destruction went successfully, the overridden method must return MamaStatus.mamaStatus.MAMA_STATUS_OK, or a suitable error code otherwise

Dispose ( bool disposing, bool destroyNativeHandle = true ) : void

The actual implementation of Dispose - called by both the Dispose method and the finalizer.

EnsurePeerCreated ( ) : void

Throws an exception if the native object has not been created.

MamaWrapper ( ) : System

Constructs a new wrapper object but doesn't create it. If the object is not explicitly disposed it will remain registered for finalization and will attempt the destroy the native peer object when finalized.

MamaWrapper ( IntPtr nativeHandle ) : System

Constructs a managed wrapper from an existing native peer. The peer object will not be automatically finalized

OnDispose ( ) : void

SelfManageLifeTime ( bool value ) : void

In some situations, wrappers are created elsewhere, but need to automatically destroy themselves, otherwise would be leaked; as a general rule, all .NET wrapper objects that were created from a native handle are not supposed to manage its own life time and will not be destroyed - this is an exception that needs to be handled (example - MamaMsg uses this method)

Method Details

CheckResultCode() protected static method

Helper method for the sub classes
protected static CheckResultCode ( int code ) : void
code int the MamaStatus.mamaStatus returned from the native call (as integer)
return void

CheckResultCodeIgnoreNotFound() protected static method

Helper method for the sub classes which will not throw exception for not found
protected static CheckResultCodeIgnoreNotFound ( int code ) : MamaStatus.mamaStatus
code int the MamaStatus.mamaStatus returned from the native call (as integer)
return MamaStatus.mamaStatus

DestroyNativePeer() protected abstract method

Subclasses must do whatever is necessary with the native handle in the overridden method in order to destroy the native peer object. If the destruction went successfully, the overridden method must return MamaStatus.mamaStatus.MAMA_STATUS_OK, or a suitable error code otherwise
protected abstract DestroyNativePeer ( ) : MamaStatus.mamaStatus
return MamaStatus.mamaStatus

Dispose() public method

Destroys the underlying peer object and unbinds the wrapper from it.
public Dispose ( ) : void
return void

Dispose() protected method

The actual implementation of Dispose - called by both the Dispose method and the finalizer.
protected Dispose ( bool disposing, bool destroyNativeHandle = true ) : void
disposing bool true if the object is being disposed (false if being finalized)
destroyNativeHandle bool
return void

EnsurePeerCreated() protected method

Throws an exception if the native object has not been created.
/// Thrown if the native object has not been created. ///
protected EnsurePeerCreated ( ) : void
return void

MamaWrapper() protected method

Constructs a new wrapper object but doesn't create it. If the object is not explicitly disposed it will remain registered for finalization and will attempt the destroy the native peer object when finalized.
protected MamaWrapper ( ) : System
return System

MamaWrapper() protected method

Constructs a managed wrapper from an existing native peer. The peer object will not be automatically finalized
protected MamaWrapper ( IntPtr nativeHandle ) : System
nativeHandle System.IntPtr The opaque native handle to the peer object
return System

OnDispose() protected method

protected OnDispose ( ) : void
return void

SelfManageLifeTime() protected method

In some situations, wrappers are created elsewhere, but need to automatically destroy themselves, otherwise would be leaked; as a general rule, all .NET wrapper objects that were created from a native handle are not supposed to manage its own life time and will not be destroyed - this is an exception that needs to be handled (example - MamaMsg uses this method)
protected SelfManageLifeTime ( bool value ) : void
value bool
return void

setNativeHandle() public method

Sets the native handle of the native peer object. Should only be used by subclasses and in the same assembly.
public setNativeHandle ( IntPtr nHandle ) : void
nHandle System.IntPtr
return void

Property Details

nativeHandle protected_oe property

the handle to the native peer object
protected IntPtr,System nativeHandle
return System.IntPtr