| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

SmartIF< TYPE > Class Template Reference

Smart pointer to handle easily interfaces. More...

#include <GaudiKernel/SmartIF.h>

Inheritance diagram for SmartIF< TYPE >:

[legend]
Collaboration diagram for SmartIF< TYPE >:
[legend]
List of all members.

Public Member Functions

 SmartIF (const InterfaceID &iid, IInterface *iface)
 Standard constructor with initialisation.
 SmartIF (const InterfaceID &iid, TYPE *iface)
 Standard constructor with initialisation.
 SmartIF (const InterfaceID &iid)
 Standard constructor with initialisation.
 SmartIF (TYPE *iface)
 Standard constructor with initialisation.
 SmartIF (IInterface *iface=0)
 Standard constructor with initialisation.
 SmartIF (const SmartIF< TYPE > &copy)
 Copy constructor.
virtual ~SmartIF ()
 Standard destructor.
SmartIF< TYPE > & operator= (int)
 Simple assignment operator.
template<class T>
SmartIF< TYPE > & operator= (const SmartIF< T > &iface)
 Copy assignment operator with conversion to requested interface type.
SmartIF< TYPE > & operator= (const SmartIF< TYPE > &iface)
 Copy assignment operator.
SmartIFoperator= (IInterface *iface)
 Assignment operator with conversion to requested interface type.
SmartIF< TYPE > & operator= (TYPE *iface)
 Simple assignment operator.
bool operator! () const
 check the validity of the interface
bool isValid () const
 Allow for check if smart pointer is valid.
 operator TYPE * ()
 Automatic conversion to constined interface type.
 operator const TYPE * () const
 Automatic conversion to constined interface type (CONST).
bool operator!= (const TYPE *test) const
 Check for non-equality.
bool operator== (const TYPE *test) const
 Check for equality.
TYPE * operator-> ()
 Dereference operator.
const TYPE * operator-> () const
 Dereference operator (CONST).
void ** operator & ()
 Allow for use as void pointer.
const TYPE * get ()
 Get reference to interface pointer.
TYPE *& pRef ()
 Get reference to interface pointer.
const TYPE *const & pRef () const
 Get reference to interface pointer (CONST).

Protected Member Functions

void releaseInterface ()
 Release interface.

Protected Attributes

const InterfaceID m_iid
TYPE * m_interface

Detailed Description

template<class TYPE>
class SmartIF< TYPE >

Smart pointer to handle easily interfaces.

Description: A small class to easy the use of Gaudi interfaces.

Base Class: SmartIFBase<TYPE>

History :

    +---------+----------------------------------------------+--------+
    |    Date |                 Comment                      | Who    |
    +---------+----------------------------------------------+--------+
    | 30/10/99| Initial version.                             | MF     |
    +---------+----------------------------------------------+--------+
    
Author: M.Frank Version: 1.0

Definition at line 120 of file SmartIF.h.


Constructor & Destructor Documentation

template<class TYPE>
SmartIF< TYPE >::SmartIF ( const InterfaceID iid,
IInterface iface 
) [inline]

Standard constructor with initialisation.

Definition at line 123 of file SmartIF.h.

00123                                                      : SmartIFBase<TYPE>(iid)   {
00124     SmartIF<TYPE>::operator=(iface);
00125   }

template<class TYPE>
SmartIF< TYPE >::SmartIF ( const InterfaceID iid,
TYPE *  iface 
) [inline]

Standard constructor with initialisation.

Definition at line 127 of file SmartIF.h.

00127                                                : SmartIFBase<TYPE>(iid)    {
00128     SmartIF<TYPE>::operator=(iface);
00129   }

template<class TYPE>
SmartIF< TYPE >::SmartIF ( const InterfaceID iid  )  [inline]

Standard constructor with initialisation.

Definition at line 131 of file SmartIF.h.

00131                                   : SmartIFBase<TYPE>(iid)    {
00132   }

template<class TYPE>
SmartIF< TYPE >::SmartIF ( TYPE *  iface  )  [inline]

Standard constructor with initialisation.

Definition at line 134 of file SmartIF.h.

00134                           : SmartIFBase<TYPE>(TYPE::interfaceID())    {
00135     SmartIF<TYPE>::operator=(iface);
00136   }

template<class TYPE>
SmartIF< TYPE >::SmartIF ( IInterface iface = 0  )  [inline]

Standard constructor with initialisation.

Definition at line 138 of file SmartIF.h.

00138                                  : SmartIFBase<TYPE>(TYPE::interfaceID())    {
00139     SmartIF<TYPE>::operator=(iface);
00140   }

template<class TYPE>
SmartIF< TYPE >::SmartIF ( const SmartIF< TYPE > &  copy  )  [inline]

Copy constructor.

Definition at line 142 of file SmartIF.h.

00142                                       : SmartIFBase<TYPE>(copy.m_iid)  {
00143     SmartIF<TYPE>::operator=(copy.m_interface);
00144   }

template<class TYPE>
virtual SmartIF< TYPE >::~SmartIF (  )  [inline, virtual]

Standard destructor.

Definition at line 146 of file SmartIF.h.

00146                         {
00147   }


Member Function Documentation

template<class TYPE>
SmartIF<TYPE>& SmartIF< TYPE >::operator= ( int   )  [inline]

Simple assignment operator.

Definition at line 149 of file SmartIF.h.

00149                                                    {
00150     this->releaseInterface();
00151     this->m_interface = 0;
00152     return *this;
00153   }

template<class TYPE>
template<class T>
SmartIF<TYPE>& SmartIF< TYPE >::operator= ( const SmartIF< T > &  iface  )  [inline]

Copy assignment operator with conversion to requested interface type.

Definition at line 156 of file SmartIF.h.

00157   {
00158     T* ptr = iface.m_interface ;
00159     if ( (void*)ptr != (void*)this->m_interface )
00160     {
00161       TYPE* newIF = 0;
00162       if ( ptr != 0 )   {
00163         ptr->queryInterface(this->m_iid, pp_cast<void>(&newIF)).ignore();
00164       }
00165       this->releaseInterface();
00166       this->m_interface = newIF;
00167     }
00168     return *this;
00169   }

template<class TYPE>
SmartIF<TYPE>& SmartIF< TYPE >::operator= ( const SmartIF< TYPE > &  iface  )  [inline]

Copy assignment operator.

Definition at line 171 of file SmartIF.h.

00172   {
00173     TYPE* newIF = iface.m_interface ;
00174     return (*this)=newIF ;
00175   }

template<class TYPE>
SmartIF& SmartIF< TYPE >::operator= ( IInterface iface  )  [inline]

Assignment operator with conversion to requested interface type.

Definition at line 177 of file SmartIF.h.

00178   {
00179     if ( iface != this->m_interface )
00180     {
00181       TYPE* newIF = 0;
00182       if ( iface != 0 )   {
00183         iface->queryInterface(this->m_iid, pp_cast<void>(&newIF)).ignore();
00184       }
00185       this->releaseInterface();
00186       this->m_interface = newIF;
00187     }
00188     return *this;
00189   }

template<class TYPE>
SmartIF<TYPE>& SmartIF< TYPE >::operator= ( TYPE *  iface  )  [inline]

Simple assignment operator.

Definition at line 191 of file SmartIF.h.

00192   {
00193     if ( iface != this->m_interface )   {
00194       if ( iface != 0 )   {
00195         iface->addRef();
00196       }
00197       this->releaseInterface();
00198       this->m_interface = iface;
00199     }
00200     return *this;
00201   }

template<class TYPE>
bool SmartIF< TYPE >::operator! (  )  const [inline]

check the validity of the interface

Reimplemented from SmartIFBase< TYPE >.

Definition at line 203 of file SmartIF.h.

00203 { return !(this->isValid()) ; }

template<class TYPE>
void SmartIFBase< TYPE >::releaseInterface (  )  [inline, protected, inherited]

Release interface.

Definition at line 36 of file SmartIF.h.

00036                             {
00037     if ( m_interface ) m_interface->release();
00038     m_interface = 0;
00039   }

template<class TYPE>
bool SmartIFBase< TYPE >::isValid (  )  const [inline, inherited]

Allow for check if smart pointer is valid.

Definition at line 49 of file SmartIF.h.

00049                            {
00050     return ( 0 != m_interface );
00051   }

template<class TYPE>
SmartIFBase< TYPE >::operator TYPE * (  )  [inline, inherited]

Automatic conversion to constined interface type.

Definition at line 53 of file SmartIF.h.

00053                       {
00054     return m_interface;
00055   }

template<class TYPE>
SmartIFBase< TYPE >::operator const TYPE * (  )  const [inline, inherited]

Automatic conversion to constined interface type (CONST).

Definition at line 57 of file SmartIF.h.

00057                                   {
00058     return m_interface;
00059   }

template<class TYPE>
bool SmartIFBase< TYPE >::operator!= ( const TYPE *  test  )  const [inline, inherited]

Check for non-equality.

Definition at line 61 of file SmartIF.h.

00061                                                {
00062     return test != m_interface;
00063   }

template<class TYPE>
bool SmartIFBase< TYPE >::operator== ( const TYPE *  test  )  const [inline, inherited]

Check for equality.

Definition at line 65 of file SmartIF.h.

00065                                                {
00066     return test == m_interface;
00067   }

template<class TYPE>
TYPE* SmartIFBase< TYPE >::operator-> (  )  [inline, inherited]

Dereference operator.

Definition at line 69 of file SmartIF.h.

00069                         {
00070     return m_interface;
00071   }

template<class TYPE>
const TYPE* SmartIFBase< TYPE >::operator-> (  )  const [inline, inherited]

Dereference operator (CONST).

Definition at line 73 of file SmartIF.h.

00073                                    {
00074     return m_interface;
00075   }

template<class TYPE>
void** SmartIFBase< TYPE >::operator & (  )  [inline, inherited]

Allow for use as void pointer.

Definition at line 77 of file SmartIF.h.

00077                          {
00078     return (void**) &m_interface;
00079   }

template<class TYPE>
const TYPE* SmartIFBase< TYPE >::get (  )  [inline, inherited]

Get reference to interface pointer.

Definition at line 81 of file SmartIF.h.

00081                     {
00082     return m_interface;
00083   }

template<class TYPE>
TYPE*& SmartIFBase< TYPE >::pRef (  )  [inline, inherited]

Get reference to interface pointer.

Definition at line 85 of file SmartIF.h.

00085                 {
00086     return this->m_interface;
00087   }

template<class TYPE>
const TYPE* const& SmartIFBase< TYPE >::pRef (  )  const [inline, inherited]

Get reference to interface pointer (CONST).

Definition at line 89 of file SmartIF.h.

00089                                     {
00090     return this->m_interface;
00091   }


Member Data Documentation

template<class TYPE>
const InterfaceID SmartIFBase< TYPE >::m_iid [protected, inherited]

Definition at line 33 of file SmartIF.h.

template<class TYPE>
TYPE* SmartIFBase< TYPE >::m_interface [protected, inherited]

Definition at line 34 of file SmartIF.h.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 19:57:14 2011 for GaudiKernel by doxygen 1.4.7