Senzing C++ SDK
C++ SDK for Senzing v4, patterned after the official C# SDK
Loading...
Searching...
No Matches
SzCoreConfigManager.hpp
Go to the documentation of this file.
1// SzCoreConfigManager.hpp -- native-backed SzConfigManager implementation.
2//
3// Ports core/SzCoreConfigManager.cs. Owns the native SzConfig_* module (for
4// create/load) and lazily the SzConfigMgr_* module (for the persisted config
5// registry / default config ID). Both native modules are initialized with the
6// owning environment's instance name / settings / verbose flag. Constructed and
7// lifecycle-managed by SzCoreEnvironment (obtain via GetConfigManager).
8#ifndef SENZING_SDK_CORE_SZCORECONFIGMANAGER_HPP
9#define SENZING_SDK_CORE_SZCORECONFIGMANAGER_HPP
10
11#include <cstdint>
12#include <memory>
13#include <mutex>
14#include <string>
15
17
18namespace senzing::sdk::core {
19
20class SzCoreEnvironment;
21
25public:
30 ~SzCoreConfigManager() override = default;
31
34
35 std::unique_ptr<SzConfig> CreateConfig() override;
36 std::unique_ptr<SzConfig> CreateConfig(
37 const std::string& configDefinition) override;
38 std::unique_ptr<SzConfig> CreateConfig(int64_t configID) override;
39 int64_t RegisterConfig(const std::string& configDefinition,
40 const std::string& configComment) override;
41 int64_t RegisterConfig(const std::string& configDefinition) override;
42 std::string GetConfigRegistry() override;
43 int64_t GetDefaultConfigID() override;
44 void ReplaceDefaultConfigID(int64_t currentDefaultConfigID,
45 int64_t newDefaultConfigID) override;
46 void SetDefaultConfigID(int64_t configID) override;
47 int64_t SetDefaultConfig(const std::string& configDefinition,
48 const std::string& configComment) override;
49 int64_t SetDefaultConfig(const std::string& configDefinition) override;
50
53 void Destroy();
54
56 [[nodiscard]] bool IsDestroyed();
57
58private:
61 void EnsureConfigMgrInitialized();
62
64 std::mutex monitor_;
65 bool configInitialized_{false};
66 bool configMgrInitialized_{false};
67 bool destroyed_{false};
68};
69
70} // namespace senzing::sdk::core
71
72#endif // SENZING_SDK_CORE_SZCORECONFIGMANAGER_HPP
Manages persisted Senzing configurations and the default config registry.
Definition SzConfigManager.hpp:18
Core implementation of SzConfigManager backed by the native SzConfig_* and SzConfigMgr_* modules.
Definition SzCoreConfigManager.hpp:24
SzCoreConfigManager(const SzCoreConfigManager &)=delete
int64_t GetDefaultConfigID() override
Returns the current default configuration ID.
SzCoreConfigManager & operator=(const SzCoreConfigManager &)=delete
void ReplaceDefaultConfigID(int64_t currentDefaultConfigID, int64_t newDefaultConfigID) override
Atomically replaces the default config ID if it currently matches currentDefaultConfigID.
std::unique_ptr< SzConfig > CreateConfig(const std::string &configDefinition) override
Creates an in-memory config from the supplied JSON definition.
int64_t RegisterConfig(const std::string &configDefinition) override
Registers a config definition (auto-generated comment); returns the ID.
std::unique_ptr< SzConfig > CreateConfig() override
Creates a new in-memory config from the registered template.
int64_t RegisterConfig(const std::string &configDefinition, const std::string &configComment) override
Registers a config definition with a comment; returns the new config ID.
std::unique_ptr< SzConfig > CreateConfig(int64_t configID) override
Loads the persisted config with the given ID into a new in-memory config.
void Destroy()
Destroys both native modules.
int64_t SetDefaultConfig(const std::string &configDefinition, const std::string &configComment) override
Registers configDefinition (with comment) and sets it as default; returns the new config ID.
bool IsDestroyed()
True once the native SzConfig_* module has been destroyed.
std::string GetConfigRegistry() override
Returns JSON describing all registered configurations.
void SetDefaultConfigID(int64_t configID) override
Sets the default configuration ID.
int64_t SetDefaultConfig(const std::string &configDefinition) override
Registers configDefinition (auto comment) and sets it as default.
SzCoreConfigManager(SzCoreEnvironment &env)
Constructs and initializes the native SzConfig_* module using the owning environment's settings.
Core implementation of SzEnvironment backed by the native libSz modules.
Definition SzCoreEnvironment.hpp:29
Definition SzCoreConfig.hpp:20