LCOV - code coverage report
Current view: top level - sd/source/ui/framework/configuration - ConfigurationUpdater.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 1 0.0 %
Date: 2014-11-03 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_SD_SOURCE_UI_FRAMEWORK_CONFIGURATION_CONFIGURATIONUPDATER_HXX
      21             : #define INCLUDED_SD_SOURCE_UI_FRAMEWORK_CONFIGURATION_CONFIGURATIONUPDATER_HXX
      22             : 
      23             : #include "ConfigurationControllerResourceManager.hxx"
      24             : #include <com/sun/star/drawing/framework/XResourceId.hpp>
      25             : #include <com/sun/star/drawing/framework/XConfiguration.hpp>
      26             : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
      27             : #include <vcl/timer.hxx>
      28             : #include <vector>
      29             : #include <boost/shared_ptr.hpp>
      30             : 
      31             : namespace sd { namespace framework {
      32             : 
      33             : class ConfigurationClassifier;
      34             : class ConfigurationUpdaterLock;
      35             : 
      36             : /** This is a helper class for the ConfigurationController.  It handles the
      37             :     update of the current configuration so that it looks like a requested
      38             :     configuration.  An update is made by activating or deactivating drawing
      39             :     framework resources.
      40             : 
      41             :     When an update is not successful, i.e. after the update the current
      42             :     configuration is not equivalent to the requested configuration, then a
      43             :     timer is started to repeat the update after a short time.
      44             : */
      45             : class ConfigurationUpdater
      46             : {
      47             : public:
      48             :     /** Create a new ConfigurationUpdater object that notifies configuration
      49             :         changes and the start and end of updates via the given broadcaster.
      50             :     */
      51             :     ConfigurationUpdater (
      52             :         const ::boost::shared_ptr<ConfigurationControllerBroadcaster>& rpBroadcaster,
      53             :         const ::boost::shared_ptr<ConfigurationControllerResourceManager>& rpResourceManager,
      54             :         const css::uno::Reference<
      55             :             css::drawing::framework::XControllerManager>& rxControllerManager);
      56             :     ~ConfigurationUpdater (void);
      57             : 
      58             :     /** This method is typically called once, when the controller manager is
      59             :         accessible to the caller.
      60             :     */
      61             :     void SetControllerManager(
      62             :         const css::uno::Reference<
      63             :             css::drawing::framework::XControllerManager>& rxControllerManager);
      64             : 
      65             :     /** Request an update of the current configuration so that it looks like
      66             :         the given requested configuration.  It checks whether an update of
      67             :         the current configuration can be done.  Calls UpdateConfiguration()
      68             :         if that is the case.  Otherwise it schedules a later call to
      69             :         UpdateConfiguration().
      70             :     */
      71             :     void RequestUpdate (const css::uno::Reference<
      72             :         css::drawing::framework::XConfiguration>& rxRequestedConfiguration);
      73             : 
      74             :     css::uno::Reference<
      75           0 :         css::drawing::framework::XConfiguration> GetCurrentConfiguration (void) const { return mxCurrentConfiguration;}
      76             : 
      77             :     friend class ConfigurationUpdaterLock;
      78             :     /** Return a lock of the called ConfigurationUpdater.  While the
      79             :         returned object exists no update of the current configuration is
      80             :         made.
      81             :     */
      82             :     ::boost::shared_ptr<ConfigurationUpdaterLock> GetLock (void);
      83             : 
      84             : private:
      85             :     /** A reference to the XControllerManager is kept so that
      86             :         UpdateConfiguration() has access to the other sub controllers.
      87             :     */
      88             :     css::uno::Reference<
      89             :         css::drawing::framework::XControllerManager> mxControllerManager;
      90             : 
      91             :     ::boost::shared_ptr<ConfigurationControllerBroadcaster> mpBroadcaster;
      92             : 
      93             :     /** The current configuration holds the resources that are currently
      94             :         active.  It is modified during an update.
      95             :     */
      96             :     css::uno::Reference<
      97             :         css::drawing::framework::XConfiguration> mxCurrentConfiguration;
      98             : 
      99             :     /** The requested configuration holds the resources that have been
     100             :         requested to activate or to deactivate since the last update.  It is
     101             :         (usually) not modified during an update.  This configuration is
     102             :         maintained by the ConfigurationController and given to the
     103             :         ConfigurationUpdater in the RequestUpdate() method.
     104             :     */
     105             :     css::uno::Reference<
     106             :         css::drawing::framework::XConfiguration> mxRequestedConfiguration;
     107             : 
     108             :     /** This flag is set to </sal_True> when an update of the current
     109             :         configurtion was requested (because the last request in the queue
     110             :         was processed) but could not be exected because the
     111             :         ConfigurationController was locked.  A call to UpdateConfiguration()
     112             :         resets the flag to </sal_False>.
     113             :     */
     114             :     bool mbUpdatePending;
     115             : 
     116             :     /** This flag is set to </sal_True> while the UpdateConfiguration() method
     117             :         is running.  It is used to prevent reentrance problems with this
     118             :         method.
     119             :     */
     120             :     bool mbUpdateBeingProcessed;
     121             : 
     122             :     /** The ConfigurationController is locked when this count has a value
     123             :         larger then zero.  If the controller is locked then updates of the
     124             :         current configuration are not made.
     125             :     */
     126             :     sal_Int32 mnLockCount;
     127             : 
     128             :     /** This timer is used to check from time to time whether the requested
     129             :         configuration and the current configuration are identical and request
     130             :         an update when they are not.
     131             :         This is used to overcome problems with resources that become
     132             :         available asynchronously.
     133             :     */
     134             :     Timer maUpdateTimer;
     135             : 
     136             :     /** The number of failed updates (those after which the current
     137             :         configuration is not equivalent to the requested configuration) is
     138             :         used to determine how long to wait before another update is made.
     139             :     */
     140             :     sal_Int32 mnFailedUpdateCount;
     141             : 
     142             :     ::boost::shared_ptr<ConfigurationControllerResourceManager> mpResourceManager;
     143             : 
     144             :     /** This method does the main work of an update.  It calls the sub
     145             :         controllers that are responsible for the various types of resources
     146             :         and tells them to update their active resources.  It notifies
     147             :         listeners about the start and end of the configuration update.
     148             :     */
     149             :     void UpdateConfiguration (void);
     150             : 
     151             :     /** Basically calls UpdaterStart() andUpdateEnd() and makes some debug
     152             :         output.
     153             :     */
     154             :     void UpdateCore (const ConfigurationClassifier& rClassifier);
     155             : 
     156             :     /** Check for all pure anchors if they have at least one child.
     157             :         Childless pure anchors are deactivated.
     158             :         This affects only the current configuration.
     159             :     */
     160             :     void CheckPureAnchors (
     161             :         const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration,
     162             :         ::std::vector<css::uno::Reference<css::drawing::framework::XResourceId> >&
     163             :             rResourcesToDeactivate);
     164             : 
     165             :     /** Remove from the requested configuration all pure anchors that have no
     166             :         child.  Requested but not yet activated anchors can not be removed
     167             :         because without the actual resource the 'pureness' of an anchor can
     168             :         not be determined.
     169             :     */
     170             :     void CleanRequestedConfiguration (void);
     171             : 
     172             :     /** Check the success of a recently executed configuration update.
     173             :         When the update failed then start the timer.
     174             :     */
     175             :     void CheckUpdateSuccess (void);
     176             : 
     177             :     /** This method sets the mbUpdateBeingProcessed member that is used to
     178             :         prevent reentrance problems.  This method allows function objects
     179             :         easily and safely to modify the variable.
     180             :     */
     181             :     void SetUpdateBeingProcessed (bool bValue);
     182             : 
     183             :     /** Return whether it is possible to do an update of the configuration.
     184             :         This takes into account whether another update is currently being
     185             :         executed, the lock count, and whether the configuration controller
     186             :         is still valid.
     187             :     */
     188             :     bool IsUpdatePossible (void);
     189             : 
     190             :     /** Lock updates of the current configuration.  For intermediate requests
     191             :         for updates mbUpdatePending is set to <TRUE/>.
     192             :     */
     193             :     void LockUpdates (void);
     194             : 
     195             :     /** When an update was requested since the last LockUpdates() call then
     196             :         RequestUpdate() is called.
     197             :     */
     198             :     void UnlockUpdates (void);
     199             : 
     200             :     DECL_LINK(TimeoutHandler, void *);
     201             : };
     202             : 
     203             : } } // end of namespace sd::framework
     204             : 
     205             : #endif
     206             : 
     207             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10