LCOV - code coverage report
Current view: top level - sd/source/ui/framework/configuration - ConfigurationControllerResourceManager.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 1 100.0 %
Date: 2015-06-13 12:38:46 Functions: 4 4 100.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_CONFIGURATIONCONTROLLERRESOURCEMANAGER_HXX
      21             : #define INCLUDED_SD_SOURCE_UI_FRAMEWORK_CONFIGURATION_CONFIGURATIONCONTROLLERRESOURCEMANAGER_HXX
      22             : 
      23             : #include <com/sun/star/drawing/framework/XConfiguration.hpp>
      24             : #include <com/sun/star/drawing/framework/XResource.hpp>
      25             : #include <com/sun/star/drawing/framework/XResourceFactory.hpp>
      26             : #include <osl/mutex.hxx>
      27             : 
      28             : #include <boost/noncopyable.hpp>
      29             : #include <boost/shared_ptr.hpp>
      30             : #include <map>
      31             : #include <vector>
      32             : 
      33             : namespace sd { namespace framework {
      34             : 
      35             : class ConfigurationControllerBroadcaster;
      36             : class ResourceFactoryManager;
      37             : 
      38             : /** Manage the set of active resources.  Activate and deactivate resources.
      39             : */
      40             : class ConfigurationControllerResourceManager
      41             :     : ::boost::noncopyable
      42             : {
      43             : public:
      44             :     /** For every active resource both the resource itself as well as its
      45             :         creating factory are remembered, so that on deactivation, the
      46             :         resource can be deactivated by this factory.
      47             :     */
      48       24726 :     class ResourceDescriptor
      49             :     {
      50             :     public:
      51             :         css::uno::Reference<css::drawing::framework::XResource> mxResource;
      52             :         css::uno::Reference<css::drawing::framework::XResourceFactory> mxResourceFactory;
      53             :     };
      54             : 
      55             :     /** A new ResourceManager object is created with the resource factory
      56             :         container for creating resources and the event broadcaster for
      57             :         notifying ConfigurationChangeListeners of activated or deactivated
      58             :         resources.
      59             :     */
      60             :     ConfigurationControllerResourceManager (
      61             :         const ::boost::shared_ptr<ResourceFactoryManager>& rpResourceFactoryContainer,
      62             :         const ::boost::shared_ptr<ConfigurationControllerBroadcaster>& rpBroadcaster);
      63             : 
      64             :     ~ConfigurationControllerResourceManager();
      65             : 
      66             :     /** Activate all the resources that are specified by resource ids in
      67             :         rResources.  The resource ids of activated resources are added to
      68             :         the given configuration.  Activated resources are notified to all
      69             :         interested ConfigurationChangeListeners.
      70             :     */
      71             :     void ActivateResources (
      72             :         const ::std::vector<
      73             :             css::uno::Reference<css::drawing::framework::XResourceId> >& rResources,
      74             :         const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration);
      75             : 
      76             :     /** Deactivate all the resources that are specified by resource ids in
      77             :         rResources.  The resource ids of deactivated resources are removed
      78             :         from the given configuration.  Activated resources are notified to all
      79             :         interested ConfigurationChangeListeners.
      80             :     */
      81             :     void DeactivateResources (
      82             :         const ::std::vector<
      83             :             css::uno::Reference<css::drawing::framework::XResourceId> >& rResources,
      84             :         const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration);
      85             : 
      86             :     /** Return the descriptor for the specified resource.
      87             :         @return
      88             :             When there is no active resource for the given resource id then
      89             :             an empty descriptor is returned.
      90             :     */
      91             :     ResourceDescriptor GetResource (
      92             :         const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId);
      93             : 
      94             : private:
      95             :     osl::Mutex maMutex;
      96             : 
      97             :     class ResourceComparator
      98             :     {
      99             :     public:
     100             :         bool operator() (
     101             :             const css::uno::Reference<css::drawing::framework::XResourceId>& rxId1,
     102             :             const css::uno::Reference<css::drawing::framework::XResourceId>& rxId2) const;
     103             :     };
     104             : 
     105             :     typedef ::std::map<
     106             :         css::uno::Reference<css::drawing::framework::XResourceId>,
     107             :         ResourceDescriptor,
     108             :         ResourceComparator> ResourceMap;
     109             :     ResourceMap maResourceMap;
     110             : 
     111             :     ::boost::shared_ptr<ResourceFactoryManager> mpResourceFactoryContainer;
     112             : 
     113             :     /** This broadcaster is used to notify the activation and deactivation
     114             :         of resources.
     115             :     */
     116             :     ::boost::shared_ptr<ConfigurationControllerBroadcaster> mpBroadcaster;
     117             : 
     118             :     void ActivateResource (
     119             :         const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId,
     120             :         const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration);
     121             : 
     122             :     void DeactivateResource (
     123             :         const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId,
     124             :         const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration);
     125             : 
     126             :     void AddResource (
     127             :         const css::uno::Reference<css::drawing::framework::XResource>& rxResource,
     128             :         const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxFactory);
     129             : 
     130             :     ResourceDescriptor RemoveResource (
     131             :         const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId);
     132             : };
     133             : 
     134             : } } // end of namespace sd::framework
     135             : 
     136             : #endif
     137             : 
     138             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11