Skip to content

Commit

Permalink
♻️ (config): Move Config struct in own header + clean up includes
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Apr 13, 2022
1 parent a865c4d commit 8e1ecbb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
28 changes: 28 additions & 0 deletions libs/ConfigKit/include/Config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Leka - LekaOS
// Copyright 2022 APF France handicap
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <filesystem>

namespace leka {

struct Config {
public:
explicit Config(const std::filesystem::path &path, uint8_t default_value = 0xFF)
: _path(_default_parent_path / path), _default_value(default_value)
{
// nothing to do
}

[[nodiscard]] auto path() const -> std::filesystem::path { return _path; }
[[nodiscard]] auto default_value() const -> uint8_t { return _default_value; }

private:
const std::filesystem::path _default_parent_path = "/fs/conf";
const std::filesystem::path _path;
const uint8_t _default_value;
};

} // namespace leka
22 changes: 1 addition & 21 deletions libs/ConfigKit/include/ConfigKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,12 @@

#pragma once

#include <cstdint>
#include <filesystem>
#include <optional>
#include <span>

#include "FileManagerKit.h"
#include "interface/platform/File.h"
#include "Config.h"

namespace leka {

struct Config {
public:
explicit Config(const std::filesystem::path &path, uint8_t default_value = 0xFF)
: _path(_default_parent_path / path), _default_value(default_value)
{
}

[[nodiscard]] auto path() const -> std::filesystem::path { return _path; }
[[nodiscard]] auto default_value() const -> uint8_t { return _default_value; }

private:
const std::filesystem::path _default_parent_path = "/fs/conf";
const std::filesystem::path _path;
const uint8_t _default_value;
};

class ConfigKit
{
public:
Expand Down
6 changes: 1 addition & 5 deletions libs/ConfigKit/source/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
// Copyright 2022 APF France handicap
// SPDX-License-Identifier: Apache-2.0

#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <span>

#include "ConfigKit.h"
#include "FileManagerKit.h"

using namespace leka;

Expand Down

0 comments on commit 8e1ecbb

Please sign in to comment.