cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / inc / tools / ConfigurationAccess.hxx
blob97b5e92dc04143eb65bb2052c19c7cb37aa020ac
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <rtl/ustring.hxx>
23 #include <com/sun/star/uno/XInterface.hpp>
25 #include <vector>
26 #include <functional>
28 namespace com::sun::star::container { class XHierarchicalNameAccess; }
29 namespace com::sun::star::container { class XNameAccess; }
30 namespace com::sun::star::lang { class XMultiServiceFactory; }
31 namespace com::sun::star::uno { class XComponentContext; }
33 namespace sd::tools {
35 /** This class gives access to the configuration. Create an object of this
36 class for one node of the configuration. This will be the root node.
37 Its children are then accessible through the new ConfigurationAccess
38 object.
40 class ConfigurationAccess
42 public:
43 enum WriteMode { READ_WRITE, READ_ONLY };
45 /** Create a new object to access the configuration entries below the
46 given root.
47 @param rsRootName
48 Name of the root.
49 @param eMode
50 This flag specifies whether to give read-write or read-only
51 access.
53 ConfigurationAccess(
54 const OUString& rsRootName,
55 const WriteMode eMode);
57 /** Return a configuration node below the root of the called object.
58 @param rsPathToNode
59 The relative path from the root (as given the constructor) to
60 the node.
61 @return
62 The type of the returned node varies with the requested node.
63 It is empty when the node was not found.
65 css::uno::Any GetConfigurationNode (
66 const OUString& rsPathToNode);
68 /** Return a configuration node below the given node.
69 @param rxNode
70 The node that acts as root to the given relative path.
71 @param rsPathToNode
72 The relative path from the given node to the requested node.
73 @return
74 The type of the returned node varies with the requested node.
75 It is empty when the node was not found.
77 static css::uno::Any GetConfigurationNode (
78 const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxNode,
79 const OUString& rsPathToNode);
81 /** Write any changes that have been made back to the configuration.
82 This call is ignored when the called ConfigurationAccess object was
83 not create with read-write mode.
85 void CommitChanges();
87 /** This functor is typically called for every item in a set. Its two
88 parameters are the name of key item (often of no further interest)
89 and the value of the item.
91 typedef ::std::function<void (
92 const OUString&,
93 const std::vector<css::uno::Any>&) > Functor;
95 private:
96 css::uno::Reference<css::uno::XInterface> mxRoot;
98 void Initialize (
99 const css::uno::Reference<css::lang::XMultiServiceFactory>& rxProvider,
100 const OUString& rsRootName,
101 const WriteMode eMode);
104 } // end of namespace sd::tools
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */