DotNameLib
Loading...
Searching...
No Matches
UtilsFactory.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <DotNameLib/version.h>
16#include <filesystem>
17#include <memory>
18
19namespace dotnamecpp::utils {
20
21 // Import types from other namespaces
22 using dotnamecpp::assets::IAssetManager;
23 using dotnamecpp::logging::ILogger;
24 using dotnamecpp::logging::LoggerConfig;
26
28 public:
29 // Filesystem factories
30 [[nodiscard]]
31 static std::shared_ptr<IFileReader> createFileReader();
32 [[nodiscard]]
33 static std::shared_ptr<IFileWriter> createFileWriter();
34 [[nodiscard]]
35 static std::shared_ptr<IPathResolver> createPathResolver();
36 [[nodiscard]]
37 static std::shared_ptr<IDirectoryManager> createDirectoryManager();
38
39 // Platform factories
40 [[nodiscard]]
41 static std::unique_ptr<IPlatformInfo> createPlatformInfo();
42 [[nodiscard]]
43 static std::unique_ptr<IPlatformInfo> createPlatformInfo(Platform platform);
44
45 // Assets factories
46 [[nodiscard]]
47 static std::shared_ptr<IAssetManager>
48 createAssetManager(const std::filesystem::path &executablePath, const std::string &appName);
49
50 // JSON factories
51 [[nodiscard]]
52 static std::shared_ptr<IJsonSerializer> createJsonSerializer();
53 [[nodiscard]]
54 static std::shared_ptr<ICustomStringsLoader>
55 createCustomStringsLoader(std::shared_ptr<IAssetManager> assetManager,
56 const std::string &filename = "customstrings.json");
57
58 // String factories
59 [[nodiscard]]
60 static std::shared_ptr<IStringFormatter> createStringFormatter();
61
62 // Logger factories
63 [[nodiscard]]
64 static std::shared_ptr<ILogger> createLogger(LoggerType type, const LoggerConfig &config);
65 [[nodiscard]]
66 static std::shared_ptr<ILogger> createDefaultLogger();
67
68 // Application initialization helper
70 std::shared_ptr<ILogger> logger;
71 std::shared_ptr<IAssetManager> assetManager;
72 std::unique_ptr<IPlatformInfo> platformInfo;
73 };
74
81 [[nodiscard]]
82 static AppComponents createAppComponents(const std::string &appName,
83 const LoggerConfig &loggerConfig);
84
85 // Convenience: Create complete utility set
86 struct UtilsBundle {
87 std::shared_ptr<IFileReader> fileReader;
88 std::shared_ptr<IFileWriter> fileWriter;
89 std::shared_ptr<IPathResolver> pathResolver;
90 std::shared_ptr<IDirectoryManager> directoryManager;
91 std::unique_ptr<IPlatformInfo> platformInfo;
92 std::shared_ptr<IJsonSerializer> jsonSerializer;
93 std::shared_ptr<IStringFormatter> stringFormatter;
94 std::shared_ptr<ILogger> logger;
95 };
96
97 [[nodiscard]]
99 };
100
101} // namespace dotnamecpp::utils
Definition UtilsFactory.hpp:27
static std::shared_ptr< IPathResolver > createPathResolver()
Definition UtilsFactory.cpp:24
static std::unique_ptr< IPlatformInfo > createPlatformInfo()
Definition UtilsFactory.cpp:33
static std::shared_ptr< IDirectoryManager > createDirectoryManager()
Definition UtilsFactory.cpp:28
static AppComponents createAppComponents(const std::string &appName, const LoggerConfig &loggerConfig)
Create complete application components.
Definition UtilsFactory.cpp:86
static std::shared_ptr< ILogger > createDefaultLogger()
Definition UtilsFactory.cpp:76
static std::shared_ptr< IJsonSerializer > createJsonSerializer()
Definition UtilsFactory.cpp:49
static std::shared_ptr< IFileWriter > createFileWriter()
Definition UtilsFactory.cpp:20
static std::shared_ptr< ILogger > createLogger(LoggerType type, const LoggerConfig &config)
Definition UtilsFactory.cpp:72
static std::shared_ptr< IFileReader > createFileReader()
Definition UtilsFactory.cpp:16
static std::shared_ptr< IAssetManager > createAssetManager(const std::filesystem::path &executablePath, const std::string &appName)
Definition UtilsFactory.cpp:43
static std::shared_ptr< IStringFormatter > createStringFormatter()
Definition UtilsFactory.cpp:67
static UtilsBundle createBundle()
Definition UtilsFactory.cpp:108
static std::shared_ptr< ICustomStringsLoader > createCustomStringsLoader(std::shared_ptr< IAssetManager > assetManager, const std::string &filename="customstrings.json")
Definition UtilsFactory.cpp:56
LoggerType
Definition LoggerFactory.hpp:8
Definition DirectoryManager.cpp:5
Platform
Definition IPlatformInfo.hpp:10
Configuration options for creating a logger.
Definition LoggerFactory.hpp:13
std::shared_ptr< ILogger > logger
Definition UtilsFactory.hpp:70
std::unique_ptr< IPlatformInfo > platformInfo
Definition UtilsFactory.hpp:72
std::shared_ptr< IAssetManager > assetManager
Definition UtilsFactory.hpp:71
Definition UtilsFactory.hpp:86
std::unique_ptr< IPlatformInfo > platformInfo
Definition UtilsFactory.hpp:91
std::shared_ptr< ILogger > logger
Definition UtilsFactory.hpp:94
std::shared_ptr< IStringFormatter > stringFormatter
Definition UtilsFactory.hpp:93
std::shared_ptr< IFileWriter > fileWriter
Definition UtilsFactory.hpp:88
std::shared_ptr< IPathResolver > pathResolver
Definition UtilsFactory.hpp:89
std::shared_ptr< IDirectoryManager > directoryManager
Definition UtilsFactory.hpp:90
std::shared_ptr< IJsonSerializer > jsonSerializer
Definition UtilsFactory.hpp:92
std::shared_ptr< IFileReader > fileReader
Definition UtilsFactory.hpp:87