LibreOffice Module sd (master) 1
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
sd::SdGlobalResourceContainer Class Referencefinal

The purpose of this container is to hold references to resources that are globally available to all interested objects and to destroy them when the sd module is destroyed. More...

#include <SdGlobalResourceContainer.hxx>

Classes

class  Implementation
 

Public Member Functions

void AddResource (::std::unique_ptr< SdGlobalResource > pResource)
 Add a resource to the container. More...
 
void AddResource (const std::shared_ptr< SdGlobalResource > &pResource)
 Add a resource to the container. More...
 
void AddResource (const css::uno::Reference< css::uno::XInterface > &rxResource)
 Add a resource that is implemented as UNO object. More...
 

Static Public Member Functions

static SdGlobalResourceContainerInstance ()
 

Private Member Functions

 SdGlobalResourceContainer ()
 
 ~SdGlobalResourceContainer ()
 

Private Attributes

::std::unique_ptr< ImplementationmpImpl
 

Friends

class SdGlobalResourceContainerInstance
 
struct o3tl::default_delete< SdGlobalResourceContainer >
 

Detailed Description

The purpose of this container is to hold references to resources that are globally available to all interested objects and to destroy them when the sd module is destroyed.

Examples for resources can be containers of bitmaps or the container of master pages used by the MasterPagesSelector objects in the task panel.

It works like a singleton in that there is one instance per sd module. Resources can be added (by themselves or their owners) to the container. The main task of the container is the destruction of all resources that have been added to it.

As you may note, there is no method to get a resource from the container. It is the task of the resource to provide other means of access to it.

The reason for this design is not to have to change the SdModule destructor every time when there is a new resource. This is done by reversing the dependency between module and resource: the resource knows about the module–this container class to be more precisely–and tells it to destroy the resource when the sd module is at the end of its lifetime.

Definition at line 65 of file SdGlobalResourceContainer.hxx.

Constructor & Destructor Documentation

◆ SdGlobalResourceContainer()

sd::SdGlobalResourceContainer::SdGlobalResourceContainer ( )
private

Definition at line 144 of file SdGlobalResourceContainer.cxx.

◆ ~SdGlobalResourceContainer()

sd::SdGlobalResourceContainer::~SdGlobalResourceContainer ( )
private

Member Function Documentation

◆ AddResource() [1/3]

void sd::SdGlobalResourceContainer::AddResource ( ::std::unique_ptr< SdGlobalResource pResource)

Add a resource to the container.

The ownership of the resource is transferred to the container. The resource is destroyed when the container is destroyed, i.e. when the sd module is destroyed.

When in doubt, use the shared_ptr variant of this method.

Definition at line 95 of file SdGlobalResourceContainer.cxx.

References mpImpl, and p.

Referenced by sd::MasterPageObserver::Instance(), sd::IconCache::Instance(), sd::sidebar::MasterPageContainer::Implementation::Instance(), sd::sidebar::RecentlyUsedMasterPages::Instance(), and sd::framework::ResourceId::ParseResourceURL().

◆ AddResource() [2/3]

void sd::SdGlobalResourceContainer::AddResource ( const css::uno::Reference< css::uno::XInterface > &  rxResource)

Add a resource that is implemented as UNO object.

Destruction (when the sd modules is unloaded) is done by a) calling dispose() when the XComponent is supported and by b) releasing the reference.

◆ AddResource() [3/3]

void sd::SdGlobalResourceContainer::AddResource ( const std::shared_ptr< SdGlobalResource > &  pResource)

Add a resource to the container.

By using a shared_ptr and releasing it only when the SgGlobalResourceContainer is destroyed the given resource is kept alive at least that long. When at the time of the destruction of SgGlobalResourceContainer no other references exist the resource is destroyed as well.

Definition at line 109 of file SdGlobalResourceContainer.cxx.

References mpImpl, and SAL_WARN.

◆ Instance()

SdGlobalResourceContainer & sd::SdGlobalResourceContainer::Instance ( )
static

Friends And Related Function Documentation

◆ o3tl::default_delete< SdGlobalResourceContainer >

Definition at line 93 of file SdGlobalResourceContainer.hxx.

◆ SdGlobalResourceContainerInstance

friend class SdGlobalResourceContainerInstance
friend

Definition at line 93 of file SdGlobalResourceContainer.hxx.

Member Data Documentation

◆ mpImpl

::std::unique_ptr<Implementation> sd::SdGlobalResourceContainer::mpImpl
private

Definition at line 97 of file SdGlobalResourceContainer.hxx.

Referenced by AddResource(), and ~SdGlobalResourceContainer().


The documentation for this class was generated from the following files: