mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-01-09 14:28:52 -05:00
added weakptr link to settings and checks
it wont crash on deinitialized setings now
Pseuto UT are passing
Added:
- deregistration on Settings destrution
- weak referencing of Service to not crash Settings on missuse
- Proxy as initialization parameter to Settings
Unused code removed
Enabled tests to be written for Settings
Removed dependency from freertos in test global file
EntryPath tests updated and compilation slimed
41 lines
1.2 KiB
C++
41 lines
1.2 KiB
C++
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#include "service-db/EntryPath.hpp"
|
|
#include <Split.hpp>
|
|
#include <tuple>
|
|
|
|
namespace settings
|
|
{
|
|
|
|
void EntryPath::parse(const std::string &dbPath)
|
|
{
|
|
auto parts = utils::split(dbPath, "\\", false);
|
|
if (1 == parts.size()) {
|
|
variable = dbPath;
|
|
scope = SettingsScope::Global;
|
|
}
|
|
else {
|
|
mode = parts[0];
|
|
service = parts[1];
|
|
profile = parts[2];
|
|
variable = parts[3];
|
|
scope = SettingsScope::AppLocal;
|
|
}
|
|
}
|
|
|
|
bool operator<(const EntryPath &lhs, const EntryPath &rhs) noexcept
|
|
{
|
|
if (lhs.scope != rhs.scope) {
|
|
return lhs.scope < rhs.scope;
|
|
}
|
|
|
|
// Scopes are equal - compare other internals.
|
|
if (lhs.scope == SettingsScope::AppLocal) {
|
|
return std::tie(lhs.scope, lhs.mode, lhs.service, lhs.profile, lhs.variable) <
|
|
std::tie(rhs.scope, rhs.mode, rhs.service, rhs.profile, rhs.variable);
|
|
}
|
|
return lhs.variable < rhs.variable;
|
|
}
|
|
} // namespace settings
|