boost::process::detail::file_handle Class Reference

#include <file_handle.hpp>

List of all members.

Public Member Functions

 file_handle ()
 file_handle (handle_type h)
 file_handle (const file_handle &fh)
 ~file_handle ()
file_handleoperator= (const file_handle &fh)
bool valid () const
void close ()
handle_type release ()
handle_type get () const


Detailed Description

Simple RAII model for system file handles.

The file_handle class is a simple RAII model for native system file handles. This class wraps one of such handles grabbing its ownership, and automaticaly closes it upon destruction. It is basically used inside the library to avoid leaking open file handles, shall an unexpected execution trace occur.

A file_handle object can be copied but doing so invalidates the source object. There can only be a single valid file_handle object for a given system file handle. This is similar to std::auto_ptr's semantics.

This class also provides some convenience methods to issue special file operations under their respective platforms.


Constructor & Destructor Documentation

boost::process::detail::file_handle::file_handle (  )  [inline]

Constructs an invalid file handle.

This constructor creates a new file_handle object that represents an invalid file handle. An invalid file handle can be copied but cannot be manipulated in any way (except checking for its validity).

See also:
valid()

boost::process::detail::file_handle::file_handle ( handle_type  h  )  [inline]

Constructs a new file handle from a native file handle.

This constructor creates a new file_handle object that takes ownership of the given h native file handle. The user must not close h on his own during the lifetime of the new object. Ownership can be reclaimed using release().

Precondition:
The native file handle must be valid; a close operation must succeed on it.
See also:
release()

boost::process::detail::file_handle::file_handle ( const file_handle fh  )  [inline]

Copy constructor; invalidates the source handle.

This copy constructor creates a new file handle from a given one. Ownership of the native file handle is transferred to the new object, effectively invalidating the source file handle. This avoids having two live file_handle objects referring to the same native file handle. The source file handle needs not be valid in the name of simplicity.

Postcondition:
The source file handle is invalid.

The new file handle owns the source's native file handle.

boost::process::detail::file_handle::~file_handle (  )  [inline]

Releases resources if the handle is valid.

If the file handle is valid, the destructor closes it.

See also:
valid()


Member Function Documentation

file_handle& boost::process::detail::file_handle::operator= ( const file_handle fh  )  [inline]

Assignment operator; invalidates the source handle.

This assignment operator transfers ownership of the RHS file handle to the LHS one, effectively invalidating the source file handle. This avoids having two live file_handle objects referring to the same native file handle. The source file handle needs not be valid in the name of simplicity.

Postcondition:
The RHS file handle is invalid.

The LHS file handle owns RHS' native file handle.

Returns:
A reference to the LHS file handle.

bool boost::process::detail::file_handle::valid (  )  const [inline]

Checks whether the file handle is valid or not.

Returns a boolean indicating whether the file handle is valid or not. If the file handle is invalid, no other methods can be executed other than the destructor.

Returns:
true if the file handle is valid; false otherwise.

void boost::process::detail::file_handle::close (  )  [inline]

Closes the file handle.

Explicitly closes the file handle, which must be valid. Upon exit, the handle is not valid any more.

Precondition:
The file handle is valid.
Postcondition:
The file handle is invalid.

The native file handle is closed.

handle_type boost::process::detail::file_handle::release (  )  [inline]

Reclaims ownership of the native file handle.

Explicitly reclaims ownership of the native file handle contained in the file_handle object, returning the native file handle. The caller is responsible of closing it later on.

Precondition:
The file handle is valid.
Postcondition:
The file handle is invalid.
Returns:
The native file handle.

handle_type boost::process::detail::file_handle::get (  )  const [inline]

Gets the native file handle.

Returns the native file handle for the file_handle object. The caller can issue any operation on it except closing it. If closing is required, release() shall be used.

Precondition:
The file handle is valid.
Postcondition:
The file handle is valid.
Returns:
The native file handle.


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

Generated on Mon Sep 22 01:00:43 2008 by  doxygen 1.5.5