winstd::handle< T, INVAL > Class Template Referenceabstract
System Handles

Base abstract template class to support generic object handle keeping. More...

`#include <WinStd/Common.h>`

Inheritance diagram for winstd::handle< T, INVAL >:

## Public Types

typedef T | handle_type
| Datatype of the object handle this template class handles.

## Public Member Functions

| handle () noexcept
| Initializes a new class instance with the object handle set to INVAL.
| handle (handle_type h) noexcept
| Initializes a new class instance with an already available object handle. More...
| handle (handle< handle_type, INVAL > &&h) noexcept
| Move constructor. More...
handle< handle_type, INVAL > & | operator= (handle_type h) noexcept
| Attaches already available object handle. More...
handle< handle_type, INVAL > & | operator= (handle< handle_type, INVAL > &&h) noexcept
| Move assignment. More...
| operator handle_type () const
| Auto-typecasting operator. More...
handle_type *& | operator* () const
| Returns the object handle value when the object handle is a pointer to a value (class, struct, etc.). More...
handle_type * | operator& ()
| Returns the object handle reference. More...
handle_type | operator-> () const
| Provides object handle member access when the object handle is a pointer to a class or struct. More...
bool | operator! () const
| Tests if the object handle is INVAL. More...
bool | operator< (handle_type h) const
| Is handle less than? More...
bool | operator<= (handle_type h) const
| Is handle less than or equal to? More...
bool | operator>= (handle_type h) const
| Is handle greater than or equal to? More...
bool | operator> (handle_type h) const
| Is handle greater than? More...
bool | operator!= (handle_type h) const
| Is handle not equal to? More...
bool | operator== (handle_type h) const
| Is handle equal to? More...
void | attach (handle_type h) noexcept
| Sets a new object handle for the class. More...
handle_type | detach ()
| Dismisses the object handle from this class. More...
void | free ()
| Destroys the object.

## Static Public Attributes

static const T | invalid = INVAL
| Invalid handle value.

## Protected Member Functions

virtual void | free_internal () noexcept=0
| Abstract member function that must be implemented by child classes to do the actual object destruction. More...

## Protected Attributes

handle_type | m_h
| Object handle.

## Detailed Description

template<class T, const T INVAL>
class winstd::handle< T, INVAL >

Base abstract template class to support generic object handle keeping.

It provides basic operators and methods common to all descendands of this class establishing a base to ease the replacement of native object handle type with classes in object-oriented approach.

## Constructor & Destructor Documentation

## handle() [1/2]

template<class T , const T INVAL>

winstd::handle< T, INVAL >::handle | ( | handle_type | h | ) |

inlinenoexcept

Initializes a new class instance with an already available object handle.

Parameters

  [in] | h | Initial object handle value

## handle() [2/2]

template<class T , const T INVAL>

winstd::handle< T, INVAL >::handle | ( | handle< handle_type, INVAL > && | h | ) |

inlinenoexcept

Move constructor.

Parameters

  [in,out] | h | A rvalue reference of another object

## Member Function Documentation

## attach()

template<class T , const T INVAL>

void winstd::handle< T, INVAL >::attach | ( | handle_type | h | ) |

inlinenoexcept

Sets a new object handle for the class.

When the current object handle of the class is non-INVAL, the object is destroyed first.

Parameters

  [in] | h | New object handle

## detach()

template<class T , const T INVAL>

handle_type winstd::handle< T, INVAL >::detach | ( |  | ) |

inline

Dismisses the object handle from this class.

Returns
  Object handle

## free_internal()

template<class T , const T INVAL>

virtual void winstd::handle< T, INVAL >::free_internal | ( |  | ) |

protectedpure virtualnoexcept

Abstract member function that must be implemented by child classes to do the actual object destruction.

Implemented in winstd::com_obj< T >, winstd::bstr, winstd::cert_context, winstd::cert_chain_context, winstd::cert_store, winstd::crypt_prov, winstd::crypt_hash, winstd::crypt_key, winstd::eap_packet, winstd::event_provider, winstd::event_session, winstd::event_trace, winstd::gdi_handle< T >, winstd::dc, winstd::window_dc, winstd::sec_credentials, winstd::sec_context, winstd::setup_device_info_list, winstd::win_handle< INVALID >, winstd::win_handle< NULL >, winstd::win_handle< INVALID_HANDLE_VALUE >, winstd::library, winstd::find_file, winstd::heap, winstd::vmemory, winstd::reg_key, winstd::security_id, winstd::event_log, winstd::addrinfo, and winstd::wlan_handle.

## operator handle_type()

template<class T , const T INVAL>

winstd::handle< T, INVAL >::operator handle_type | ( |  | ) | const

inline

Auto-typecasting operator.

Returns
  Object handle

## operator!()

template<class T , const T INVAL>

bool winstd::handle< T, INVAL >::operator! | ( |  | ) | const

inline

Tests if the object handle is INVAL.

Returns
  - Non zero when object handle is INVAL;
  - Zero otherwise.

## operator!=()

template<class T , const T INVAL>

bool winstd::handle< T, INVAL >::operator!= | ( | handle_type | h | ) | const

inline

Is handle not equal to?

Parameters

  [in] | h | Object handle to compare against

Returns
  - Non zero when object handle is not equal to h;
  - Zero otherwise.

## operator&()

template<class T , const T INVAL>

handle_type * winstd::handle< T, INVAL >::operator& | ( |  | ) |

inline

Returns the object handle reference.

Returns
  Object handle reference

## operator*()

template<class T , const T INVAL>

handle_type *& winstd::handle< T, INVAL >::operator* | ( |  | ) | const

inline

Returns the object handle value when the object handle is a pointer to a value (class, struct, etc.).

Returns
  Object handle value

## operator->()

template<class T , const T INVAL>

handle_type winstd::handle< T, INVAL >::operator-> | ( |  | ) | const

inline

Provides object handle member access when the object handle is a pointer to a class or struct.

Returns
  Object handle

## operator<()

template<class T , const T INVAL>

bool winstd::handle< T, INVAL >::operator< | ( | handle_type | h | ) | const

inline

Is handle less than?

Parameters

  [in] | h | Object handle to compare against

Returns
  - Non zero when object handle is less than h;
  - Zero otherwise.

## operator<=()

template<class T , const T INVAL>

bool winstd::handle< T, INVAL >::operator<= | ( | handle_type | h | ) | const

inline

Is handle less than or equal to?

Parameters

  [in] | h | Object handle to compare against

Returns
  - Non zero when object handle is less than or equal to h;
  - Zero otherwise.

## operator=() [1/2]

template<class T , const T INVAL>

handle< handle_type, INVAL > & winstd::handle< T, INVAL >::operator= | ( | handle< handle_type, INVAL > && | h | ) |

inlinenoexcept

Move assignment.

Parameters

  [in,out] | h | A rvalue reference of another object

## operator=() [2/2]

template<class T , const T INVAL>

handle< handle_type, INVAL > & winstd::handle< T, INVAL >::operator= | ( | handle_type | h | ) |

inlinenoexcept

Attaches already available object handle.

Parameters

  [in] | h | Object handle value

## operator==()

template<class T , const T INVAL>

bool winstd::handle< T, INVAL >::operator== | ( | handle_type | h | ) | const

inline

Is handle equal to?

Parameters

  [in] | h | Object handle to compare against

Returns
  - Non zero when object handle is equal to h;
  - Zero otherwise.

## operator>()

template<class T , const T INVAL>

bool winstd::handle< T, INVAL >::operator> | ( | handle_type | h | ) | const

inline

Is handle greater than?

Parameters

  [in] | h | Object handle to compare against

Returns
  - Non zero when object handle is greater than h;
  - Zero otherwise.

## operator>=()

template<class T , const T INVAL>

bool winstd::handle< T, INVAL >::operator>= | ( | handle_type | h | ) | const

inline

Is handle greater than or equal to?

Parameters

  [in] | h | Object handle to compare against

Returns
  - Non zero when object handle is greater than or equal to h;
  - Zero otherwise.

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

- include/WinStd/Common.h