SRef Class Template Reference


Public Methods

 SRef (T *in)
 SRef (const SPtr< T > &in)
 SRef (const SRef< T > &in)
 ~SRef ()
T * detach () const
bool operator! () const
T * operator-> () const
bool operator== (const SRef< T > &other) const
bool operator== (const SPtr< T > &other) const
bool operator!= (const SRef< T > &other) const
bool operator!= (const SPtr< T > &other) const

Detailed Description

template<class T>
class SRef< T >

This class is a smart reference that can be used as a return value to pass referenced interfaces. When you use this class, have your interface function return an SRef<T> by value, where T is the interface you are returning.


Constructor & Destructor Documentation

template<class T>
SRef< T >::SRef T *    in [inline]
 

This function constructs an SRef from a raw pointer of type T. It increments the reference count of the argument, and the argument therefore does not have its reference count incremented.

Parameters:
in A pointer to an interface of type T.

template<class T>
SRef< T >::SRef const SPtr< T > &    in [inline]
 

This function constructs an SRef from an SPtr of the same controlled type. It caches the interface pointer controlled by the incoming SPtr, and increments the reference count for the return.

Parameters:
in A reference to an SPtr of type T.

template<class T>
SRef< T >::SRef const SRef< T > &    in [inline]
 

This function constructs an SRef from another SRef of the same controlled type. In this constructor, the target SRef takes control of the pointer by calling "detach" on the source SRef. This is done for performance purposes.

Parameters:
in A reference to another SRef of the same control type.

template<class T>
SRef< T >::~SRef   [inline]
 

This is the destructor of the SRef class. If the internal pointer is not NULL, it calls IBase::release() to remove the reference on the plug-in instance.


Member Function Documentation

template<class T>
T * SRef< T >::detach   const
 

This function detaches the controlled pointer from the SRef instance. It is assumed that the caller of detach will take responsibility for releasing the object.

template<class T>
bool SRef< T >::operator!   const [inline]
 

This logical NOT operator returns true if the pointer is NULL, otherwise it returns false.

template<class T>
bool SRef< T >::operator!= const SPtr< T > &    other const [inline]
 

This comparison operator tests the inequality of the controlled interface against an SPtr of the same control type.

Parameters:
other A reference to an SPtr of the same control type to test against.

template<class T>
bool SRef< T >::operator!= const SRef< T > &    other const [inline]
 

This comparison operator tests the inequality of the controlled interface against an SRef of the same control type.

Parameters:
other A reference to another SRef of the same control type to test against.

template<class T>
T * SRef< T >::operator->   const [inline]
 

This operator is used to access the member functions of the T interface. It allows the SRef to be used with the same syntax as a raw pointer. It is implemented on the SRef to allow a function that returns an SRef to be dereferenced with the ->() operator as though it were returning a raw pointer. For example, if myFunction() is a member function of the IMyInterface class:

   SRef	someFunction();
   .
   .
   .
   someFunction()->myFunction();
   

template<class T>
bool SRef< T >::operator== const SPtr< T > &    other const [inline]
 

This comparison operator tests the equality of the controlled interface against an SPtr of the same control type.

Parameters:
other A reference to an SPtr of the same control type to test against.

template<class T>
bool SRef< T >::operator== const SRef< T > &    other const [inline]
 

This comparison operator tests the equality of the controlled interface against an SRef of the same control type.

Parameters:
other A reference to another SRef of the same control type to test against.


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

Return to top of page