Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::cOSHandle Class Reference

#include <cOSHandle.h>

Inheritance diagram for Gray::cOSHandle:
Gray::cNonCopyable GrayLib::cOSPipe GrayLib::cSerialPort GrayLib::cOSPipeClient GrayLib::cOSPipeServer

Public Member Functions

 cOSHandle (HANDLE h=INVALID_HANDLE_VALUE) noexcept
 
 cOSHandle (const cOSHandle &Handle) noexcept
 
cOSHandleoperator= (const cOSHandle &Handle)
 
 ~cOSHandle ()
 
 operator HANDLE () const noexcept
 
HANDLE get_Handle () const noexcept
 
HANDLE & ref_Handle () noexcept
 
bool isValidHandle () const noexcept
 
void CloseHandle () noexcept
 
void AttachHandle (HANDLE h) noexcept
 
HANDLE DetachHandle () noexcept
 
HRESULT WriteX (const void *pData, size_t nDataSize) const
 
HRESULT ReadX (void *pData, size_t nDataSize) const
 
HRESULT FlushX () const
 
STREAM_SEEKRET_t Seek (STREAM_OFFSET_t lOffset, SEEK_ORIGIN_TYPE eSeekOrigin) const
 
HRESULT WaitForSingleObject (TIMESYSD_t dwMilliseconds) const
 

Static Public Member Functions

static bool IsValidHandle (HANDLE h) noexcept
 
static bool CloseHandle (HANDLE h) noexcept
 

Public Attributes

HANDLE m_h
 

Protected Member Functions

void CloseHandleLast () noexcept
 
- Protected Member Functions inherited from Gray::cNonCopyable
 cNonCopyable () noexcept
 Force the use of Factory creation via protected constructor. More...
 
 ~cNonCopyable () noexcept
 

Friends

class cOSHandleTests
 

Detailed Description

Wrap ownership of a OS Kernel HANDLE. (NOT a GUI or User handle) Close on destruct. Any OS system handles that might use CloseHandle() Similar to CHandle in ATL

Note
Don't use cHandlePtr<> because that is just for typed (not void) pointers and HANDLE is 'int' in linux

Constructor & Destructor Documentation

◆ cOSHandle() [1/2]

Gray::cOSHandle::cOSHandle ( HANDLE  h = INVALID_HANDLE_VALUE)
inlineexplicitnoexcept

◆ cOSHandle() [2/2]

Gray::cOSHandle::cOSHandle ( const cOSHandle Handle)
inlinenoexcept

◆ ~cOSHandle()

Gray::cOSHandle::~cOSHandle ( )
inline

Member Function Documentation

◆ AttachHandle()

void Gray::cOSHandle::AttachHandle ( HANDLE  h)
inlinenoexcept

◆ CloseHandle() [1/2]

void Gray::cOSHandle::CloseHandle ( )
inlinenoexcept

◆ CloseHandle() [2/2]

static bool Gray::cOSHandle::CloseHandle ( HANDLE  h)
inlinestaticnoexcept

default implementation for closing OS HANDLE. ASSUME IsValidHandle(h)

Returns
true = ok;

◆ CloseHandleLast()

void Gray::cOSHandle::CloseHandleLast ( )
inlineprotectednoexcept

◆ DetachHandle()

HANDLE Gray::cOSHandle::DetachHandle ( )
inlinenoexcept

◆ FlushX()

HRESULT Gray::cOSHandle::FlushX ( ) const
inline

synchronous flush of write data to file.

◆ get_Handle()

HANDLE Gray::cOSHandle::get_Handle ( ) const
inlinenoexcept

◆ isValidHandle()

bool Gray::cOSHandle::isValidHandle ( ) const
inlinenoexcept

◆ IsValidHandle()

static bool Gray::cOSHandle::IsValidHandle ( HANDLE  h)
inlinestaticnoexcept

0 is a valid OS handle for linux but NOT _WIN32

◆ operator HANDLE()

Gray::cOSHandle::operator HANDLE ( ) const
inlinenoexcept

◆ operator=()

cOSHandle& Gray::cOSHandle::operator= ( const cOSHandle Handle)
inline

◆ ReadX()

HRESULT Gray::cOSHandle::ReadX ( void *  pData,
size_t  nDataSize 
) const
inline

◆ ref_Handle()

HANDLE& Gray::cOSHandle::ref_Handle ( )
inlinenoexcept

◆ Seek()

STREAM_SEEKRET_t Gray::cOSHandle::Seek ( STREAM_OFFSET_t  lOffset,
SEEK_ORIGIN_TYPE  eSeekOrigin 
) const
inline

Change or get the current file position pointer.

  • eSeekOrigin = // SEEK_SET ?
    Returns
    the New position, -1=FAILED

◆ WaitForSingleObject()

HRESULT Gray::cOSHandle::WaitForSingleObject ( TIMESYSD_t  dwMilliseconds) const

Wait for the handle m_h to be signaled. HRESULT_WIN32_C(ERROR_WAIT_TIMEOUT) = after dwMilliseconds

◆ WriteX()

HRESULT Gray::cOSHandle::WriteX ( const void *  pData,
size_t  nDataSize 
) const
inline
Returns
# of bytes written. <0 = error. ERROR_INVALID_USER_BUFFER = too many async calls ?? wait ERROR_IO_PENDING = must wait!?

Friends And Related Function Documentation

◆ cOSHandleTests

friend class cOSHandleTests
friend

Member Data Documentation

◆ m_h

HANDLE Gray::cOSHandle::m_h

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