/* -*- 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 .
*/
struct NodeValueAccessor
{ private:
OUString sRelativePath; // the relative path of the node
LocationType eLocationType; // the type of location where the value is stored void* pLocation; // the pointer to the location
Type aDataType; // the type object pointed to by pLocation
/// base class for functors synchronizing between exchange locations and config sub nodes struct SubNodeAccess
{ protected: const OConfigurationNode& m_rRootNode;
std::mutex& m_rMutex;
struct OConfigurationValueContainerImpl
{
Reference< XComponentContext > xORB; // the service factory
std::mutex& rMutex; // the mutex for accessing the data containers
OConfigurationTreeRoot aConfigRoot; // the configuration node we're accessing
std::vector<NodeValueAccessor> aAccessors; // the accessors to the node values
// create the configuration node we're about to work with
m_pImpl->aConfigRoot = OConfigurationTreeRoot::createWithComponentContext(
m_pImpl->xORB,
_rConfigLocation,
_nLevels
);
SAL_WARN_IF(!m_pImpl->aConfigRoot.isValid(), "unotools.config", "Could not access the configuration node located at " << _rConfigLocation);
}
void OConfigurationValueContainer::commit()
{ // write the current values in the exchange locations
std::for_each(
m_pImpl->aAccessors.begin(),
m_pImpl->aAccessors.end(),
UpdateToConfig( m_pImpl->aConfigRoot, m_pImpl->rMutex )
);
// commit the changes done
m_pImpl->aConfigRoot.commit( );
}
// another check (should be the first container for this node)
SAL_WARN_IF(!(m_pImpl->aAccessors.end() == ::std::find(
m_pImpl->aAccessors.begin(),
m_pImpl->aAccessors.end(),
_rAccessor)), "unotools.config", "OConfigurationValueContainer::implRegisterExchangeLocation: already registered a container for this subnode!" );
// remember the accessor
m_pImpl->aAccessors.push_back( _rAccessor );
// and initially fill the value
lcl_copyData( _rAccessor, m_pImpl->aConfigRoot.getNodeValue( _rAccessor.getPath() ), m_pImpl->rMutex );
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.