LibreOffice Module unotools (master) 1
|
is a helper class for sharing ownership of a UNO component More...
#include <sharedunocomponent.hxx>
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< Component > | m_xComponent |
css::uno::Reference< INTERFACE > | m_xTypedComponent |
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.
INTERFACE | the UNO interface type as which the component should be held |
COMPONENT_HOLDER | a 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.
|
private |
Definition at line 139 of file sharedunocomponent.hxx.
enum utl::SharedUNOComponent::AssignmentMode |
Enumerator | |
---|---|
TakeOwnership | |
NoTakeOwnership |
Definition at line 146 of file sharedunocomponent.hxx.
|
inline |
Definition at line 153 of file sharedunocomponent.hxx.
|
inlineexplicit |
Definition at line 157 of file sharedunocomponent.hxx.
References eMode, and utl::SharedUNOComponent< INTERFACE, COMPONENT >::reset().
|
inline |
Definition at line 162 of file sharedunocomponent.hxx.
References utl::SharedUNOComponent< INTERFACE, COMPONENT >::set().
|
inline |
Definition at line 203 of file sharedunocomponent.hxx.
References utl::SharedUNOComponent< INTERFACE, COMPONENT >::m_xComponent, and utl::SharedUNOComponent< INTERFACE, COMPONENT >::m_xTypedComponent.
|
inline |
Definition at line 193 of file sharedunocomponent.hxx.
References utl::SharedUNOComponent< INTERFACE, COMPONENT >::m_xTypedComponent.
Referenced by utl::operator==().
|
inline |
Definition at line 198 of file sharedunocomponent.hxx.
References utl::SharedUNOComponent< INTERFACE, COMPONENT >::m_xTypedComponent.
|
inline |
Definition at line 188 of file sharedunocomponent.hxx.
INTERFACE *SAL_CALL utl::SharedUNOComponent< INTERFACE, COMPONENT >::operator-> |
Definition at line 211 of file sharedunocomponent.hxx.
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().
|
inline |
Definition at line 259 of file sharedunocomponent.hxx.
Referenced by utl::SharedUNOComponent< INTERFACE, COMPONENT >::set(), and utl::SharedUNOComponent< INTERFACE, COMPONENT >::SharedUNOComponent().
|
inline |
Definition at line 239 of file sharedunocomponent.hxx.
|
inline |
Definition at line 245 of file sharedunocomponent.hxx.
|
inline |
Definition at line 251 of file sharedunocomponent.hxx.
References utl::SharedUNOComponent< INTERFACE, COMPONENT >::set().
|
private |
Definition at line 142 of file sharedunocomponent.hxx.
Referenced by utl::SharedUNOComponent< INTERFACE, COMPONENT >::clear().
|
private |
Definition at line 143 of file sharedunocomponent.hxx.
Referenced by utl::SharedUNOComponent< INTERFACE, COMPONENT >::clear(), utl::SharedUNOComponent< INTERFACE, COMPONENT >::getTyped(), utl::SharedUNOComponent< INTERFACE, COMPONENT >::is(), and utl::SharedUNOComponent< css::embed::XStorage >::operator const css::uno::Reference< css::embed::XStorage > &().