/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include #ifndef INCLUDED_UNOTOOLS_CONFIGVALUECONTAINER_HXX #define INCLUDED_UNOTOOLS_CONFIGVALUECONTAINER_HXX #include #include //......................................................................... namespace utl { //......................................................................... #define CVC_READONLY_ACCESS 0x0000 #define CVC_UPDATE_ACCESS 0x0001 #define CVC_LAZY_UPDATE 0x0000 #define CVC_IMMEDIATE_UPDATE 0x0002 struct OConfigurationValueContainerImpl; struct NodeValueAccessor; //===================================================================== //= OConfigurationValueContainer //===================================================================== /** allows simple access to static configuration structures.

The basic idea of this class is that it's clients (usually derived classes) simply register an address in memory and a node path, and upon explicit request, the configuration value and the memory are syncronized.
This means that when calling read, the current configuration values are copied into the memory registered for them, and upon calling write the current values in memory are set in the configuration nodes.

This way, the usage of this class is pretty straight forward: derive your own class, spend some members to it, and bind these members to configuration node (usually done in the ctor of the derived class).
In the dtor, simply call write and commit.

There is no auto-commit mechanism in the dtor: In the usual scenario, when you derive from this class and bind some members of your derived class to config nodes, this means that your members will be destroyed before your base class' dtor is called, so accessing the memory during such a theoretical auto-commit would yield undefined behaviour.

*/ class UNOTOOLS_DLLPUBLIC OConfigurationValueContainer { private: OConfigurationValueContainerImpl* m_pImpl; protected: //----------------------------------------------------------------- // construction/destruction /** constructs the object @param _rxORB specifies the service factory which should be used to access the configuration @param _rAccessSafety As this class is intented to manipulate objects it does not hold itself (see the various registerXXX methods), it needs to guard these access for muti threading safety.
The mutex given here is locked whenever such an access occurs. @param _pConfigLocation is an ASCII string describing the configurations node path @param _nAccessFlags specifies different aspects of the configuration aspect to be created, e.g. it's update mode etc.
See the CVC_xxx constants for what you can use here. @param _nLevels specifies the number of levels to access under the node given by _pConfigLocation */ OConfigurationValueContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB, ::osl::Mutex& _rAccessSafety, const sal_Char* _pConfigLocation, const sal_uInt16 _nAccessFlags = CVC_UPDATE_ACCESS | CVC_LAZY_UPDATE, const sal_Int32 _nLevels = -1 ); /// dtor ~OConfigurationValueContainer(); //----------------------------------------------------------------- // registering data containers /** registers a data accessor of an arbitrary type.

Usually, in your derived class you simply add a member of the correct type of the configuration value, and then call this method with the address of this member.

@param _pRelativePathAscii is a relative (ASCII) path of the node which should be "mirrored" into the accessor. @param _pContainer points to the accessors location in memory. Usually, this is simply an address of your derived class @param _rValueType is the type of your accessort. This type must be supported by the configuration. */ void registerExchangeLocation( const sal_Char* _pRelativePathAscii, void* _pContainer, const ::com::sun::star::uno::Type& _rValueType ); public: /** reads the configuration data

The current values of the nodes bound (using the registerXXX methods) is copied into their respective exchange locations.

Please note that any changes done to your exchange locations are overridden with the current config values.

@see write */ void read( ); /** updates the configuration data

The current values in memory (your exchange locations registered using the registerXXX methods) is forwarded to their respective configuration nodes.

Note that calling write(commit().

@precond The access must have been created for update access @param _bCommit If set to , an automatic commit is done after the values have been synchronized.
If set to , you must explicitly call commit to make your changes persistent. @see read @see commit */ void write( sal_Bool _bCommit = sal_True ); /** commits any changes done

Note that calling write(commit().

@precond The access must have been created for update access @param _bWrite If , the current values in the exchange locations are written to the configuration nodes before the changes are committed.
If , only the current values in the config nodes (as present since the last call to write) are committed. */ void commit( sal_Bool _bWrite = sal_True ); private: /// implements the ctors void implConstruct( const OUString& _rConfigLocation, const sal_uInt16 _nAccessFlags, const sal_Int32 _nLevels ); /// registers a value container void implRegisterExchangeLocation( const NodeValueAccessor& _rAccessor ); }; //......................................................................... } // namespace utl //......................................................................... #endif // INCLUDED_UNOTOOLS_CONFIGVALUECONTAINER_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ alue='distro/nisz/libreoffice-7-0'>distro/nisz/libreoffice-7-0 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-05-02throw() -> noexcept, part 2/3: Automatic loplugin:noexcept rewriteStephan Bergmann
Change-Id: I076f16d0536b534abf0ced4d76051eadb4c0e033 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114949 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-11-19tdf#124176 use pragma once instead of include guardsRoman Kuznetsov
in /core/include/svtools/ Change-Id: Ic8614f77dfde02f4c1fc4cceccd1de4ff5a05f72 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106006 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2019-10-30loplugin:finalclasses svtoolsNoel Grandin
Change-Id: I17f4fd3960a23132916ea64b21cc8869a94eaed4 Reviewed-on: https://gerrit.libreoffice.org/81704 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-02-05tdf#42949 Fix IWYU warnings in include/svtools/*Gabor Kelemen
Found with bin/find-unneeded-includes Only removal proposals are dealt with here. Change-Id: I937ed12f2a96943664087ddcdd035f1347e84a57 Reviewed-on: https://gerrit.libreoffice.org/67102 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2018-11-02fix signatures of deleted copy/assign operatorsNoel Grandin
Change-Id: Id1a0749b78a7021be3564487fb974d7084705129 Reviewed-on: https://gerrit.libreoffice.org/62718 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-06-18remove unused osl/mutex.hxx includesJochen Nitschke
Change-Id: I3b50e45fdb99e9cd8bfda07356ee3ddb4dd0f8bb Reviewed-on: https://gerrit.libreoffice.org/38905 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
2017-01-26Remove dynamic exception specificationsStephan Bergmann
...(for now, from LIBO_INTERNAL_CODE only). See the mail thread starting at <https://lists.freedesktop.org/archives/libreoffice/2017-January/076665.html> "Dynamic Exception Specifications" for details. Most changes have been done automatically by the rewriting loplugin:dynexcspec (after enabling the rewriting mode, to be committed shortly). The way it only removes exception specs from declarations if it also sees a definition, it identified some dead declarations-w/o-definitions (that have been removed manually) and some cases where a definition appeared in multiple include files (which have also been cleaned up manually). There's also been cases of macro paramters (that were used to abstract over exception specs) that have become unused now (and been removed). Furthermore, some code needed to be cleaned up manually (avmedia/source/quicktime/ and connectivity/source/drivers/kab/), as I had no configurations available that would actually build that code. Missing @throws documentation has not been applied in such manual clean-up. Change-Id: I3408691256c9b0c12bc5332de976743626e13960 Reviewed-on: https://gerrit.libreoffice.org/33574 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2016-06-24loplugin:singlevalfields in svtoolsNoel Grandin
Change-Id: I80fe1d4646af2b8d8e6362a25f6cda4b7ac29eab Reviewed-on: https://gerrit.libreoffice.org/26603 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-03-17loplugin:constantparam in svtoolsNoel Grandin
Change-Id: I1a3c4a36e29a6712c589ffd3aaada593880d978d Reviewed-on: https://gerrit.libreoffice.org/23304 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
2016-01-10Fix typosAndrea Gelmini
Change-Id: I9a5940027423ff0791fa7da0b79b617412ce6b86 Reviewed-on: https://gerrit.libreoffice.org/21209 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2015-10-23com::sun::star->css in include/sot to include/typelibNoel Grandin
Change-Id: I9cd92b53370a6b6018d2f7c648890f9c014a27de
2015-10-12Replace "SAL_OVERRIDE" with "override" in LIBO_INTERNAL_ONLY codeStephan Bergmann
Change-Id: I2ea407acd763ef2d7dae2d3b8f32525523ac8274
2015-10-12Replace "SAL_DELETED_FUNCTION" with "= delete" in LIBO_INTERNAL_ONLY codeStephan Bergmann
Change-Id: I328ac7a95ccc87732efae48b567a0556865928f3
2015-02-07loplugin:deletedspecialStephan Bergmann
Change-Id: Ia503ee8012ca9a2a6128c657961176968073f37f
2014-03-26First batch of adding SAL_OVERRRIDE to overriding function declarationsStephan Bergmann
...mostly done with a rewriting Clang plugin, with just some manual tweaking necessary to fix poor macro usage. Change-Id: I71fa20213e86be10de332ece0aa273239df7b61a
2014-02-26cppuhelper: retrofit std::exception into overriding exception specsStephan Bergmann
Change-Id: I56e32131b7991ee9948ce46765632eb823d463b3