blocxx
|
PURPOSE: The AutoResource class template is an analog of std::auto_ptr for managing arbitrary resource handles. More...
#include <AutoResource.hpp>
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. | |
AutoResource & | operator= (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). | |
AutoResource & | operator= (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 |
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.
typedef Policy::handle_type BLOCXX_NAMESPACE::AutoResource< Policy >::handle_type [private] |
Definition at line 99 of file AutoResource.hpp.
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.
BLOCXX_NAMESPACE::AutoResource< Policy >::AutoResource | ( | handle_type | h | ) | [inline, explicit] |
Take over ownership of h.
Definition at line 116 of file AutoResource.hpp.
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.
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.
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.
BLOCXX_NAMESPACE::AutoResource< Policy >::BLOCXX_SAFE_BOOL_IMPL | ( | AutoResource< Policy > | , |
handle_type | , | ||
AutoResource< Policy >::hdl | , | ||
(hdl!=Policy::null()) | |||
) |
handle_type BLOCXX_NAMESPACE::AutoResource< Policy >::get | ( | ) | const [inline] |
Return handle of resource, retaining ownership.
Definition at line 165 of file AutoResource.hpp.
References BLOCXX_NAMESPACE::AutoResource< Policy >::hdl.
Referenced by BLOCXX_NAMESPACE::SocketBaseImpl::connect(), BLOCXX_NAMESPACE::UnnamedPipe::createStderr(), BLOCXX_NAMESPACE::UnnamedPipe::createStdin(), BLOCXX_NAMESPACE::UnnamedPipe::createStdinStdout(), BLOCXX_NAMESPACE::UnnamedPipe::createStdout(), BLOCXX_NAMESPACE::UnnamedPipe::createUnnamedPipeFromDescriptor(), BLOCXX_NAMESPACE::FileBuf::open(), and BLOCXX_NAMESPACE::receiveDescriptor().
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().
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().
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.
handle_type BLOCXX_NAMESPACE::AutoResource< Policy >::release | ( | ) | [inline] |
Relinquish ownership of resource and return its handle.
Definition at line 172 of file AutoResource.hpp.
References BLOCXX_NAMESPACE::AutoResource< Policy >::hdl.
Referenced by BLOCXX_NAMESPACE::SocketBaseImpl::connect(), BLOCXX_NAMESPACE::FileBuf::open(), BLOCXX_NAMESPACE::AutoResource< Policy >::operator AutoResourceRef< Policy >(), and BLOCXX_NAMESPACE::AutoResource< Policy >::operator=().
void BLOCXX_NAMESPACE::AutoResource< Policy >::reset | ( | ) | [inline] |
Definition at line 193 of file AutoResource.hpp.
Referenced by BLOCXX_NAMESPACE::AutoResource< Policy >::operator=().
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.
handle_type BLOCXX_NAMESPACE::AutoResource< Policy >::hdl [private] |
Definition at line 100 of file AutoResource.hpp.
Referenced by BLOCXX_NAMESPACE::AutoResource< Policy >::get(), BLOCXX_NAMESPACE::AutoResource< Policy >::operator=(), BLOCXX_NAMESPACE::AutoResource< Policy >::release(), BLOCXX_NAMESPACE::AutoResource< Policy >::reset(), and BLOCXX_NAMESPACE::AutoResource< Policy >::~AutoResource().