AudRecordLib
Public Member Functions
ComType< Type > Class Template Reference

#include <scoped.h>

List of all members.

Public Member Functions

 ComType (Type *data)
 ComType (const ComType &other)
 ComType ()
 ~ComType ()
void operator= (const ComType &other)
Type * get () const
Type * operator* () const
Type ** operator& ()
Type * operator-> ()
 operator bool_type () const
void Init (Type *newData)
Type * Release ()
void Swap (ComType &other)

Detailed Description

template<class Type>
class ComType< Type >

Scoped wrapper around a COM object

Template Parameters:
TypeThe interface type that'll be stored in the object

Constructor & Destructor Documentation

template<class Type>
ComType< Type >::ComType ( Type *  data) [inline]

Construct an object with a preexisting interface pointer

The function assumes ownership of the pointer and does not call AddRef on it.

Parameters:
dataA pointer that the object takes ownership of
template<class Type>
ComType< Type >::ComType ( const ComType< Type > &  other) [inline]

Copies the pointer stored in another object and calls AddRef

Parameters:
otherThe object to copy the pointer from
template<class Type>
ComType< Type >::ComType ( ) [inline]

Leaves the object in an uninitialised state

template<class Type>
ComType< Type >::~ComType ( ) [inline]

Calls Release on the stored interface pointer if there is one


Member Function Documentation

template<class Type>
Type* ComType< Type >::get ( ) const [inline]

Retrieves the stored pointer

The function asserts that the object is initialised before returning the pointer

Returns:
The objects data pointer
template<class Type>
void ComType< Type >::Init ( Type *  newData) [inline]

Initialises an uninitialised object

The function asserts that the object hasn't been initialised

Parameters:
newDataAn interface pointer that the object takes ownership of
template<class Type>
ComType< Type >::operator bool_type ( ) const [inline]

Safe bool idiom initialised check

Returns:
NULL if the object is in an uninitialised state, non-zero otherwise
template<class Type>
Type** ComType< Type >::operator& ( ) [inline]

Retrieves a pointer to the interface pointer

The function asserts that the object has not already been initialised before returning the pointer. Allowing this can lead to memory leaks

Returns:
A pointer to the stored interface pointer
template<class Type>
Type* ComType< Type >::operator* ( ) const [inline]

Retrieves the stored pointer

This operator is just syntactic sugar around the get() method.

Returns:
The objects data pointer
template<class Type>
Type* ComType< Type >::operator-> ( ) [inline]

Retrieves the stored pointer

Equivalent to get(), this operator allows the object to be used as a pointer

Returns:
The stored interface pointer
template<class Type>
void ComType< Type >::operator= ( const ComType< Type > &  other) [inline]

Makes the contained pointer equal to that contained in another object

Parameters:
otherThe object and indirectly the pointer to make this object the same as
template<class Type>
Type* ComType< Type >::Release ( ) [inline]

Releases the object's ownership of the stored pointer

Turns the object back to an uninitialised state. The caller is then responsible for calling Release() on the interface when it is no longer required. Note: this function DOES NOT call Release on the stored interface pointer and is not equivalent to calling it.

Returns:
The stored pointer
template<class Type>
void ComType< Type >::Swap ( ComType< Type > &  other) [inline]

Swaps the pointers stored in two disperate objects

Parameters:
otherThe object to swap with

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Defines