LibreOffice Module framework (master) 1
|
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... | |
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.
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.
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.
eMode | force opening of the configuration access in readonly or in read/write mode |
Definition at line 43 of file configaccess.cxx.
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().
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();
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().
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().
|
private |
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.
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().
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!
eMode | force (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().
|
private |
represent the current open mode
Definition at line 68 of file configaccess.hxx.
Referenced by closeImpl(), getMode(), and open().
|
mutableprivate |
Definition at line 53 of file configaccess.hxx.
|
private |
knows the root of the opened config access point
Definition at line 65 of file configaccess.hxx.
Referenced by open().
|
private |
hold an opened configuration alive
Definition at line 62 of file configaccess.hxx.
Referenced by cfg(), closeImpl(), and open().
|
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().