fb-cpp 0.0.2
A modern C++ wrapper for the Firebird database API
Loading...
Searching...
No Matches
DatabaseManager.h
1/*
2 * MIT License
3 *
4 * Copyright (c) 2026 Popa Adrian Marius
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25#ifndef FBCPP_DATABASE_MANAGER_H
26#define FBCPP_DATABASE_MANAGER_H
27
28#include "ServiceManager.h"
29#include <cstdint>
30#include <optional>
31#include <string>
32
33
37namespace fbcpp
38{
43 {
44 public:
48 const std::string& getDatabase() const
49 {
50 return database;
51 }
52
56 DatabasePropertiesOptions& setDatabase(const std::string& value)
57 {
58 database = value;
59 return *this;
60 }
61
65 const std::optional<ReplicaMode>& getReplicaMode() const
66 {
67 return replicaMode;
68 }
69
74 {
75 replicaMode = value;
76 return *this;
77 }
78
79 private:
80 std::string database;
81 std::optional<ReplicaMode> replicaMode;
82 };
83
88 {
89 public:
93 const std::string& getDatabase() const
94 {
95 return database;
96 }
97
101 DatabaseRepairOptions& setDatabase(const std::string& value)
102 {
103 database = value;
104 return *this;
105 }
106
111 {
112 return verboseOutput;
113 }
114
119 {
120 verboseOutput = std::move(value);
121 return *this;
122 }
123
127 const std::optional<std::uint32_t>& getParallelWorkers() const
128 {
129 return parallelWorkers;
130 }
131
136 {
137 parallelWorkers = value;
138 return *this;
139 }
140
144 bool getSweep() const
145 {
146 return sweep;
147 }
148
153 {
154 sweep = value;
155 return *this;
156 }
157
161 bool getValidate() const
162 {
163 return validate;
164 }
165
170 {
171 validate = value;
172 return *this;
173 }
174
178 bool getMend() const
179 {
180 return mend;
181 }
182
187 {
188 mend = value;
189 return *this;
190 }
191
195 bool getIgnoreChecksum() const
196 {
197 return ignoreChecksum;
198 }
199
204 {
205 ignoreChecksum = value;
206 return *this;
207 }
208
212 bool getKillShadows() const
213 {
214 return killShadows;
215 }
216
221 {
222 killShadows = value;
223 return *this;
224 }
225
229 bool getFull() const
230 {
231 return full;
232 }
233
238 {
239 full = value;
240 return *this;
241 }
242
246 bool getCheckDb() const
247 {
248 return checkDb;
249 }
250
255 {
256 checkDb = value;
257 return *this;
258 }
259
263 bool getIcu() const
264 {
265 return icu;
266 }
267
272 {
273 icu = value;
274 return *this;
275 }
276
280 bool getUpgradeDb() const
281 {
282 return upgradeDb;
283 }
284
289 {
290 upgradeDb = value;
291 return *this;
292 }
293
294 private:
295 std::string database;
296 ServiceManager::VerboseOutput verboseOutput;
297 std::optional<std::uint32_t> parallelWorkers;
298 bool sweep = false;
299 bool validate = false;
300 bool mend = false;
301 bool ignoreChecksum = false;
302 bool killShadows = false;
303 bool full = false;
304 bool checkDb = false;
305 bool icu = false;
306 bool upgradeDb = false;
307 };
308
312 class DatabaseManager final : public ServiceManager
313 {
314 public:
316
317 public:
321 void setProperties(const DatabasePropertiesOptions& options);
322
326 void repair(const DatabaseRepairOptions& options);
327 };
328} // namespace fbcpp
329
330
331#endif // FBCPP_DATABASE_MANAGER_H
Executes configuration and maintenance operations through the Firebird service manager.
void setProperties(const DatabasePropertiesOptions &options)
Configures database properties using the provided options.
void repair(const DatabaseRepairOptions &options)
Runs a repair operation using the provided options.
Represents options used to configure database properties through the service manager.
const std::string & getDatabase() const
Returns the database path to be configured.
DatabasePropertiesOptions & setReplicaMode(ReplicaMode value)
Sets the replica mode.
const std::optional< ReplicaMode > & getReplicaMode() const
Returns the replica mode.
DatabasePropertiesOptions & setDatabase(const std::string &value)
Sets the database path to be configured.
Represents options used to run a database maintenance operation through the service manager.
DatabaseRepairOptions & setFull(bool value)
Sets whether full validation should be run.
bool getIgnoreChecksum() const
Returns whether checksum verification is configured to be ignored.
DatabaseRepairOptions & setKillShadows(bool value)
Sets whether killing database shadows should be run.
DatabaseRepairOptions & setUpgradeDb(bool value)
Sets whether database upgrade should be run.
const std::optional< std::uint32_t > & getParallelWorkers() const
Returns the requested number of parallel workers.
DatabaseRepairOptions & setSweep(bool value)
Sets whether database sweep should be run.
DatabaseRepairOptions & setVerboseOutput(ServiceManager::VerboseOutput value)
Sets the verbose output callback.
bool getUpgradeDb() const
Returns whether database upgrade is configured to be run.
DatabaseRepairOptions & setCheckDb(bool value)
Sets whether checking only metadata/structure should be run.
const ServiceManager::VerboseOutput & getVerboseOutput() const
Returns the verbose output callback.
bool getValidate() const
Returns whether database validation is configured to be run.
bool getCheckDb() const
Returns whether checking only metadata/structure is configured to be run.
bool getKillShadows() const
Returns whether killing database shadows is configured to be run.
bool getSweep() const
Returns whether database sweep is configured to be run.
const std::string & getDatabase() const
Returns the database path to be maintained.
DatabaseRepairOptions & setIcu(bool value)
Sets whether recreating ICU indexes should be run.
DatabaseRepairOptions & setIgnoreChecksum(bool value)
Sets whether checksum verification should be ignored.
bool getIcu() const
Returns whether recreating ICU indexes is configured to be run.
bool getMend() const
Returns whether database mending is configured to be run.
DatabaseRepairOptions & setParallelWorkers(std::uint32_t value)
Sets the requested number of parallel workers.
DatabaseRepairOptions & setMend(bool value)
Sets whether database mending should be run.
bool getFull() const
Returns whether full validation is configured to be run.
DatabaseRepairOptions & setDatabase(const std::string &value)
Sets the database path to be maintained.
DatabaseRepairOptions & setValidate(bool value)
Sets whether database validation should be run.
Represents a connection to the Firebird service manager.
ServiceManager(Client &client, const ServiceManagerOptions &options={})
Attaches to the service manager specified by the given options.
std::function< void(std::string_view line)> VerboseOutput
Function invoked when a verbose service output line is available.
fb-cpp namespace.
Definition Attachment.h:45
ReplicaMode
Replica mode.