|
WinStd
Windows Win32 API using Standard C++
|
Base abstract template class to support generic object handle keeping. More...
#include <WinStd/Common.h>
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. | |
| handle (handle< handle_type, INVAL > &&h) noexcept | |
| Move constructor. | |
| handle< handle_type, INVAL > & | operator= (handle_type h) noexcept |
| Attaches already available object handle. | |
| handle< handle_type, INVAL > & | operator= (handle< handle_type, INVAL > &&h) noexcept |
| Move assignment. | |
| operator handle_type () const | |
| Auto-typecasting operator. | |
| handle_type *& | operator* () const |
| Returns the object handle value when the object handle is a pointer to a value (class, struct, etc.). | |
| handle_type * | operator& () |
| Returns the object handle reference. | |
| handle_type | operator-> () const |
| Provides object handle member access when the object handle is a pointer to a class or struct. | |
| bool | operator! () const |
| Tests if the object handle is invalid. | |
| bool | operator< (handle_type h) const |
| Is handle less than? | |
| bool | operator<= (handle_type h) const |
| Is handle less than or equal to? | |
| bool | operator>= (handle_type h) const |
| Is handle greater than or equal to? | |
| bool | operator> (handle_type h) const |
| Is handle greater than? | |
| bool | operator!= (handle_type h) const |
| Is handle not equal to? | |
| bool | operator== (handle_type h) const |
| Is handle equal to? | |
| void | attach (handle_type h) noexcept |
| Sets a new object handle for the class. | |
| handle_type | detach () |
| Dismisses the object handle from this class. | |
| 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. | |
Protected Attributes | |
| handle_type | m_h |
| Object handle. | |
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.
|
inlinenoexcept |
Initializes a new class instance with an already available object handle.
| [in] | h | Initial object handle value |
|
inlinenoexcept |
Move constructor.
| [in,out] | h | A rvalue reference of another object |
|
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.
| [in] | h | New object handle |
|
inline |
Dismisses the object handle from this class.
|
protectedpure virtualnoexcept |
Abstract member function that must be implemented by child classes to do the actual object destruction.
Implemented in winstd::addrinfo, winstd::bstr, winstd::cert_chain_context, winstd::cert_context, winstd::cert_store, winstd::com_obj< T >, winstd::crypt_hash, winstd::crypt_key, winstd::crypt_prov, winstd::dc, winstd::eap_packet, winstd::event_log, winstd::event_provider, winstd::event_session, winstd::event_trace, winstd::find_file, winstd::gdi_handle< T >, winstd::heap, winstd::http, winstd::icon, winstd::library, winstd::reg_key, winstd::safearray, winstd::sc_handle, winstd::sec_context, winstd::sec_credentials, winstd::security_id, winstd::setup_device_info_list, winstd::vmemory, winstd::waddrinfo, winstd::win_handle< INVALID >, winstd::window_dc, and winstd::wlan_handle.
|
inline |
Auto-typecasting operator.
|
inline |
Tests if the object handle is invalid.
operator bool() const would be correct C++ approach here. Unfortunately, it would produce ambiguities where bool and handle_type are polymorphed. Use !! to test if the object handle is valid.
|
inline |
Is handle not equal to?
| [in] | h | Object handle to compare against |
|
inline |
Returns the object handle reference.
|
inline |
Returns the object handle value when the object handle is a pointer to a value (class, struct, etc.).
|
inline |
Provides object handle member access when the object handle is a pointer to a class or struct.
|
inline |
Is handle less than?
| [in] | h | Object handle to compare against |
|
inline |
Is handle less than or equal to?
| [in] | h | Object handle to compare against |
|
inlinenoexcept |
Move assignment.
| [in,out] | h | A rvalue reference of another object |
|
inlinenoexcept |
Attaches already available object handle.
| [in] | h | Object handle value |
|
inline |
Is handle equal to?
| [in] | h | Object handle to compare against |
|
inline |
Is handle greater than?
| [in] | h | Object handle to compare against |
|
inline |
Is handle greater than or equal to?
| [in] | h | Object handle to compare against |