blocxx
Public Member Functions | Private Types | Private Attributes

BLOCXX_NAMESPACE::AutoResource< Policy > Class Template Reference

PURPOSE: The AutoResource class template is an analog of std::auto_ptr for managing arbitrary resource handles. More...

#include <AutoResource.hpp>

List of all members.

Public Member Functions

 AutoResource ()
 Default (no argument) ctor initializes with value indicating no resource currently owned.
 AutoResource (handle_type h)
 Take over ownership of h.
 AutoResource (AutoResource &x)
 Take over ownership of resource owned by x.
AutoResourceoperator= (AutoResource &x)
 Assignment takes over ownership of resource owned by x.
 ~AutoResource ()
 Free resource when AutoResource object reaches end of lifetime.
 BLOCXX_SAFE_BOOL_IMPL (AutoResource< Policy >, handle_type, AutoResource< Policy >::hdl,(hdl!=Policy::null()))
handle_type get () const
 Return handle of resource, retaining ownership.
handle_type release ()
 Relinquish ownership of resource and return its handle.
void reset (handle_type h)
 Free resource and take over ownership of another.
void reset ()
 AutoResource (AutoResourceRef< Policy > href)
 Conversion to facilitate passing and returning AutoResource by value (which transfers ownership).
 operator AutoResourceRef< Policy > ()
 Conversion to facilitate passing and returning AutoResource by value (which transfers ownership).
AutoResourceoperator= (AutoResourceRef< Policy > href)
 Converting assignment to facilitate returning autorc by value (which transfers ownership).

Private Types

typedef Policy::handle_type handle_type

Private Attributes

handle_type hdl

Detailed Description

template<typename Policy>
class BLOCXX_NAMESPACE::AutoResource< Policy >

PURPOSE: The AutoResource class template is an analog of std::auto_ptr for managing arbitrary resource handles.

The Policy template argument specifies what type of resource to manage and how to release the resource.

PROMISE: None of the operations of the class throw exceptions.

REQUIRE: the Policy argument used below must be a class with these properties:

Note the additional requirements for reset(handle_type) and operator=(autorc_ref) in case (1). The equal function never throws.

Definition at line 97 of file AutoResource.hpp.


Member Typedef Documentation

template<typename Policy >
typedef Policy::handle_type BLOCXX_NAMESPACE::AutoResource< Policy >::handle_type [private]

Definition at line 99 of file AutoResource.hpp.


Constructor & Destructor Documentation

template<typename Policy >
BLOCXX_NAMESPACE::AutoResource< Policy >::AutoResource ( ) [inline]

Default (no argument) ctor initializes with value indicating no resource currently owned.

Definition at line 108 of file AutoResource.hpp.

template<typename Policy >
BLOCXX_NAMESPACE::AutoResource< Policy >::AutoResource ( handle_type  h) [inline, explicit]

Take over ownership of h.

Definition at line 116 of file AutoResource.hpp.

template<typename Policy >
BLOCXX_NAMESPACE::AutoResource< Policy >::AutoResource ( AutoResource< Policy > &  x) [inline]

Take over ownership of resource owned by x.

Definition at line 131 of file AutoResource.hpp.

template<typename Policy >
BLOCXX_NAMESPACE::AutoResource< Policy >::~AutoResource ( ) [inline]

Free resource when AutoResource object reaches end of lifetime.

Definition at line 156 of file AutoResource.hpp.

References BLOCXX_NAMESPACE::AutoResource< Policy >::hdl.

template<typename Policy >
BLOCXX_NAMESPACE::AutoResource< Policy >::AutoResource ( AutoResourceRef< Policy >  href) [inline]

Conversion to facilitate passing and returning AutoResource by value (which transfers ownership).

Definition at line 202 of file AutoResource.hpp.


Member Function Documentation

template<typename Policy >
BLOCXX_NAMESPACE::AutoResource< Policy >::BLOCXX_SAFE_BOOL_IMPL ( AutoResource< Policy >  ,
handle_type  ,
AutoResource< Policy >::hdl  ,
(hdl!=Policy::null())   
)
template<typename Policy >
handle_type BLOCXX_NAMESPACE::AutoResource< Policy >::get ( ) const [inline]
template<typename Policy >
BLOCXX_NAMESPACE::AutoResource< Policy >::operator AutoResourceRef< Policy > ( ) [inline]

Conversion to facilitate passing and returning AutoResource by value (which transfers ownership).

Definition at line 211 of file AutoResource.hpp.

References BLOCXX_NAMESPACE::AutoResource< Policy >::release().

template<typename Policy >
AutoResource& BLOCXX_NAMESPACE::AutoResource< Policy >::operator= ( AutoResource< Policy > &  x) [inline]

Assignment takes over ownership of resource owned by x.

Definition at line 148 of file AutoResource.hpp.

References BLOCXX_NAMESPACE::AutoResource< Policy >::release(), and BLOCXX_NAMESPACE::AutoResource< Policy >::reset().

template<typename Policy >
AutoResource& BLOCXX_NAMESPACE::AutoResource< Policy >::operator= ( AutoResourceRef< Policy >  href) [inline]

Converting assignment to facilitate returning autorc by value (which transfers ownership).

REQUIRE: if Policy::equal() always returns false, then href must not contain the resource handle currently owned by *this;

Definition at line 223 of file AutoResource.hpp.

References BLOCXX_NAMESPACE::AutoResource< Policy >::hdl, and BLOCXX_NAMESPACE::AutoResourceRef< Policy >::hdl.

template<typename Policy >
handle_type BLOCXX_NAMESPACE::AutoResource< Policy >::release ( ) [inline]
template<typename Policy >
void BLOCXX_NAMESPACE::AutoResource< Policy >::reset ( ) [inline]
template<typename Policy >
void BLOCXX_NAMESPACE::AutoResource< Policy >::reset ( handle_type  h) [inline]

Free resource and take over ownership of another.

REQUIRE: if Policy::equal() always returns false, then h must must not be the resource handle currently owned by *this.

Definition at line 185 of file AutoResource.hpp.

References BLOCXX_NAMESPACE::AutoResource< Policy >::hdl.


Member Data Documentation

template<typename Policy >
handle_type BLOCXX_NAMESPACE::AutoResource< Policy >::hdl [private]

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