LibreOffice Module framework (master) 1
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
framework::ConfigAccess Class Referencefinal

implements a simple configuration access @descr Sometimes it's better to have direct config access instead of using specialized config items of the svtools project. More...

#include <configaccess.hxx>

Public Types

enum  EOpenMode {
  E_CLOSED ,
  E_READONLY ,
  E_READWRITE
}
 represent the possible modes of the internal wrapped configuration access More...
 

Public Member Functions

 ConfigAccess (css::uno::Reference< css::uno::XComponentContext > xContext, OUString sRoot)
 open the configuration of this job @descr We open the configuration of this job only. More...
 
 ~ConfigAccess ()
 last chance to close an open configuration access point @descr In case our user forgot to close this configuration point in the right way, normally he will run into some trouble - e.g. More...
 
void open (EOpenMode eMode)
 open the configuration access in the specified mode @descr We set the opened configuration access as our member. More...
 
void close ()
 close the internal opened configuration access and flush all changes @descr It checks, if the given access is valid and react in the right way. More...
 
EOpenMode getMode () const
 return the internal mode of this instance @descr May be the outside user need any information about successfully opened or closed config access point objects. More...
 
const css::uno::Reference< css::uno::XInterface > & cfg ()
 provides an access to the internal wrapped configuration access @descr It's not allowed to safe this c++ (!) reference outside. More...
 

Private Member Functions

void closeImpl ()
 

Private Attributes

std::mutex m_mutex
 
css::uno::Reference< css::uno::XComponentContext > m_xContext
 reference to the uno service manager It's necessary to instantiate own needed services. More...
 
css::uno::Reference< css::uno::XInterface > m_xConfig
 hold an opened configuration alive More...
 
OUString m_sRoot
 knows the root of the opened config access point More...
 
EOpenMode m_eMode
 represent the current open mode More...
 

Detailed Description

implements a simple configuration access @descr Sometimes it's better to have direct config access instead of using specialized config items of the svtools project.

This class can wrap such configuration access.

Definition at line 34 of file configaccess.hxx.

Member Enumeration Documentation

◆ EOpenMode

represent the possible modes of the internal wrapped configuration access

Enumerator
E_CLOSED 

config isn't used yet

E_READONLY 

config access is open for reading only

E_READWRITE 

config access is open for reading/writing data

Definition at line 40 of file configaccess.hxx.

Constructor & Destructor Documentation

◆ ConfigAccess()

framework::ConfigAccess::ConfigAccess ( css::uno::Reference< css::uno::XComponentContext >  xContext,
OUString  sRoot 
)

open the configuration of this job @descr We open the configuration of this job only.

Not the whole package or the whole job set. We are interested on our own properties only. We set the opened configuration access as our member. So any following method, which needs cfg access, can use it. That prevent us against multiple open/close requests. But you can use this method to upgrade an already opened configuration too.

Parameters
eModeforce opening of the configuration access in readonly or in read/write mode

Definition at line 43 of file configaccess.cxx.

◆ ~ConfigAccess()

framework::ConfigAccess::~ConfigAccess ( )

last chance to close an open configuration access point @descr In case our user forgot to close this configuration point in the right way, normally he will run into some trouble - e.g.

losing data.

Definition at line 57 of file configaccess.cxx.

References close().

Member Function Documentation

◆ cfg()

const css::uno::Reference< css::uno::XInterface > & framework::ConfigAccess::cfg ( )

provides an access to the internal wrapped configuration access @descr It's not allowed to safe this c++ (!) reference outside.

You have to use it directly. Further you must use our public lock member m_aLock to synchronize your code with our internal structures and our interface methods. Acquire it before you call cfg() and release it afterwards immediately.

E.g.: ConfigAccess aAccess(...); Guard aReadLock(aAccess.m_aLock); Reference< XPropertySet > xSet(aAccess.cfg(), UNO_QUERY); Any aProp = xSet->getPropertyValue("..."); aReadLock.unlock();

Attention: \n During this time it's not allowed to call the methods open() or close()!
Otherwise you will change your own referenced config access. Anything will be possible then.
Returns
A c++(!) reference to the uno instance of the configuration access point.

Definition at line 175 of file configaccess.cxx.

References m_xConfig.

Referenced by framework::JobData::disableJob(), framework::JobData::getEnabledJobsForEvent(), framework::JobData::setAlias(), and framework::JobData::setJobConfig().

◆ close()

void framework::ConfigAccess::close ( )

close the internal opened configuration access and flush all changes @descr It checks, if the given access is valid and react in the right way.

It flushes all changes ... so nobody else must know this state.

Definition at line 137 of file configaccess.cxx.

References closeImpl(), and m_mutex.

Referenced by framework::JobData::disableJob(), framework::JobData::getEnabledJobsForEvent(), framework::JobData::setAlias(), framework::JobData::setJobConfig(), and ~ConfigAccess().

◆ closeImpl()

void framework::ConfigAccess::closeImpl ( )
private

Definition at line 143 of file configaccess.cxx.

References E_CLOSED, m_eMode, and m_xConfig.

Referenced by close(), and open().

◆ getMode()

ConfigAccess::EOpenMode framework::ConfigAccess::getMode ( ) const

return the internal mode of this instance @descr May be the outside user need any information about successfully opened or closed config access point objects.

He can control the internal mode to do so.

Returns
The internal open state of this object.

Definition at line 69 of file configaccess.cxx.

References m_eMode, and m_mutex.

Referenced by framework::JobData::disableJob(), framework::JobData::getEnabledJobsForEvent(), framework::JobData::setAlias(), and framework::JobData::setJobConfig().

◆ open()

void framework::ConfigAccess::open ( EOpenMode  eMode)

open the configuration access in the specified mode @descr We set the opened configuration access as our member.

So any following method, which needs cfg access, can use it. That prevent us against multiple open/close requests. But you can use this method to upgrade an already opened configuration too. It's possible to open a config access in READONLY mode first and "open" it at a second time within the mode READWRITE. Then we will upgrade it. Downgrade will be possible too.

But note: closing will be done explicitly by calling method close() ... not by downgrading with mode CLOSED!

Parameters
eModeforce (re)opening of the configuration access in readonly or in read/write mode

Definition at line 89 of file configaccess.cxx.

References closeImpl(), E_CLOSED, E_READONLY, E_READWRITE, eMode, m_eMode, m_mutex, m_sRoot, m_xConfig, m_xContext, framework::SERVICENAME_CFGREADACCESS, framework::SERVICENAME_CFGUPDATEACCESS, and TOOLS_INFO_EXCEPTION.

Referenced by framework::JobData::disableJob(), framework::JobData::getEnabledJobsForEvent(), framework::JobData::setAlias(), and framework::JobData::setJobConfig().

Member Data Documentation

◆ m_eMode

EOpenMode framework::ConfigAccess::m_eMode
private

represent the current open mode

Definition at line 68 of file configaccess.hxx.

Referenced by closeImpl(), getMode(), and open().

◆ m_mutex

std::mutex framework::ConfigAccess::m_mutex
mutableprivate

Definition at line 53 of file configaccess.hxx.

Referenced by close(), getMode(), and open().

◆ m_sRoot

OUString framework::ConfigAccess::m_sRoot
private

knows the root of the opened config access point

Definition at line 65 of file configaccess.hxx.

Referenced by open().

◆ m_xConfig

css::uno::Reference< css::uno::XInterface > framework::ConfigAccess::m_xConfig
private

hold an opened configuration alive

Definition at line 62 of file configaccess.hxx.

Referenced by cfg(), closeImpl(), and open().

◆ m_xContext

css::uno::Reference< css::uno::XComponentContext > framework::ConfigAccess::m_xContext
private

reference to the uno service manager It's necessary to instantiate own needed services.

Definition at line 59 of file configaccess.hxx.

Referenced by open().


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