SQPtr Class Template Reference

Inheritance diagram for SQPtr:

SPtr


Public Methods

 SQPtr ()
 SQPtr (T *in)
 SQPtr (const char *clsid, bool factory=false)
 SQPtr (const SPtr< T > &in)
 SQPtr (const SQPtr< T > &in)
 SQPtr (const SRef< T > &in)
template<class U>  SQPtr (SPtr< U > in, bool successRequired=true)
template<class U>  SQPtr (U *in, bool successRequired=true)
template<class U>  SQPtr (const SRef< U > &in, bool successRequired=true)
T * operator= (const SQPtr< T > &in)
T * operator= (IBase *in)
T * operator= (T *in)
T * operator= (const SPtr< T > &in)
T * operator= (const SRef< T > &in)

Detailed Description

template<class T>
class SQPtr< T >

This class is an extension of the SPtr smart pointer. The Q stands for Query Interface, and the smart pointer is responsible for querying for the proper interface if an interface that is not of type 'T' is passed in. This interface must derive from IBase for the query to take place, otherwise a compile time error occurs. See the description of SPtr for more details.


Constructor & Destructor Documentation

template<class T>
SQPtr< T >::SQPtr   [inline]
 

This is the default constructor for the SQPtr class. It initializes the internal pointer to NULL.

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

This constructor takes in a raw interface pointer. It adds a reference to the instance (via the IBase::addRef() function) and stores the pointer value in its internal pointer field.

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

template<class T>
SQPtr< T >::SQPtr const char *    clsid,
bool    factory = false
[inline]
 

This constructor takes in the name of a plug-in. It passes this name to the plug-in manager to create a new instance of the requested plug-in. It requests an interface pointer of type T. If the plug-in doesn't implement that interface, the new plug-in instance will be deleted, and the internal pointer of the SQPtr is set to NULL.

Parameters:
clsid A NULL terminated string representing the name of the plug-in to create.
factory If this parameter is set to true, the SQPtr requests a pointer to the plug-in's factory* instead of the plug-in itself. This factory must implement the interface T. This is useful if the factory implements a custom creation interface, or some other interface that is relevent to all instances of this plug-in type (for example, licensing or authorization).

template<class T>
SQPtr< T >::SQPtr const SPtr< T > &    in [inline, explicit]
 

This constructor copies the pointer value from the SPtr<T> reference in the paramater "in", adds a reference to it via IBase::addRef() and stores it in it's internal pointer.

Parameters:
in A reference to an SPtr of the same type as this SQPtr.

template<class T>
T * SQPtr< T >::SQPtr const SQPtr< T > &    in [inline, explicit]
 

This is the standard copy constructor for the SQPtr class. It copies the pointer value from in and adds a reference to it via IBase::addRef().

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

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

This constructor takes in an SRef of a matching interface type. This is usually invoked when a function that returns an interface by an SRef is assigned into an SQPtr. Since it's the job of the SRef class to preserve the reference count of the plug-in through a function return, the SQPtr "takes over" this reference by calling SRef::detach(). See the description of SRef for more details.

Parameters:
in A reference to an SRef object.

template<class T>
template<class U>
SQPtr< T >::SQPtr SPtr< U >    in,
bool    successRequired = true
[inline, explicit]
 

template<class T>
template<class U>
template< class U > explicit SQPtr< T >::SQPtr U *    in,
bool    successRequired = true
[inline, explicit]
 

This constructor takes in an interface pointer of any type and queries it for an interface of type T. If successRequired is true, upon failure this function throws an IPlugInException that contains the failure code (one of the values in the IBase::Status enum). If successRequired is false, upon failure the internal pointer is set to NULL.

Parameters:
in An interface pointer of any type. It must derive from IBase.
successRequired A boolean value indicating if an exception should be thrown if the query for an interface of type T fails.

template<class T>
template<class U>
template< class U > explicit SQPtr< T >::SQPtr const SRef< U > &    in,
bool    successRequired = true
[inline, explicit]
 

This constructor takes in an SPtr of any type and queries the internal pointer for an interface of type T. If successRequired is true, upon failure this function throws an IPlugInException that contains the failure code (one of the values in the IBase::Status enum). If successRequired is false, upon failure the internal pointer is set to NULL.

Parameters:
in An SPtr of any type.
successRequired A boolean value indicating if an exception should be thrown if the query for an interface of type T fails.


Member Function Documentation

template<class T>
T * SQPtr< T >::operator= const SRef< T > &    in [inline]
 

This assigment operator takes in an SRef of a matching interface type. This is usually invoked when a function that returns an interface by an SRef is assigned into an SQPtr. Since it is the job of the SRef class to preserve the reference count of the plug-in through a function return, the SQPtr "takes over" this reference by calling SRef::detach(). See the description of SRef for more details.

Parameters:
in A reference to an SRef object.

Reimplemented from SPtr.

template<class T>
T * SQPtr< T >::operator= const SPtr< T > &    in [inline]
 

This assignment operator copies the pointer value from the SPtr<T> reference in the paramater "in", adds a reference to it via IBase::addRef(), and stores it in it's internal pointer.

Parameters:
in A reference to an SPtr of the same type as this SQPtr.

Reimplemented from SPtr.

template<class T>
T * SQPtr< T >::operator= T *    in [inline]
 

This function takes in a raw interface pointer. It adds a reference to the instance (via the IBase::addRef() function) and stores the pointer value in its internal pointer field.

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

Reimplemented from SPtr.

template<class T>
T * SQPtr< T >::operator= IBase *    in [inline]
 

This assignment operator takes in a pointer to an IBase interface, which all interface pointers should be derived from. It then queries it for an interface pointer of type T. If the query fails, the internal pointer is set to NULL.

Parameters:
in A poiner to an IBase interface. Note that any interface pointer assigned into an SQPtr will be converted to its IBase base pointer for this call.

template<class T>
T * SQPtr< T >::operator= const SQPtr< T > &    in [inline]
 


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

Return to top of page