LibreOffice Module framework (master) 1
Public Member Functions | Private Attributes | List of all members
framework::ActionLockGuard Class Referencefinal

implements a guard, which can use the interface <type scope="css::document">XActionLockable</type>. More...

#include <actionlockguard.hxx>

Public Member Functions

 ActionLockGuard ()
 default ctor to initialize a "non working guard". More...
 
 ~ActionLockGuard ()
 release this guard instance and make sure, that no lock will exist afterwards on the internal wrapped resource. More...
 
bool setResource (const css::uno::Reference< css::document::XActionLockable > &xLock)
 set a new resource for locking at this guard. More...
 
void freeResource ()
 set a new resource for locking at this guard. More...
 
void unlock ()
 unlock the internal wrapped resource, if it's not already done. More...
 

Private Attributes

std::mutex m_mutex
 
css::uno::Reference< css::document::XActionLockable > m_xActionLock
 points to the object, which can be locked from outside. More...
 
bool m_bActionLocked
 knows if a lock exists on the internal lock object forced by this guard instance. More...
 

Detailed Description

implements a guard, which can use the interface <type scope="css::document">XActionLockable</type>.

@descr This guard should be used to be sure, that any lock will be released. Otherwise the locked document can hinder the office on shutdown!

Definition at line 33 of file actionlockguard.hxx.

Constructor & Destructor Documentation

◆ ActionLockGuard()

framework::ActionLockGuard::ActionLockGuard ( )
inline

default ctor to initialize a "non working guard".

@descr That can be useful in cases, where no resource still exists, but will be available next time. Then this guard can be used in a mode "use guard for more than one resources".

Definition at line 58 of file actionlockguard.hxx.

◆ ~ActionLockGuard()

framework::ActionLockGuard::~ActionLockGuard ( )
inline

release this guard instance and make sure, that no lock will exist afterwards on the internal wrapped resource.

Definition at line 66 of file actionlockguard.hxx.

References unlock().

Member Function Documentation

◆ freeResource()

void framework::ActionLockGuard::freeResource ( )
inline

set a new resource for locking at this guard.

@descr This call will fail, if an internal resource already exists and is currently locked.

Parameters
xLockpoints to the outside resource, which should be locked.
Returns
sal_True, if new resource could be set and locked. sal_False otherwise.

Definition at line 107 of file actionlockguard.hxx.

References m_bActionLocked, m_mutex, and m_xActionLock.

Referenced by framework::LoadEnv::impl_reactForLoadingState().

◆ setResource()

bool framework::ActionLockGuard::setResource ( const css::uno::Reference< css::document::XActionLockable > &  xLock)
inline

set a new resource for locking at this guard.

@descr This call will fail, if an internal resource already exists and is currently locked.

Parameters
xLockpoints to the outside resource, which should be locked.
Returns
sal_True, if new resource could be set and locked. sal_False otherwise.

Definition at line 82 of file actionlockguard.hxx.

References m_bActionLocked, m_mutex, and m_xActionLock.

Referenced by framework::LoadEnv::impl_loadContent(), and framework::LoadEnv::impl_searchRecycleTarget().

◆ unlock()

void framework::ActionLockGuard::unlock ( )
inline

unlock the internal wrapped resource, if it's not already done.

Definition at line 126 of file actionlockguard.hxx.

References m_bActionLocked, m_mutex, and m_xActionLock.

Referenced by ~ActionLockGuard().

Member Data Documentation

◆ m_bActionLocked

bool framework::ActionLockGuard::m_bActionLocked
private

knows if a lock exists on the internal lock object forced by this guard instance.

Definition at line 46 of file actionlockguard.hxx.

Referenced by freeResource(), setResource(), and unlock().

◆ m_mutex

std::mutex framework::ActionLockGuard::m_mutex
private

Definition at line 39 of file actionlockguard.hxx.

Referenced by freeResource(), setResource(), and unlock().

◆ m_xActionLock

css::uno::Reference< css::document::XActionLockable > framework::ActionLockGuard::m_xActionLock
private

points to the object, which can be locked from outside.

Definition at line 42 of file actionlockguard.hxx.

Referenced by freeResource(), setResource(), and unlock().


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