LibreOffice Module filter (master) 1
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
filter::config::BaseContainer Class Reference

implements the interface css::container::XNameContainer on top of a FilterCache reference. More...

#include <basecontainer.hxx>

Inheritance diagram for filter::config::BaseContainer:
[legend]
Collaboration diagram for filter::config::BaseContainer:
[legend]

Public Member Functions

 BaseContainer ()
 standard ctor. More...
 
virtual ~BaseContainer () override
 standard dtor. More...
 
void init (const OUString &sImplementationName, const css::uno::Sequence< OUString > &lServiceNames, FilterCache::EItemType eType)
 initialize this generic instance with some specialized values from our derived object. More...
 
virtual OUString SAL_CALL getImplementationName () override
 
virtual sal_Bool SAL_CALL supportsService (const OUString &sServiceName) override
 
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames () override
 
virtual void SAL_CALL insertByName (const OUString &sItem, const css::uno::Any &aValue) override
 
virtual void SAL_CALL removeByName (const OUString &sItem) override
 
virtual void SAL_CALL replaceByName (const OUString &sItem, const css::uno::Any &aValue) override
 
virtual css::uno::Any SAL_CALL getByName (const OUString &sItem) override
 
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames () override
 
virtual sal_Bool SAL_CALL hasByName (const OUString &sItem) override
 
virtual css::uno::Type SAL_CALL getElementType () override
 
virtual sal_Bool SAL_CALL hasElements () override
 
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSubSetEnumerationByQuery (const OUString &sQuery) override
 
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSubSetEnumerationByProperties (const css::uno::Sequence< css::beans::NamedValue > &lProperties) override
 
virtual void SAL_CALL flush () override
 
virtual void SAL_CALL addFlushListener (const css::uno::Reference< css::util::XFlushListener > &xListener) override
 
virtual void SAL_CALL removeFlushListener (const css::uno::Reference< css::util::XFlushListener > &xListener) override
 

Protected Member Functions

void impl_loadOnDemand (std::unique_lock< std::mutex > &rGuard)
 check if the underlying configuration data was already loaded and do it if necessary automatically. More...
 
void impl_initFlushMode (std::unique_lock< std::mutex > &rGuard)
 it creates the global instance m_pFilterCache, which is a copy of the global instance m_rCache, and will be used to change the configuration. More...
 
FilterCacheimpl_getWorkingCache (std::unique_lock< std::mutex > &rGuard) const
 returns a pointer to the current used cache member. More...
 

Protected Attributes

std::mutex m_aMutex
 
OUString m_sImplementationName
 the implementation name of our derived class, which we provide at the interface XServiceInfo of our class... More...
 
css::uno::Sequence< OUString > m_lServiceNames
 the list of supported uno service names of our derived class, which we provide at the interface XServiceInfo of our class... More...
 
std::unique_ptr< FilterCachem_pFlushCache
 local filter cache, which is used to collect changes on the filter configuration first and flush it later. More...
 
FilterCache::EItemType m_eType
 specify, which sub container of the used filter cache must be wrapped by this container interface. More...
 
comphelper::OInterfaceContainerHelper4< css::util::XFlushListener > m_lListener
 holds all listener, which are registered at this instance. More...
 

Detailed Description

implements the interface css::container::XNameContainer on top of a FilterCache reference.

@descr This class can be used as base for own service implementations, which must provide read/write access to the filter configuration. Parameters regulate read/write access, which sub set of information should be available etc.

Attention: \n The base class BaseLock must be the first of declared ones.
Otherwise we can't be sure, that our own mutex member (which is present by this base class!) was full initialized inside our own ctor as first!

Definition at line 52 of file basecontainer.hxx.

Constructor & Destructor Documentation

◆ BaseContainer()

filter::config::BaseContainer::BaseContainer ( )

standard ctor.

@descr Because mostly this class is used as base class for own service implementations in combination with an ImplInheritanceHelper template... there is no way to provide some initializing data through the ctor :-( This base class will be created inside its default ctor and must be initialized with its needed parameters explicitly by calling: "init()".

See also
init()

Definition at line 32 of file basecontainer.cxx.

References filter::config::FilterCache::E_CONTAINS_STANDARD, filter::config::GetTheFilterCache(), filter::config::FilterCache::load(), and m_eType.

◆ ~BaseContainer()

filter::config::BaseContainer::~BaseContainer ( )
overridevirtual

standard dtor.

Definition at line 39 of file basecontainer.cxx.

Member Function Documentation

◆ addFlushListener()

void SAL_CALL filter::config::BaseContainer::addFlushListener ( const css::uno::Reference< css::util::XFlushListener > &  xListener)
overridevirtual

◆ createSubSetEnumerationByProperties()

css::uno::Reference< css::container::XEnumeration > SAL_CALL filter::config::BaseContainer::createSubSetEnumerationByProperties ( const css::uno::Sequence< css::beans::NamedValue > &  lProperties)
overridevirtual

◆ createSubSetEnumerationByQuery()

css::uno::Reference< css::container::XEnumeration > SAL_CALL filter::config::BaseContainer::createSubSetEnumerationByQuery ( const OUString &  sQuery)
overridevirtual

◆ flush()

void SAL_CALL filter::config::BaseContainer::flush ( )
overridevirtual

◆ getByName()

css::uno::Any SAL_CALL filter::config::BaseContainer::getByName ( const OUString &  sItem)
overridevirtual

◆ getElementNames()

css::uno::Sequence< OUString > SAL_CALL filter::config::BaseContainer::getElementNames ( )
overridevirtual

◆ getElementType()

css::uno::Type SAL_CALL filter::config::BaseContainer::getElementType ( )
overridevirtual

◆ getImplementationName()

OUString SAL_CALL filter::config::BaseContainer::getImplementationName ( )
overridevirtual

Definition at line 107 of file basecontainer.cxx.

References m_sImplementationName.

◆ getSupportedServiceNames()

css::uno::Sequence< OUString > SAL_CALL filter::config::BaseContainer::getSupportedServiceNames ( )
overridevirtual

Definition at line 118 of file basecontainer.cxx.

References m_lServiceNames.

◆ hasByName()

sal_Bool SAL_CALL filter::config::BaseContainer::hasByName ( const OUString &  sItem)
overridevirtual

◆ hasElements()

sal_Bool SAL_CALL filter::config::BaseContainer::hasElements ( )
overridevirtual

◆ impl_getWorkingCache()

FilterCache * filter::config::BaseContainer::impl_getWorkingCache ( std::unique_lock< std::mutex > &  rGuard) const
protected

returns a pointer to the current used cache member.

@descr It's a point to the FilterCache instance behind m_pFlushCache or m_rCache.

Note
The lifetime of this pointer is restricted to the time, where the mutex of this BaseContainer instance is locked. Otherwise may be the interface method flush() will destroy m_pFlushCache and the here returned pointer will be invalid!

Use:

Guard aLock(m_aLock);
    FilterCache* p = impl_getWorkingCache();
    p->doSomething();
aLock.clear();

after this point p can't b e guaranteed any longer!

Definition at line 98 of file basecontainer.cxx.

References filter::config::GetTheFilterCache(), and m_pFlushCache.

Referenced by createSubSetEnumerationByProperties(), getByName(), getElementNames(), hasByName(), hasElements(), insertByName(), removeByName(), and replaceByName().

◆ impl_initFlushMode()

void filter::config::BaseContainer::impl_initFlushMode ( std::unique_lock< std::mutex > &  rGuard)
protected

it creates the global instance m_pFilterCache, which is a copy of the global instance m_rCache, and will be used to change the configuration.

@descr If no exception occurs, its guaranteed, that the member m_rFlushCache was initialized right and can be used further.

Exceptions
css::uno::RuntimeException

Definition at line 88 of file basecontainer.cxx.

References filter::config::FilterCache::clone(), filter::config::GetTheFilterCache(), and m_pFlushCache.

Referenced by insertByName(), removeByName(), and replaceByName().

◆ impl_loadOnDemand()

void filter::config::BaseContainer::impl_loadOnDemand ( std::unique_lock< std::mutex > &  rGuard)
protected

◆ init()

void filter::config::BaseContainer::init ( const OUString &  sImplementationName,
const css::uno::Sequence< OUString > &  lServiceNames,
FilterCache::EItemType  eType 
)

initialize this generic instance with some specialized values from our derived object.

@descr Because an outside class must use ImplInheritanceHelper template to use us a base class... and there is no way to pass such initializing parameters through a required default ctor... we must be initialized by this special method. Of course this method must be called first before any other interface method is used.

Parameters
rxContextreference to the uno service manager, which created this service instance.
sImplementationNamethe implementation name of our derived class, which we provide at the interface XServiceInfo of our class...
lServiceNamesthe list of supported uno service names of our derived class, which we provide at the interface XServiceInfo of our class...
eTypespecify, which sub container of the used filter cache must be wrapped by this container interface.

Definition at line 44 of file basecontainer.cxx.

References eType, m_aMutex, m_eType, m_lServiceNames, m_sImplementationName, and sImplementationName.

Referenced by filter::config::ContentHandlerFactory::ContentHandlerFactory(), filter::config::FilterFactory::FilterFactory(), filter::config::FrameLoaderFactory::FrameLoaderFactory(), and filter::config::TypeDetection::TypeDetection().

◆ insertByName()

void SAL_CALL filter::config::BaseContainer::insertByName ( const OUString &  sItem,
const css::uno::Any &  aValue 
)
overridevirtual

◆ removeByName()

void SAL_CALL filter::config::BaseContainer::removeByName ( const OUString &  sItem)
overridevirtual

◆ removeFlushListener()

void SAL_CALL filter::config::BaseContainer::removeFlushListener ( const css::uno::Reference< css::util::XFlushListener > &  xListener)
overridevirtual

◆ replaceByName()

void SAL_CALL filter::config::BaseContainer::replaceByName ( const OUString &  sItem,
const css::uno::Any &  aValue 
)
overridevirtual

◆ supportsService()

sal_Bool SAL_CALL filter::config::BaseContainer::supportsService ( const OUString &  sServiceName)
overridevirtual

Definition at line 113 of file basecontainer.cxx.

References sServiceName, and cppu::supportsService().

Member Data Documentation

◆ m_aMutex

std::mutex filter::config::BaseContainer::m_aMutex
mutableprotected

◆ m_eType

FilterCache::EItemType filter::config::BaseContainer::m_eType
protected

specify, which sub container of the used filter cache must be wrapped by this container interface.

Definition at line 90 of file basecontainer.hxx.

Referenced by createSubSetEnumerationByProperties(), getByName(), getElementNames(), hasByName(), hasElements(), impl_loadOnDemand(), init(), insertByName(), removeByName(), and replaceByName().

◆ m_lListener

comphelper::OInterfaceContainerHelper4<css::util::XFlushListener> filter::config::BaseContainer::m_lListener
protected

holds all listener, which are registered at this instance.

Definition at line 93 of file basecontainer.hxx.

Referenced by addFlushListener(), flush(), and removeFlushListener().

◆ m_lServiceNames

css::uno::Sequence< OUString > filter::config::BaseContainer::m_lServiceNames
protected

the list of supported uno service names of our derived class, which we provide at the interface XServiceInfo of our class...

Definition at line 69 of file basecontainer.hxx.

Referenced by getSupportedServiceNames(), and init().

◆ m_pFlushCache

std::unique_ptr<FilterCache> filter::config::BaseContainer::m_pFlushCache
protected

local filter cache, which is used to collect changes on the filter configuration first and flush it later.

@descr Normally this member isn't used nor initialized. That's true, if this container is used for reading only. The first write access (e.g. by calling insertByName()) creates a copy of the current global cache m_rCache to initialize the m_pFlushCache member.

Afterwards only the flush cache copy is used. Inside flush() this copy will be removed and m_rCache can be used again.

m_pFlushCache and m_rCache must not be synchronized manually here. m_rCache listen on the global configuration, where m_pFlushCache write its data. m_rCache update itself automatically.

Definition at line 86 of file basecontainer.hxx.

Referenced by flush(), impl_getWorkingCache(), and impl_initFlushMode().

◆ m_sImplementationName

OUString filter::config::BaseContainer::m_sImplementationName
protected

the implementation name of our derived class, which we provide at the interface XServiceInfo of our class...

Definition at line 65 of file basecontainer.hxx.

Referenced by getImplementationName(), and init().


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