LibreOffice Module unotools (master) 1
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
utl::SharedUNOComponent< INTERFACE, COMPONENT > Class Template Reference

is a helper class for sharing ownership of a UNO component More...

#include <sharedunocomponent.hxx>

Inheritance diagram for utl::SharedUNOComponent< INTERFACE, COMPONENT >:
[legend]

Public Types

enum  AssignmentMode {
  TakeOwnership ,
  NoTakeOwnership
}
 

Public Member Functions

 SharedUNOComponent ()
 
 SharedUNOComponent (const css::uno::Reference< INTERFACE > &_rxComponent, AssignmentMode eMode=TakeOwnership)
 
 SharedUNOComponent (const css::uno::BaseReference &_rRef, css::uno::UnoReference_QueryThrow _queryThrow)
 
void reset (const css::uno::Reference< INTERFACE > &_rxComponent, AssignmentMode _eMode=TakeOwnership)
 assigns a new component, and releases the old one More...
 
bool set (const css::uno::BaseReference &_rRef, css::uno::UnoReference_Query _query)
 
void set (const css::uno::BaseReference &_rRef, css::uno::UnoReference_QueryThrow _queryThrow)
 
void set (const css::uno::Reference< INTERFACE > &_rRef, css::uno::UnoReference_SetThrow _setThrow)
 
void set (const SharedUNOComponent &_rComp, css::uno::UnoReference_SetThrow _setThrow)
 
INTERFACE *SAL_CALL operator-> () const
 
 operator const css::uno::Reference< INTERFACE > & () const
 
const css::uno::Reference< INTERFACE > & getTyped () const
 
bool is () const
 
void clear ()
 

Private Types

typedef COMPONENT Component
 

Private Attributes

std::shared_ptr< Componentm_xComponent
 
css::uno::Reference< INTERFACE > m_xTypedComponent
 

Detailed Description

template<class INTERFACE, class COMPONENT = DisposableComponent>
class utl::SharedUNOComponent< INTERFACE, COMPONENT >

is a helper class for sharing ownership of a UNO component

If you need to share a UNO component, which normally needs a dedicated owner, and is lifetime controlled by an explicit disposal action (not necessarily ->XComponent::dispose, but any explicit method call, after which the object is considered to be disposed), between different classes, ->SharedUNOComponent is what you need.

Instead of passing around a Reference< XFoo >, and bothering with ownership and disposal, you just use a SharedUNOComponent< XFoo >. This instance can be passed around, including copying, and in nearly all respects behaves like the original Reference< XFoo >. However, when the last ->SharedUNOComponent referencing a certain Reference< XFoo > dies, it will automatically get rid of the object held by this reference.

Parameters
INTERFACEthe UNO interface type as which the component should be held
COMPONENT_HOLDERa class which can be used to represent and dispose a UNO component. The class must support (maybe explicit only) construction from a Reference< INTERFACE >, and destruction. Upon destruction, the class must dispose (by any suitable means) the component instance it was constructed with.

Definition at line 136 of file sharedunocomponent.hxx.

Member Typedef Documentation

◆ Component

template<class INTERFACE , class COMPONENT = DisposableComponent>
typedef COMPONENT utl::SharedUNOComponent< INTERFACE, COMPONENT >::Component
private

Definition at line 139 of file sharedunocomponent.hxx.

Member Enumeration Documentation

◆ AssignmentMode

template<class INTERFACE , class COMPONENT = DisposableComponent>
enum utl::SharedUNOComponent::AssignmentMode
Enumerator
TakeOwnership 
NoTakeOwnership 

Definition at line 146 of file sharedunocomponent.hxx.

Constructor & Destructor Documentation

◆ SharedUNOComponent() [1/3]

template<class INTERFACE , class COMPONENT = DisposableComponent>
utl::SharedUNOComponent< INTERFACE, COMPONENT >::SharedUNOComponent ( )
inline

Definition at line 153 of file sharedunocomponent.hxx.

◆ SharedUNOComponent() [2/3]

template<class INTERFACE , class COMPONENT = DisposableComponent>
utl::SharedUNOComponent< INTERFACE, COMPONENT >::SharedUNOComponent ( const css::uno::Reference< INTERFACE > &  _rxComponent,
AssignmentMode  eMode = TakeOwnership 
)
inlineexplicit

◆ SharedUNOComponent() [3/3]

template<class INTERFACE , class COMPONENT = DisposableComponent>
utl::SharedUNOComponent< INTERFACE, COMPONENT >::SharedUNOComponent ( const css::uno::BaseReference &  _rRef,
css::uno::UnoReference_QueryThrow  _queryThrow 
)
inline

Member Function Documentation

◆ clear()

template<class INTERFACE , class COMPONENT = DisposableComponent>
void utl::SharedUNOComponent< INTERFACE, COMPONENT >::clear ( )
inline

◆ getTyped()

template<class INTERFACE , class COMPONENT = DisposableComponent>
const css::uno::Reference< INTERFACE > & utl::SharedUNOComponent< INTERFACE, COMPONENT >::getTyped ( ) const
inline

◆ is()

template<class INTERFACE , class COMPONENT = DisposableComponent>
bool utl::SharedUNOComponent< INTERFACE, COMPONENT >::is ( ) const
inline

◆ operator const css::uno::Reference< INTERFACE > &()

template<class INTERFACE , class COMPONENT = DisposableComponent>
utl::SharedUNOComponent< INTERFACE, COMPONENT >::operator const css::uno::Reference< INTERFACE > & ( ) const
inline

Definition at line 188 of file sharedunocomponent.hxx.

◆ operator->()

template<class INTERFACE , class COMPONENT >
INTERFACE *SAL_CALL utl::SharedUNOComponent< INTERFACE, COMPONENT >::operator->

Definition at line 211 of file sharedunocomponent.hxx.

◆ reset()

template<class INTERFACE , class COMPONENT >
void utl::SharedUNOComponent< INTERFACE, COMPONENT >::reset ( const css::uno::Reference< INTERFACE > &  _rxComponent,
AssignmentMode  _eMode = TakeOwnership 
)

assigns a new component, and releases the old one

Definition at line 218 of file sharedunocomponent.hxx.

Referenced by utl::SharedUNOComponent< INTERFACE, COMPONENT >::SharedUNOComponent().

◆ set() [1/4]

template<class INTERFACE , class COMPONENT >
bool utl::SharedUNOComponent< INTERFACE, COMPONENT >::set ( const css::uno::BaseReference &  _rRef,
css::uno::UnoReference_Query  _query 
)
inline

◆ set() [2/4]

template<class INTERFACE , class COMPONENT >
void utl::SharedUNOComponent< INTERFACE, COMPONENT >::set ( const css::uno::BaseReference &  _rRef,
css::uno::UnoReference_QueryThrow  _queryThrow 
)
inline

Definition at line 239 of file sharedunocomponent.hxx.

◆ set() [3/4]

template<class INTERFACE , class COMPONENT >
void utl::SharedUNOComponent< INTERFACE, COMPONENT >::set ( const css::uno::Reference< INTERFACE > &  _rRef,
css::uno::UnoReference_SetThrow  _setThrow 
)
inline

Definition at line 245 of file sharedunocomponent.hxx.

◆ set() [4/4]

template<class INTERFACE , class COMPONENT >
void utl::SharedUNOComponent< INTERFACE, COMPONENT >::set ( const SharedUNOComponent< INTERFACE, COMPONENT > &  _rComp,
css::uno::UnoReference_SetThrow  _setThrow 
)
inline

Member Data Documentation

◆ m_xComponent

template<class INTERFACE , class COMPONENT = DisposableComponent>
std::shared_ptr<Component> utl::SharedUNOComponent< INTERFACE, COMPONENT >::m_xComponent
private

◆ m_xTypedComponent

template<class INTERFACE , class COMPONENT = DisposableComponent>
css::uno::Reference< INTERFACE > utl::SharedUNOComponent< INTERFACE, COMPONENT >::m_xTypedComponent
private

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