blocxx
|
PURPOSE: The AutoResource class template is an analog of std::auto_ptr for managing arbitrary resource handles. More...
#include <AutoResource.hpp>
Public Types | |
typedef handle_type | AutoResource< Policy >safe_bool |
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. | |
operator safe_bool () const | |
bool | operator! () const |
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:
Policy::equal(h1, h2) is a legal expression convertible to bool whenever h1 and h2 are convertible to Policy::handle_type. Either
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 handle_type BLOCXX_NAMESPACE::AutoResource< Policy >::AutoResource< Policy >safe_bool |
Definition at line 161 of file AutoResource.hpp.
|
private |
Definition at line 99 of file AutoResource.hpp.
|
inline |
Default (no argument) ctor initializes with value indicating no resource currently owned.
Definition at line 108 of file AutoResource.hpp.
|
inlineexplicit |
Take over ownership of h.
Definition at line 116 of file AutoResource.hpp.
|
inline |
Take over ownership of resource owned by x.
Definition at line 131 of file AutoResource.hpp.
|
inline |
Free resource when AutoResource object reaches end of lifetime.
Definition at line 156 of file AutoResource.hpp.
|
inline |
Conversion to facilitate passing and returning AutoResource by value (which transfers ownership).
Definition at line 202 of file AutoResource.hpp.
|
inline |
Return handle of resource, retaining ownership.
Definition at line 165 of file AutoResource.hpp.
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(), BLOCXX_NAMESPACE::FileBuf::open(), BLOCXX_NAMESPACE::PosixUnnamedPipe::PosixUnnamedPipe(), BLOCXX_NAMESPACE::receiveDescriptor(), and BLOCXX_NAMESPACE::Select::selectRWEpoll().
|
inline |
Conversion to facilitate passing and returning AutoResource by value (which transfers ownership).
Definition at line 211 of file AutoResource.hpp.
|
inline |
Definition at line 161 of file AutoResource.hpp.
|
inline |
Definition at line 161 of file AutoResource.hpp.
|
inline |
Assignment takes over ownership of resource owned by x.
Definition at line 148 of file AutoResource.hpp.
|
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.
|
inline |
Relinquish ownership of resource and return its handle.
Definition at line 172 of file AutoResource.hpp.
Referenced by BLOCXX_NAMESPACE::SocketBaseImpl::connect(), BLOCXX_NAMESPACE::FileBuf::open(), BLOCXX_NAMESPACE::FileBuf::open(), BLOCXX_NAMESPACE::AutoResource< AutoDescriptorPolicy >::operator AutoResourceRef< AutoDescriptorPolicy >(), BLOCXX_NAMESPACE::AutoResource< AutoDescriptorPolicy >::operator=(), and BLOCXX_NAMESPACE::PosixUnnamedPipe::PosixUnnamedPipe().
|
inline |
Definition at line 193 of file AutoResource.hpp.
Referenced by BLOCXX_NAMESPACE::AutoResource< AutoDescriptorPolicy >::operator=(), and BLOCXX_NAMESPACE::AutoResource< AutoDescriptorPolicy >::reset().
|
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.
|
private |
Definition at line 100 of file AutoResource.hpp.