1 #ifndef GAUDI_SMARTIF_H 2 #define GAUDI_SMARTIF_H 1 33 template <
class OTHER>
35 if ( ptr )
reset( ptr );
47 rhs.m_interface =
nullptr;
64 inline explicit operator bool()
const {
return isValid(); }
77 #if !defined( GAUDI_V22_API ) && !defined( NEW_SMARTIF ) 86 inline void reset( TYPE* ptr =
nullptr ) {
94 template <
class OTHER>
95 inline void reset( OTHER* ptr ) {
96 if ( static_cast<IInterface*>( ptr ) == static_cast<IInterface*>(
m_interface ) )
return;
99 ptr->queryInterface( TYPE::interfaceID(), pp_cast<void>( &
m_interface ) ).ignore();
106 template <
typename IFace>
139 template <
typename IFace>
144 #endif // GAUDI_SMARTIF_H SmartIF(SmartIF &&rhs)
Move constructor.
Small smart pointer class with automatic reference counting for IInterface.
void reset(OTHER *ptr)
Set the internal pointer to the passed one disposing of the old one.
~SmartIF()
Standard Destructor.
bool isValid() const
Allow for check if smart pointer is valid.
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
TYPE * get() const
Get interface pointer.
SmartIF()=default
Default constructor.
TYPE * m_interface
Pointer to the instance.
SmartIF & operator=(IInterface *ptr)
Assignment operator from IInterface pointer.
Definition of the basic interface.
SmartIF & operator=(const SmartIF< T > &rhs)
Assignment operator from a different SmartIF.
SmartIF(const SmartIF &rhs)
Copy constructor.
TYPE & operator *() const
Dereference operator.
TYPE * operator->() const
Dereference operator.
SmartIF(TYPE *ptr)
Standard constructor from pointer.
SmartIF & operator=(const SmartIF &rhs)
Assignment operator.
SmartIF & operator=(SmartIF &&rhs)
Move assignement.
SmartIF(OTHER *ptr)
Standard constructor from any (IInterface-derived) pointer.
SmartIF(const SmartIF< T > &rhs)
Constructor from another SmartIF, with a different type.
SmartIF< IFace > make_SmartIF(IFace *iface)
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
TYPE *& pRef()
Get reference to the pointer.