| # Gaudi Framework, version v20r3
Generated: 24 Nov 2008

# SmartIF< TYPE > Class Template Reference

`#include <GaudiKernel/SmartIF.h>`

Inheritance diagram for SmartIF< TYPE >:

[legend]
Collaboration diagram for SmartIF< TYPE >:

[legend]

List of all members.

## Detailed Description

### template<class TYPE>
class SmartIF< TYPE >

Smart pointer to handle easily interfaces.

Smart pointer base class 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

Description: A small class to easy the use of Gaudi interfaces. This class acts as a base class for the specific instances SmartIF<TYPE>. The base class only defines operations on the valid smart pointer.

Dependencies:

- Gaudi Interface definition: Gaudi/Interfaces/IInterface.h

Author: M.Frank

Author:
  Sebastien Ponce

Definition at line 120 of file SmartIF.h.

## 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.
SmartIF & | operator= (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

## 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()) ; }

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r3/GaudiKernel/GaudiKernel/SmartIF.h