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

Generated by: LCOV version 1.10