DotNX::Core::AutoDisposable< RefType > Class Template Reference

Resource management helper. More...

Inheritance diagram for DotNX::Core::AutoDisposable< RefType >:

DotNX::Core::DisposableBase

List of all members.

Public Member Functions

 AutoDisposable ()
 Default constructor.
 AutoDisposable (RefType res)
 Value constructor.
 AutoDisposable (ref RefType res)
 Reference constructor.
void Reset (RefType res)
 Replaces the resource it holds with a new one.
void Reset (ref RefType res)
 Replaces the resource it holds with a new one.
void Reset ()
 Disposes of the resource it holds.
void Release (out RefType res)
 Relinquishes control over the resource it holds.

Static Public Member Functions

static implicit operator RefType (AutoDisposable< RefType > ar)
 Implicit conversion operator.

Protected Member Functions

override void Dispose (bool disposing)
 Implements the IDisposable protocol. See the DisposableBase class for details.

Properties

bool Empty [get]
 Indicates whether a resource is being held.


Detailed Description

template<RefType>
class DotNX::Core::AutoDisposable< RefType >

Resource management helper.

Obviates the limitations of the using statement. Ensures correct handling of resources within constructors and makes it possible to conditionally construct IDisposable's within using statements. Expects to own resources exclusively, even though such a constraint cannot be enforced completely.

Template Parameters:
RefType The IDisposable descendant to be managed.
Type Constraints
RefType :class 
RefType :IDisposable 

Constructor & Destructor Documentation

template<RefType >
DotNX::Core::AutoDisposable< RefType >::AutoDisposable (  ) 

Default constructor.

Initialises an instance to hold a null reference.

template<RefType >
DotNX::Core::AutoDisposable< RefType >::AutoDisposable ( RefType  res  ) 

Value constructor.

Parameters:
res The resource to be managed, usually directly constructed.

template<RefType >
DotNX::Core::AutoDisposable< RefType >::AutoDisposable ( ref RefType  res  ) 

Reference constructor.

Parameters:
res A reference to an already constructed resource, which is set to null to enforce single ownership.


Member Function Documentation

template<RefType >
static implicit DotNX::Core::AutoDisposable< RefType >::operator RefType ( AutoDisposable< RefType >  ar  )  [static]

Implicit conversion operator.

The resource is kept under AutoDisposable's control.

Parameters:
ar An AutoDisposable to a resource type.
Returns:
The resource being held.

template<RefType >
void DotNX::Core::AutoDisposable< RefType >::Reset ( RefType  res  ) 

Replaces the resource it holds with a new one.

The resource held originally is disposed of.

Parameters:
res The new resource to handle.

template<RefType >
void DotNX::Core::AutoDisposable< RefType >::Reset ( ref RefType  res  ) 

Replaces the resource it holds with a new one.

The reference variant of the previous method, which sets its argument to null.

Parameters:
res The new resource to handle.

template<RefType >
void DotNX::Core::AutoDisposable< RefType >::Reset (  ) 

Disposes of the resource it holds.

template<RefType >
void DotNX::Core::AutoDisposable< RefType >::Release ( out RefType  res  ) 

Relinquishes control over the resource it holds.

Parameters:
res the resource.

template<RefType >
override void DotNX::Core::AutoDisposable< RefType >::Dispose ( bool  disposing  )  [protected, virtual]

Implements the IDisposable protocol. See the DisposableBase class for details.

Parameters:
disposing Indicates whether fields requiring explicit cleanup should be dealt with.

Implements DotNX::Core::DisposableBase.


Property Documentation

template<RefType >
bool DotNX::Core::AutoDisposable< RefType >::Empty [get]

Indicates whether a resource is being held.


The documentation for this class was generated from the following file:

SourceForge.net Logo
Generated on Sat Oct 18 14:13:25 2008 for .Nick's 0.1.0 by  doxygen 1.5.7.1