LCOV - code coverage report
Current view: top level - sd/source/ui/inc/tools - SdGlobalResourceContainer.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 2 0.0 %
Date: 2014-04-14 Functions: 0 3 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_INC_TOOLS_SDGLOBALRESOURCECONTAINER_HXX
      21             : #define INCLUDED_SD_SOURCE_UI_INC_TOOLS_SDGLOBALRESOURCECONTAINER_HXX
      22             : 
      23             : #include "sdmod.hxx"
      24             : #include <memory>
      25             : #include <boost/shared_ptr.hpp>
      26             : #include <com/sun/star/uno/XInterface.hpp>
      27             : 
      28             : namespace sd {
      29             : 
      30           0 : class SdGlobalResource
      31             : {
      32             : public:
      33           0 :     virtual ~SdGlobalResource (void) {};
      34             : };
      35             : 
      36             : /** The purpose of this container is to hold references to resources that
      37             :     are globally available to all interested objects and to destroy them
      38             :     when the sd module is destroyed.  Examples for resources can be
      39             :     containers of bitmaps or the container of master pages used by the
      40             :     MasterPagesSelector objects in the task panel.
      41             : 
      42             :     It works like a singleton in that there is one instance per sd module.
      43             :     Resources can be added (by themselves or their owners) to the
      44             :     container.  The main task of the container is the destruction of all
      45             :     resources that have been added to it.
      46             : 
      47             :     As you may note, there is no method to get a resource from the
      48             :     container.  It is the task of the resource to provide other means of
      49             :     access to it.
      50             : 
      51             :     The reason for this design is not to have to change the SdModule
      52             :     destructor every time when there is a new resource.  This is done by
      53             :     reversing the dependency between module and resource: the resource knows
      54             :     about the module--this container class to be more precisely--and tells
      55             :     it to destroy the resource when the sd module is at the end of its
      56             :     lifetime.
      57             : */
      58             : class SdGlobalResourceContainer
      59             : {
      60             : public:
      61             :     static SdGlobalResourceContainer& Instance (void);
      62             : 
      63             :     /** Add a resource to the container.  The ownership of the resource is
      64             :         transferred to the container.  The resource is destroyed when the
      65             :         container is destroyed, i.e. when the sd module is destroyed.
      66             : 
      67             :         When in doubt, use the shared_ptr variant of this method.
      68             :     */
      69             :     void AddResource (::std::auto_ptr<SdGlobalResource> pResource);
      70             : 
      71             :     /** Add a resource to the container.  By using a shared_ptr and
      72             :         releasing it only when the SgGlobalResourceContainer is destroyed
      73             :         the given resource is kept alive at least that long.  When at the
      74             :         time of the destruction of SgGlobalResourceContainer no other
      75             :         references exist the resource is destroyed as well.
      76             :     */
      77             :     void AddResource (::boost::shared_ptr<SdGlobalResource> pResource);
      78             : 
      79             :     /** Add a resource that is implemented as UNO object.  Destruction
      80             :         (when the sd modules is unloaded) is done by a) calling dispose()
      81             :         when the XComponent is supported and by b) releasing the reference.
      82             :     */
      83             :     void AddResource (const css::uno::Reference<css::uno::XInterface>& rxResource);
      84             : 
      85             : protected:
      86             :     friend class ::SdModule;
      87             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
      88             :     friend class ::std::auto_ptr<SdGlobalResourceContainer>;
      89             :     SAL_WNODEPRECATED_DECLARATIONS_POP
      90             : 
      91             :     class Implementation;
      92             :     ::std::auto_ptr<Implementation> mpImpl;
      93             : 
      94             :     SdGlobalResourceContainer (void);
      95             :     ~SdGlobalResourceContainer (void);
      96             : };
      97             : 
      98             : } // end of namespace sd
      99             : 
     100             : #endif
     101             : 
     102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10