winss
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | Related Functions | List of all members
winss::HandleWrapper Class Reference

A wrapper for a Windows HANDLE. More...

#include <handle_wrapper.hpp>

Inheritance diagram for winss::HandleWrapper:
Inheritance graph
[legend]

Public Member Functions

 HandleWrapper ()
 Create an empty handle wrapper. More...
 
 HandleWrapper (HANDLE handle, bool owned=true, DWORD dup_rights=0)
 Create a new handle wrapper. More...
 
 HandleWrapper (const HandleWrapper &h)
 Copies the handle wrapper. More...
 
 HandleWrapper (HandleWrapper &&h)
 Move the handle wrapper. More...
 
bool HasHandle () const
 Gets if the wrapper contains a handle. More...
 
bool IsOwner () const
 Gets if this instance owns the handle. More...
 
DWORD GetDuplicateRights () const
 Gets the duplicate rights of the handle. More...
 
WaitResult Wait (DWORD timeout) const
 Waits for an event on the handle. More...
 
HANDLE Duplicate (bool inherit) const
 Duplicates the handle. More...
 
bool operator== (const HandleWrapper &rhs) const
 Checks the handles are equal. More...
 
bool operator!= (const HandleWrapper &rhs) const
 Checks the handles are not equal. More...
 
bool operator< (const HandleWrapper &rhs) const
 Checks this handle is less than the rhs. More...
 
bool operator<= (const HandleWrapper &rhs) const
 Checks this handle is less than or equal to the rhs. More...
 
bool operator> (const HandleWrapper &rhs) const
 Checks this handle is greater than the rhs. More...
 
bool operator>= (const HandleWrapper &rhs) const
 Checks this handle is greater than or equal to the rhs. More...
 
HandleWrapperoperator= (const HandleWrapper &h)
 Copies the handle wrapper. More...
 
HandleWrapperoperator= (HandleWrapper &&h)
 Move the handle wrapper. More...
 
virtual ~HandleWrapper ()
 Cleans up the handle. More...
 

Static Public Member Functions

template<typename Iterator >
static WaitResult Wait (DWORD timeout, Iterator begin, Iterator end)
 Waits for an event on a sequence of handles. More...
 

Protected Member Functions

void CloseHandle ()
 Close the handle if the instance owns it. More...
 

Static Protected Member Functions

static WaitResult Wait (DWORD timeout, const std::vector< HANDLE > &handles)
 Waits for an event to happen on the given list of handles. More...
 

Protected Attributes

bool owned
 If this instance owns the handle. More...
 
HANDLE handle
 The wrapped handle. More...
 
DWORD dup_rights
 The duplicate rights. More...
 

Friends

bool operator== (const HandleWrapper &lhs, const HANDLE &rhs)
 Checks the handles are equal. More...
 
bool operator== (const HANDLE &lhs, const HandleWrapper &rhs)
 Checks the handles are equal. More...
 
bool operator!= (const HandleWrapper &lhs, const HANDLE &rhs)
 Checks the handles are not equal. More...
 
bool operator!= (const HANDLE &lhs, const HandleWrapper &rhs)
 Checks the handles are not equal. More...
 
bool operator< (const HandleWrapper &lhs, const HANDLE &rhs)
 Checks the lhs handle is less than the rhs. More...
 
bool operator< (const HANDLE &lhs, const HandleWrapper &rhs)
 Checks the lhs handle is less than the rhs. More...
 
bool operator<= (const HandleWrapper &lhs, const HANDLE &rhs)
 Checks the lhs handle is less than or equal to the rhs. More...
 
bool operator<= (const HANDLE &lhs, const HandleWrapper &rhs)
 Checks the lhs handle is less than or equal to the rhs. More...
 
bool operator> (const HandleWrapper &lhs, const HANDLE &rhs)
 Checks the lhs handle is greater than the rhs. More...
 
bool operator> (const HANDLE &lhs, const HandleWrapper &rhs)
 Checks the lhs handle is greater than the rhs. More...
 
bool operator>= (const HandleWrapper &lhs, const HANDLE &rhs)
 Checks the lhs handle is greater than or equal to the rhs. More...
 
bool operator>= (const HANDLE &lhs, const HandleWrapper &rhs)
 

Related Functions

(Note that these are not member functions.)

bool operator== (const HandleWrapper &lhs, const HANDLE &rhs)
 
bool operator== (const HANDLE &lhs, const winss::HandleWrapper &rhs)
 
bool operator!= (const winss::HandleWrapper &lhs, const HANDLE &rhs)
 
bool operator!= (const HANDLE &lhs, const winss::HandleWrapper &rhs)
 
bool operator< (const winss::HandleWrapper &lhs, const HANDLE &rhs)
 
bool operator< (const HANDLE &lhs, const winss::HandleWrapper &rhs)
 
bool operator<= (const winss::HandleWrapper &lhs, const HANDLE &rhs)
 
bool operator<= (const HANDLE &lhs, const winss::HandleWrapper &rhs)
 
bool operator> (const winss::HandleWrapper &lhs, const HANDLE &rhs)
 
bool operator> (const HANDLE &lhs, const winss::HandleWrapper &rhs)
 
bool operator>= (const winss::HandleWrapper &lhs, const HANDLE &rhs)
 
bool operator>= (const HANDLE &lhs, const winss::HandleWrapper &rhs)
 

Detailed Description

A wrapper for a Windows HANDLE.

Constructor & Destructor Documentation

winss::HandleWrapper::HandleWrapper ( )

Create an empty handle wrapper.

winss::HandleWrapper::HandleWrapper ( HANDLE  handle,
bool  owned = true,
DWORD  dup_rights = 0 
)
explicit

Create a new handle wrapper.

Parameters
handleThe handle to wrap.
ownedIf the instance should own the handle.
dup_rightsThe duplicate rights on the handle.
winss::HandleWrapper::HandleWrapper ( const HandleWrapper h)

Copies the handle wrapper.

Any ownership rights will not be copied.

Parameters
hThe handle wrapper to copy.
winss::HandleWrapper::HandleWrapper ( winss::HandleWrapper &&  h)

Move the handle wrapper.

Any ownership rights will be moved

Parameters
hThe handle wrapper to move.
winss::HandleWrapper::~HandleWrapper ( )
virtual

Cleans up the handle.

References CloseHandle().

Referenced by Wait().

Member Function Documentation

void winss::HandleWrapper::CloseHandle ( )
protected

Close the handle if the instance owns it.

References handle, owned, and WINDOWS.

Referenced by operator=(), and ~HandleWrapper().

HANDLE winss::HandleWrapper::Duplicate ( bool  inherit) const

Duplicates the handle.

Parameters
[in]inheritIf the duplicated handle should be inheritable.
Returns
The new raw handle.

References dup_rights, handle, and WINDOWS.

Referenced by winss::Process::Create(), and Wait().

DWORD winss::HandleWrapper::GetDuplicateRights ( ) const

Gets the duplicate rights of the handle.

Returns
The duplicate rights as an unsigned int.

References dup_rights.

bool winss::HandleWrapper::HasHandle ( ) const

Gets if the wrapper contains a handle.

Returns
True if the wrapper contains a handle otherwise false.

References handle.

Referenced by winss::WaitMultiplexer::AddTriggeredCallback(), and winss::Process::Create().

bool winss::HandleWrapper::IsOwner ( ) const

Gets if this instance owns the handle.

Returns
True if the instance owns the handle otherwise false.

References owned.

bool winss::HandleWrapper::operator!= ( const HandleWrapper rhs) const

Checks the handles are not equal.

Parameters
[in]rhsThe other handle.
Returns
True if handles are not equal.

References handle.

Referenced by Wait().

bool winss::HandleWrapper::operator< ( const HandleWrapper rhs) const

Checks this handle is less than the rhs.

Parameters
[in]rhsThe other handle.
Returns
True if this handle is less than the rhs.

References handle.

Referenced by Wait().

bool winss::HandleWrapper::operator<= ( const HandleWrapper rhs) const

Checks this handle is less than or equal to the rhs.

Parameters
[in]rhsThe other handle.
Returns
True if this handle is less than or equal to the rhs.

References handle.

Referenced by Wait().

winss::HandleWrapper & winss::HandleWrapper::operator= ( const HandleWrapper h)

Copies the handle wrapper.

Any ownership rights will not be copied.

Parameters
hThe handle wrapper to copy.
Returns
This handle wrapper.

References CloseHandle(), dup_rights, handle, and owned.

Referenced by Wait().

winss::HandleWrapper & winss::HandleWrapper::operator= ( winss::HandleWrapper &&  h)

Move the handle wrapper.

Any ownership rights will be moved

Parameters
hThe handle wrapper to move.
Returns
This handle wrapper.

References CloseHandle(), dup_rights, handle, and owned.

bool winss::HandleWrapper::operator== ( const HandleWrapper rhs) const

Checks the handles are equal.

Parameters
[in]rhsThe other handle.
Returns
True if handles are equal.

References handle.

Referenced by Wait().

bool winss::HandleWrapper::operator> ( const HandleWrapper rhs) const

Checks this handle is greater than the rhs.

Parameters
[in]rhsThe other handle.
Returns
True if this handle is greater than the rhs.

References handle.

Referenced by Wait().

bool winss::HandleWrapper::operator>= ( const HandleWrapper rhs) const

Checks this handle is greater than or equal to the rhs.

Parameters
[in]rhsThe other handle.
Returns
True if this handle is greater than or equal to the rhs.

References handle.

Referenced by Wait().

winss::WaitResult winss::HandleWrapper::Wait ( DWORD  timeout,
const std::vector< HANDLE > &  handles 
)
staticprotected

Waits for an event to happen on the given list of handles.

Parameters
[in]timeoutThe wait timeout.
[in]handlesThe list of handles to wait for.
Returns
The wait result.

References winss::FAILED, handle, winss::SUCCESS, winss::TIMEOUT, and WINDOWS.

Referenced by winss::WaitMultiplexer::Start(), and Wait().

winss::WaitResult winss::HandleWrapper::Wait ( DWORD  timeout) const

Waits for an event on the handle.

Parameters
[in]timeoutThe wait timeout.
Returns
The wait result.

References handle, and Wait().

template<typename Iterator >
static WaitResult winss::HandleWrapper::Wait ( DWORD  timeout,
Iterator  begin,
Iterator  end 
)
inlinestatic

Waits for an event on a sequence of handles.

Template Parameters
IteratorThe iterator type.
Parameters
[in]timeoutThe wait timeout.
[in]beginThe start of the handle sequence.
[in]endThe end of the handle sequence.
Returns
The wait result.

References Duplicate(), operator!=(), operator<(), operator<=(), operator=(), operator==(), operator>(), operator>=(), winss::WaitResult::state, Wait(), and ~HandleWrapper().

Friends And Related Function Documentation

bool operator!= ( const winss::HandleWrapper lhs,
const HANDLE &  rhs 
)
related

References handle.

bool operator!= ( const HANDLE &  lhs,
const winss::HandleWrapper rhs 
)
related

References handle.

bool operator!= ( const HandleWrapper lhs,
const HANDLE &  rhs 
)
friend

Checks the handles are not equal.

Parameters
[in]lhsThe first handle.
[in]rhsThe second handle.
Returns
True if handles are not equal.
bool operator!= ( const HANDLE &  lhs,
const HandleWrapper rhs 
)
friend

Checks the handles are not equal.

Parameters
[in]lhsThe first handle.
[in]rhsThe second handle.
Returns
True if handles are not equal.
bool operator< ( const winss::HandleWrapper lhs,
const HANDLE &  rhs 
)
related

References handle.

bool operator< ( const HANDLE &  lhs,
const winss::HandleWrapper rhs 
)
related

References handle.

bool operator< ( const HandleWrapper lhs,
const HANDLE &  rhs 
)
friend

Checks the lhs handle is less than the rhs.

Parameters
[in]lhsThe first handle.
[in]rhsThe other handle.
Returns
True if the lhs handle is less than the rhs.
bool operator< ( const HANDLE &  lhs,
const HandleWrapper rhs 
)
friend

Checks the lhs handle is less than the rhs.

Parameters
[in]lhsThe first handle.
[in]rhsThe other handle.
Returns
True if the lhs handle is less than the rhs.
bool operator<= ( const winss::HandleWrapper lhs,
const HANDLE &  rhs 
)
related

References handle.

bool operator<= ( const HANDLE &  lhs,
const winss::HandleWrapper rhs 
)
related

References handle.

bool operator<= ( const HandleWrapper lhs,
const HANDLE &  rhs 
)
friend

Checks the lhs handle is less than or equal to the rhs.

Parameters
[in]lhsThe first handle.
[in]rhsThe other handle.
Returns
True if the lhs handle is less than or equal to the rhs.
bool operator<= ( const HANDLE &  lhs,
const HandleWrapper rhs 
)
friend

Checks the lhs handle is less than or equal to the rhs.

Parameters
[in]lhsThe first handle.
[in]rhsThe other handle.
Returns
True if the lhs handle is less than or equal to the rhs.
bool operator== ( const HandleWrapper lhs,
const HANDLE &  rhs 
)
related

References handle.

bool operator== ( const HANDLE &  lhs,
const winss::HandleWrapper rhs 
)
related

References handle.

bool operator== ( const HandleWrapper lhs,
const HANDLE &  rhs 
)
friend

Checks the handles are equal.

Parameters
[in]lhsThe first handle.
[in]rhsThe second handle.
Returns
True if handles are equal.
bool operator== ( const HANDLE &  lhs,
const HandleWrapper rhs 
)
friend

Checks the handles are equal.

Parameters
[in]lhsThe first handle.
[in]rhsThe second handle.
Returns
True if handles are equal.
bool operator> ( const winss::HandleWrapper lhs,
const HANDLE &  rhs 
)
related

References handle.

bool operator> ( const HANDLE &  lhs,
const winss::HandleWrapper rhs 
)
related

References handle.

bool operator> ( const HandleWrapper lhs,
const HANDLE &  rhs 
)
friend

Checks the lhs handle is greater than the rhs.

Parameters
[in]lhsThe first handle.
[in]rhsThe other handle.
Returns
True if the lhs handle is greater than the rhs.
bool operator> ( const HANDLE &  lhs,
const HandleWrapper rhs 
)
friend

Checks the lhs handle is greater than the rhs.

Parameters
[in]lhsThe first handle.
[in]rhsThe other handle.
Returns
True if the lhs handle is greater than the rhs.
bool operator>= ( const winss::HandleWrapper lhs,
const HANDLE &  rhs 
)
related

References handle.

bool operator>= ( const HANDLE &  lhs,
const winss::HandleWrapper rhs 
)
related

References handle.

bool operator>= ( const HandleWrapper lhs,
const HANDLE &  rhs 
)
friend

Checks the lhs handle is greater than or equal to the rhs.

Parameters
[in]lhsThe first handle.
[in]rhsThe other handle.
Returns
True if the lhs handle is greater than or equal to the rhs.
bool operator>= ( const HANDLE &  lhs,
const HandleWrapper rhs 
)
friend

Member Data Documentation

DWORD winss::HandleWrapper::dup_rights
protected
HANDLE winss::HandleWrapper::handle
protected
bool winss::HandleWrapper::owned
protected

If this instance owns the handle.

Referenced by CloseHandle(), IsOwner(), and operator=().


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