winss
|
A wrapper for a Windows HANDLE. More...
#include <handle_wrapper.hpp>
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... | |
HandleWrapper & | operator= (const HandleWrapper &h) |
Copies the handle wrapper. More... | |
HandleWrapper & | operator= (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) |
A wrapper for a Windows HANDLE.
winss::HandleWrapper::HandleWrapper | ( | ) |
Create an empty handle wrapper.
|
explicit |
Create a new handle wrapper.
handle | The handle to wrap. |
owned | If the instance should own the handle. |
dup_rights | The duplicate rights on the handle. |
winss::HandleWrapper::HandleWrapper | ( | const HandleWrapper & | h | ) |
Copies the handle wrapper.
Any ownership rights will not be copied.
h | The handle wrapper to copy. |
winss::HandleWrapper::HandleWrapper | ( | winss::HandleWrapper && | h | ) |
Move the handle wrapper.
Any ownership rights will be moved
h | The handle wrapper to move. |
|
virtual |
|
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.
[in] | inherit | If the duplicated handle should be inheritable. |
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.
References dup_rights.
bool winss::HandleWrapper::HasHandle | ( | ) | const |
Gets if the wrapper contains a handle.
References handle.
Referenced by winss::WaitMultiplexer::AddTriggeredCallback(), and winss::Process::Create().
bool winss::HandleWrapper::IsOwner | ( | ) | const |
Gets if this instance owns the handle.
References owned.
bool winss::HandleWrapper::operator!= | ( | const HandleWrapper & | rhs | ) | const |
bool winss::HandleWrapper::operator< | ( | const HandleWrapper & | rhs | ) | const |
bool winss::HandleWrapper::operator<= | ( | const HandleWrapper & | rhs | ) | const |
winss::HandleWrapper & winss::HandleWrapper::operator= | ( | const HandleWrapper & | h | ) |
Copies the handle wrapper.
Any ownership rights will not be copied.
h | The handle wrapper to copy. |
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
h | The handle wrapper to move. |
References CloseHandle(), dup_rights, handle, and owned.
bool winss::HandleWrapper::operator== | ( | const HandleWrapper & | rhs | ) | const |
bool winss::HandleWrapper::operator> | ( | const HandleWrapper & | rhs | ) | const |
bool winss::HandleWrapper::operator>= | ( | const HandleWrapper & | rhs | ) | const |
|
staticprotected |
Waits for an event to happen on the given list of handles.
[in] | timeout | The wait timeout. |
[in] | handles | The list of handles to wait for. |
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 |
|
inlinestatic |
Waits for an event on a sequence of handles.
Iterator | The iterator type. |
[in] | timeout | The wait timeout. |
[in] | begin | The start of the handle sequence. |
[in] | end | The end of the handle sequence. |
References Duplicate(), operator!=(), operator<(), operator<=(), operator=(), operator==(), operator>(), operator>=(), winss::WaitResult::state, Wait(), and ~HandleWrapper().
|
related |
References handle.
|
related |
References handle.
|
friend |
Checks the handles are not equal.
[in] | lhs | The first handle. |
[in] | rhs | The second handle. |
|
friend |
Checks the handles are not equal.
[in] | lhs | The first handle. |
[in] | rhs | The second handle. |
|
related |
References handle.
|
related |
References handle.
|
friend |
Checks the lhs handle is less than the rhs.
[in] | lhs | The first handle. |
[in] | rhs | The other handle. |
|
friend |
Checks the lhs handle is less than the rhs.
[in] | lhs | The first handle. |
[in] | rhs | The other handle. |
|
related |
References handle.
|
related |
References handle.
|
friend |
Checks the lhs handle is less than or equal to the rhs.
[in] | lhs | The first handle. |
[in] | rhs | The other handle. |
|
friend |
Checks the lhs handle is less than or equal to the rhs.
[in] | lhs | The first handle. |
[in] | rhs | The other handle. |
|
related |
References handle.
|
related |
References handle.
|
friend |
Checks the handles are equal.
[in] | lhs | The first handle. |
[in] | rhs | The second handle. |
|
friend |
Checks the handles are equal.
[in] | lhs | The first handle. |
[in] | rhs | The second handle. |
|
related |
References handle.
|
related |
References handle.
|
friend |
Checks the lhs handle is greater than the rhs.
[in] | lhs | The first handle. |
[in] | rhs | The other handle. |
|
friend |
Checks the lhs handle is greater than the rhs.
[in] | lhs | The first handle. |
[in] | rhs | The other handle. |
|
related |
References handle.
|
related |
References handle.
|
friend |
Checks the lhs handle is greater than or equal to the rhs.
[in] | lhs | The first handle. |
[in] | rhs | The other handle. |
|
friend |
|
protected |
The duplicate rights.
Referenced by Duplicate(), GetDuplicateRights(), winss::TrustedHandleWrapper::GetHandleWrapper(), and operator=().
|
protected |
The wrapped handle.
Referenced by CloseHandle(), Duplicate(), winss::TrustedHandleWrapper::GetHandle(), winss::TrustedHandleWrapper::GetHandleWrapper(), HasHandle(), operator!=(), operator<(), operator<=(), operator=(), operator==(), operator>(), operator>=(), and Wait().
|
protected |
If this instance owns the handle.
Referenced by CloseHandle(), IsOwner(), and operator=().