Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / desktop / source / deployment / registry / inc / dp_backenddb.hxx
blob53ee5e56569d2547d5a40b63cd5f3deebf07da17
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 #ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_REGISTRY_INC_DP_BACKENDDB_HXX
21 #define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_REGISTRY_INC_DP_BACKENDDB_HXX
23 #include <rtl/ustring.hxx>
24 #include <deque>
25 #include <vector>
27 namespace com { namespace sun { namespace star {
28 namespace uno {
29 class XComponentContext;
31 namespace xml { namespace dom {
32 class XDocument;
33 class XNode;
35 namespace xml { namespace xpath {
36 class XXPathAPI;
38 }}}
40 namespace dp_registry {
41 namespace backend {
43 class BackendDb
45 private:
47 css::uno::Reference<css::xml::dom::XDocument> m_doc;
48 css::uno::Reference<css::xml::xpath::XXPathAPI> m_xpathApi;
50 BackendDb(BackendDb const &) = delete;
51 BackendDb & operator = (BackendDb const &) = delete;
53 protected:
54 const css::uno::Reference<css::uno::XComponentContext> m_xContext;
55 OUString m_urlDb;
57 protected:
59 /* caller must make sure that only one thread accesses the function
61 css::uno::Reference<css::xml::dom::XDocument> const & getDocument();
63 /* the namespace prefix is "reg" (without quotes)
65 css::uno::Reference<css::xml::xpath::XXPathAPI> const & getXPathAPI();
66 void save();
67 void removeElement(OUString const & sXPathExpression);
69 css::uno::Reference<css::xml::dom::XNode> getKeyElement(
70 OUString const & url);
72 void writeSimpleList(
73 std::deque< OUString> const & list,
74 OUString const & sListTagName,
75 OUString const & sMemberTagName,
76 css::uno::Reference<css::xml::dom::XNode> const & xParent);
78 void writeVectorOfPair(
79 std::vector< std::pair< OUString, OUString > > const & vecPairs,
80 OUString const & sVectorTagName,
81 OUString const & sPairTagName,
82 OUString const & sFirstTagName,
83 OUString const & sSecondTagName,
84 css::uno::Reference<css::xml::dom::XNode> const & xParent);
86 void writeSimpleElement(
87 OUString const & sElementName, OUString const & value,
88 css::uno::Reference<css::xml::dom::XNode> const & xParent);
90 css::uno::Reference<css::xml::dom::XNode> writeKeyElement(
91 OUString const & url);
93 OUString readSimpleElement(
94 OUString const & sElementName,
95 css::uno::Reference<css::xml::dom::XNode> const & xParent);
97 std::vector< std::pair< OUString, OUString > >
98 readVectorOfPair(
99 css::uno::Reference<css::xml::dom::XNode> const & parent,
100 OUString const & sListTagName,
101 OUString const & sPairTagName,
102 OUString const & sFirstTagName,
103 OUString const & sSecondTagName);
105 std::deque< OUString> readList(
106 css::uno::Reference<css::xml::dom::XNode> const & parent,
107 OUString const & sListTagName,
108 OUString const & sMemberTagName);
110 /* returns the values of one particularly child element of all key elements.
112 std::vector< OUString> getOneChildFromAllEntries(
113 OUString const & sElementName);
116 /* returns the namespace which is to be written as xmlns attribute
117 into the root element.
119 virtual OUString getDbNSName()=0;
120 /* return the namespace prefix which is to be registered with the XPath API.
122 The prefix can then be used in XPath expressions.
124 virtual OUString getNSPrefix()=0;
125 /* returns the name of the root element without any namespace prefix.
127 virtual OUString getRootElementName()=0;
128 /* returns the name of xml element for each entry
130 virtual OUString getKeyElementName()=0;
132 public:
133 BackendDb(css::uno::Reference<css::uno::XComponentContext> const & xContext,
134 OUString const & url);
135 virtual ~BackendDb() {};
137 void removeEntry(OUString const & url);
139 /* This is called to write the "revoked" attribute to the entry.
140 This is done when XPackage::revokePackage is called.
142 void revokeEntry(OUString const & url);
144 /* returns false if the entry does not exist yet.
146 bool activateEntry(OUString const & url);
148 bool hasActiveEntry(OUString const & url);
152 class RegisteredDb: public BackendDb
155 public:
156 RegisteredDb( css::uno::Reference<css::uno::XComponentContext> const & xContext,
157 OUString const & url);
160 void addEntry(OUString const & url);
165 #endif
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */