Skip to content

Commit 76ab69b

Browse files
committed
huge simplified app+lib template
forwarding over contructors just one reference
1 parent 5711409 commit 76ab69b

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

application/src/Application.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,21 @@ int main(int argc, char **argv) {
3232
.appPrefix = appName});
3333

3434
auto &logger = utilsComponents.logger;
35-
auto &assetManager = utilsComponents.assetManager;
35+
[[maybe_unused]] auto &assetManager = utilsComponents.assetManager;
3636
auto &platformInfo = utilsComponents.platformInfo;
3737
auto &customStringsLoader = utilsComponents.customStringsLoader;
3838

39-
const std::string notFound = "[Not Found]";
40-
logger->infoStream()
41-
<< customStringsLoader->getLocalizedString("Author", "en").value_or(notFound);
42-
logger->infoStream()
43-
<< customStringsLoader->getLocalizedString("GitHub", "en").value_or(notFound) << " - "
44-
<< customStringsLoader->getCustomKey("GitHub", "url").value_or(notFound);
39+
const std::string na = "[Not Found]";
40+
logger->infoStream() << customStringsLoader->getLocalizedString("Author", "en").value_or(na);
41+
logger->infoStream() << customStringsLoader->getLocalizedString("GitHub", "en").value_or(na)
42+
<< " - "
43+
<< customStringsLoader->getCustomKey("GitHub", "url").value_or(na);
4544

4645
logger->infoStream() << platformInfo->getPlatformName() << " platform detected.";
4746

4847
logger->infoStream() << appName + " started ...";
4948

50-
auto library = std::make_unique<v1::DotNameLib>(logger, assetManager);
49+
auto library = std::make_unique<dotnamecpp::v1::DotNameLib>(utilsComponents);
5150
if (!library->isInitialized()) {
5251
logger->errorStream() << "Library initialization failed";
5352
return EXIT_FAILURE;

include/DotNameLib/DotNameLib.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
#include <memory>
77

88
namespace dotnamecpp::v1 {
9+
using namespace dotnamecpp::utils;
910
class DotNameLib {
1011

1112
public:
12-
DotNameLib(std::shared_ptr<logging::ILogger> logger,
13-
std::shared_ptr<dotnamecpp::assets::IAssetManager> assetManager);
14-
13+
DotNameLib(const UtilsFactory::AppComponents &utilsComponents);
1514
~DotNameLib();
16-
1715
DotNameLib(const DotNameLib &other) = delete;
1816
DotNameLib &operator=(const DotNameLib &other) = delete;
1917
DotNameLib(DotNameLib &&other) = delete;

src/DotNameLib.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace dotnamecpp::v1 {
44

5-
DotNameLib::DotNameLib(std::shared_ptr<logging::ILogger> logger,
6-
std::shared_ptr<dotnamecpp::assets::IAssetManager> assetManager)
7-
: logger_(logger ? std::move(logger) : std::make_shared<dotnamecpp::logging::NullLogger>()),
8-
assetManager_(std::move(assetManager)) {
5+
DotNameLib::DotNameLib(const UtilsFactory::AppComponents &utilsComponents)
6+
: logger_(utilsComponents.logger ? utilsComponents.logger
7+
: std::make_shared<dotnamecpp::logging::NullLogger>()),
8+
assetManager_(utilsComponents.assetManager) {
99

1010
if (!assetManager_ || !assetManager_->validate()) {
1111
logger_->errorStream() << "Invalid or missing asset manager";

0 commit comments

Comments
 (0)