LibreOffice Module sd (master) 1
|
This is a helper class for the ConfigurationController. More...
#include <ConfigurationUpdater.hxx>
Public Member Functions | |
ConfigurationUpdater (std::shared_ptr< ConfigurationControllerBroadcaster > pBroadcaster, std::shared_ptr< ConfigurationControllerResourceManager > pResourceManager, const rtl::Reference<::sd::DrawController > &xControllerManager) | |
Create a new ConfigurationUpdater object that notifies configuration changes and the start and end of updates via the given broadcaster. More... | |
~ConfigurationUpdater () | |
void | RequestUpdate (const css::uno::Reference< css::drawing::framework::XConfiguration > &rxRequestedConfiguration) |
Request an update of the current configuration so that it looks like the given requested configuration. More... | |
const css::uno::Reference< css::drawing::framework::XConfiguration > & | GetCurrentConfiguration () const |
std::shared_ptr< ConfigurationUpdaterLock > | GetLock () |
Return a lock of the called ConfigurationUpdater. More... | |
Private Member Functions | |
void | UpdateConfiguration () |
This method does the main work of an update. More... | |
void | UpdateCore (const ConfigurationClassifier &rClassifier) |
Basically calls UpdaterStart() andUpdateEnd() and makes some debug output. More... | |
void | CheckPureAnchors (const css::uno::Reference< css::drawing::framework::XConfiguration > &rxConfiguration, ::std::vector< css::uno::Reference< css::drawing::framework::XResourceId > > &rResourcesToDeactivate) |
Check for all pure anchors if they have at least one child. More... | |
void | CleanRequestedConfiguration () |
Remove from the requested configuration all pure anchors that have no child. More... | |
void | CheckUpdateSuccess () |
Check the success of a recently executed configuration update. More... | |
void | SetUpdateBeingProcessed (bool bValue) |
This method sets the mbUpdateBeingProcessed member that is used to prevent reentrance problems. More... | |
bool | IsUpdatePossible () const |
Return whether it is possible to do an update of the configuration. More... | |
void | LockUpdates () |
Lock updates of the current configuration. More... | |
void | UnlockUpdates () |
When an update was requested since the last LockUpdates() call then RequestUpdate() is called. More... | |
DECL_LINK (TimeoutHandler, Timer *, void) | |
Private Attributes | |
rtl::Reference<::sd::DrawController > | mxControllerManager |
A reference to the XControllerManager is kept so that UpdateConfiguration() has access to the other sub controllers. More... | |
std::shared_ptr< ConfigurationControllerBroadcaster > | mpBroadcaster |
css::uno::Reference< css::drawing::framework::XConfiguration > | mxCurrentConfiguration |
The current configuration holds the resources that are currently active. More... | |
css::uno::Reference< css::drawing::framework::XConfiguration > | mxRequestedConfiguration |
The requested configuration holds the resources that have been requested to activate or to deactivate since the last update. More... | |
bool | mbUpdatePending |
This flag is set to </sal_True> when an update of the current configuration was requested (because the last request in the queue was processed) but could not be executed because the ConfigurationController was locked. More... | |
bool | mbUpdateBeingProcessed |
This flag is set to </sal_True> while the UpdateConfiguration() method is running. More... | |
sal_Int32 | mnLockCount |
The ConfigurationController is locked when this count has a value larger then zero. More... | |
Timer | maUpdateTimer |
This timer is used to check from time to time whether the requested configuration and the current configuration are identical and request an update when they are not. More... | |
sal_Int32 | mnFailedUpdateCount |
The number of failed updates (those after which the current configuration is not equivalent to the requested configuration) is used to determine how long to wait before another update is made. More... | |
std::shared_ptr< ConfigurationControllerResourceManager > | mpResourceManager |
Friends | |
class | ConfigurationUpdaterLock |
This is a helper class for the ConfigurationController.
It handles the update of the current configuration so that it looks like a requested configuration. An update is made by activating or deactivating drawing framework resources.
When an update is not successful, i.e. after the update the current configuration is not equivalent to the requested configuration, then a timer is started to repeat the update after a short time.
Definition at line 61 of file ConfigurationUpdater.hxx.
sd::framework::ConfigurationUpdater::ConfigurationUpdater | ( | std::shared_ptr< ConfigurationControllerBroadcaster > | pBroadcaster, |
std::shared_ptr< ConfigurationControllerResourceManager > | pResourceManager, | ||
const rtl::Reference<::sd::DrawController > & | xControllerManager | ||
) |
Create a new ConfigurationUpdater object that notifies configuration changes and the start and end of updates via the given broadcaster.
Definition at line 66 of file ConfigurationUpdater.cxx.
References LINK, maUpdateTimer, mxControllerManager, Reference, Timer::SetInvokeHandler(), and Timer::SetTimeout().
sd::framework::ConfigurationUpdater::~ConfigurationUpdater | ( | ) |
Definition at line 87 of file ConfigurationUpdater.cxx.
References maUpdateTimer, and Task::Stop().
|
private |
Check for all pure anchors if they have at least one child.
Childless pure anchors are deactivated. This affects only the current configuration.
Definition at line 271 of file ConfigurationUpdater.cxx.
References mpResourceManager, nCount, nIndex, sd::framework::FrameworkHelper::ResourceIdToString(), and SAL_INFO.
Referenced by CleanRequestedConfiguration(), and UpdateCore().
|
private |
Check the success of a recently executed configuration update.
When the update failed then start the timer.
Definition at line 209 of file ConfigurationUpdater.cxx.
References sd::framework::AreConfigurationsEquivalent(), maUpdateTimer, mnFailedUpdateCount, mxCurrentConfiguration, mxRequestedConfiguration, Timer::SetTimeout(), and Timer::Start().
Referenced by UpdateConfiguration().
|
private |
Remove from the requested configuration all pure anchors that have no child.
Requested but not yet activated anchors can not be removed because without the actual resource the 'pureness' of an anchor can not be determined.
Definition at line 191 of file ConfigurationUpdater.cxx.
References CheckPureAnchors(), mxControllerManager, and mxRequestedConfiguration.
Referenced by UpdateConfiguration().
|
private |
|
inline |
Definition at line 82 of file ConfigurationUpdater.hxx.
References mxCurrentConfiguration.
std::shared_ptr< ConfigurationUpdaterLock > sd::framework::ConfigurationUpdater::GetLock | ( | ) |
Return a lock of the called ConfigurationUpdater.
While the returned object exists no update of the current configuration is made.
Definition at line 353 of file ConfigurationUpdater.cxx.
|
private |
Return whether it is possible to do an update of the configuration.
This takes into account whether another update is currently being executed, the lock count, and whether the configuration controller is still valid.
Definition at line 117 of file ConfigurationUpdater.cxx.
References mbUpdateBeingProcessed, mnLockCount, mxControllerManager, mxCurrentConfiguration, and mxRequestedConfiguration.
Referenced by RequestUpdate().
|
private |
Lock updates of the current configuration.
For intermediate requests for updates mbUpdatePending is set to <TRUE>.
Definition at line 339 of file ConfigurationUpdater.cxx.
References mnLockCount.
Referenced by sd::framework::ConfigurationUpdaterLock::ConfigurationUpdaterLock().
void sd::framework::ConfigurationUpdater::RequestUpdate | ( | const css::uno::Reference< css::drawing::framework::XConfiguration > & | rxRequestedConfiguration | ) |
Request an update of the current configuration so that it looks like the given requested configuration.
It checks whether an update of the current configuration can be done. Calls UpdateConfiguration() if that is the case. Otherwise it schedules a later call to UpdateConfiguration().
Definition at line 92 of file ConfigurationUpdater.cxx.
References IsUpdatePossible(), mbUpdatePending, mxRequestedConfiguration, SAL_INFO, and UpdateConfiguration().
Referenced by UnlockUpdates().
|
private |
This method sets the mbUpdateBeingProcessed member that is used to prevent reentrance problems.
This method allows function objects easily and safely to modify the variable.
Definition at line 358 of file ConfigurationUpdater.cxx.
References mbUpdateBeingProcessed.
Referenced by UpdateConfiguration().
|
private |
When an update was requested since the last LockUpdates() call then RequestUpdate() is called.
Definition at line 344 of file ConfigurationUpdater.cxx.
References mbUpdatePending, mnLockCount, mxRequestedConfiguration, and RequestUpdate().
Referenced by sd::framework::ConfigurationUpdaterLock::~ConfigurationUpdaterLock().
|
private |
This method does the main work of an update.
It calls the sub controllers that are responsible for the various types of resources and tells them to update their active resources. It notifies listeners about the start and end of the configuration update.
Definition at line 126 of file ConfigurationUpdater.cxx.
References aEvent, CheckUpdateSuccess(), CleanRequestedConfiguration(), DBG_UNHANDLED_EXCEPTION, mbUpdatePending, mnLockCount, mpBroadcaster, sd::framework::FrameworkHelper::msConfigurationUpdateEndEvent, sd::framework::FrameworkHelper::msConfigurationUpdateStartEvent, mxCurrentConfiguration, mxRequestedConfiguration, sd::framework::ConfigurationClassifier::Partition(), SAL_INFO, SetUpdateBeingProcessed(), sd::framework::ConfigurationTracer::TraceConfiguration(), and UpdateCore().
Referenced by RequestUpdate().
|
private |
Basically calls UpdaterStart() andUpdateEnd() and makes some debug output.
Definition at line 231 of file ConfigurationUpdater.cxx.
References CheckPureAnchors(), DBG_UNHANDLED_EXCEPTION, sd::framework::ConfigurationClassifier::GetC1minusC2(), sd::framework::ConfigurationClassifier::GetC2minusC1(), mpResourceManager, mxCurrentConfiguration, mxRequestedConfiguration, SAL_INFO, and sd::framework::ConfigurationTracer::TraceConfiguration().
Referenced by UpdateConfiguration().
|
friend |
Definition at line 87 of file ConfigurationUpdater.hxx.
|
private |
This timer is used to check from time to time whether the requested configuration and the current configuration are identical and request an update when they are not.
This is used to overcome problems with resources that become available asynchronously.
Definition at line 141 of file ConfigurationUpdater.hxx.
Referenced by CheckUpdateSuccess(), ConfigurationUpdater(), and ~ConfigurationUpdater().
|
private |
This flag is set to </sal_True> while the UpdateConfiguration() method is running.
It is used to prevent reentrance problems with this method.
Definition at line 127 of file ConfigurationUpdater.hxx.
Referenced by IsUpdatePossible(), and SetUpdateBeingProcessed().
|
private |
This flag is set to </sal_True> when an update of the current configuration was requested (because the last request in the queue was processed) but could not be executed because the ConfigurationController was locked.
A call to UpdateConfiguration() resets the flag to </sal_False>.
Definition at line 121 of file ConfigurationUpdater.hxx.
Referenced by RequestUpdate(), UnlockUpdates(), and UpdateConfiguration().
|
private |
The number of failed updates (those after which the current configuration is not equivalent to the requested configuration) is used to determine how long to wait before another update is made.
Definition at line 147 of file ConfigurationUpdater.hxx.
Referenced by CheckUpdateSuccess().
|
private |
The ConfigurationController is locked when this count has a value larger then zero.
If the controller is locked then updates of the current configuration are not made.
Definition at line 133 of file ConfigurationUpdater.hxx.
Referenced by IsUpdatePossible(), LockUpdates(), UnlockUpdates(), and UpdateConfiguration().
|
private |
Definition at line 100 of file ConfigurationUpdater.hxx.
Referenced by UpdateConfiguration().
|
private |
Definition at line 149 of file ConfigurationUpdater.hxx.
Referenced by CheckPureAnchors(), and UpdateCore().
|
private |
A reference to the XControllerManager is kept so that UpdateConfiguration() has access to the other sub controllers.
Definition at line 98 of file ConfigurationUpdater.hxx.
Referenced by CleanRequestedConfiguration(), ConfigurationUpdater(), and IsUpdatePossible().
|
private |
The current configuration holds the resources that are currently active.
It is modified during an update.
Definition at line 105 of file ConfigurationUpdater.hxx.
Referenced by CheckUpdateSuccess(), GetCurrentConfiguration(), IsUpdatePossible(), UpdateConfiguration(), and UpdateCore().
|
private |
The requested configuration holds the resources that have been requested to activate or to deactivate since the last update.
It is (usually) not modified during an update. This configuration is maintained by the ConfigurationController and given to the ConfigurationUpdater in the RequestUpdate() method.
Definition at line 113 of file ConfigurationUpdater.hxx.
Referenced by CheckUpdateSuccess(), CleanRequestedConfiguration(), IsUpdatePossible(), RequestUpdate(), UnlockUpdates(), UpdateConfiguration(), and UpdateCore().