WinStd
Additional templates and function helpers for Microsoft Windows using Standard C++ classes
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
winstd::handle< T, INVAL > Class Template Referenceabstract

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

#include <WinStd/Common.h>

Inheritance diagram for winstd::handle< T, INVAL >:
winstd::dplhandle< 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 (1 handle_type h) noexcept
 Initializes a new class instance with an already available object handle. More...
 
 handle (1 handle< handle_type, INVAL > &&h) noexcept
 Move constructor. More...
 
handle< handle_type, INVAL > & operator= (1 handle_type h) noexcept
 Attaches already available object handle. More...
 
handle< handle_type, INVAL > & operator= (1 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_typeoperator& ()
 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< (1 handle_type h) const
 Is handle less than? More...
 
bool operator<= (1 handle_type h) const
 Is handle less than or equal to? More...
 
bool operator>= (1 handle_type h) const
 Is handle greater than or equal to? More...
 
bool operator> (1 handle_type h) const
 Is handle greater than? More...
 
bool operator!= (1 handle_type h) const
 Is handle not equal to? More...
 
bool operator== (1 handle_type h) const
 Is handle equal to? More...
 
void attach (1 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 ( 1 handle_type  h)
inlinenoexcept

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

Parameters
[in]hInitial object handle value

◆ handle() [2/2]

template<class T , const T INVAL>
winstd::handle< T, INVAL >::handle ( 1 handle< handle_type, INVAL > &&  h)
inlinenoexcept

Move constructor.

Parameters
[in,out]hA rvalue reference of another object

Member Function Documentation

◆ attach()

template<class T , const T INVAL>
void winstd::handle< T, INVAL >::attach ( 1 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]hNew 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

◆ 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!= ( 1 handle_type  h) const
inline

Is handle not equal to?

Parameters
[in]hObject 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< ( 1 handle_type  h) const
inline

Is handle less than?

Parameters
[in]hObject 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<= ( 1 handle_type  h) const
inline

Is handle less than or equal to?

Parameters
[in]hObject 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= ( 1 handle< handle_type, INVAL > &&  h)
inlinenoexcept

Move assignment.

Parameters
[in,out]hA rvalue reference of another object

◆ operator=() [2/2]

template<class T , const T INVAL>
handle< handle_type, INVAL > & winstd::handle< T, INVAL >::operator= ( 1 handle_type  h)
inlinenoexcept

Attaches already available object handle.

Parameters
[in]hObject handle value

◆ operator==()

template<class T , const T INVAL>
bool winstd::handle< T, INVAL >::operator== ( 1 handle_type  h) const
inline

Is handle equal to?

Parameters
[in]hObject 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> ( 1 handle_type  h) const
inline

Is handle greater than?

Parameters
[in]hObject 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>= ( 1 handle_type  h) const
inline

Is handle greater than or equal to?

Parameters
[in]hObject 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: