diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-10-30 15:47:38 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-10-30 15:52:26 +1100 |
| commit | b58c08150853b8055093dc116d407ffd543f8ec8 (patch) | |
| tree | 9b82d130d2c833fc234bca0f12f0fba1b7202c4d /src/system_fsm | |
| parent | 18d90051c9145ead86d4da701a2bc54f45e4fb66 (diff) | |
| download | tangara-fw-b58c08150853b8055093dc116d407ffd543f8ec8.tar.gz | |
add locale-aware colation to db indexes
Diffstat (limited to 'src/system_fsm')
| -rw-r--r-- | src/system_fsm/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/system_fsm/booting.cpp | 2 | ||||
| -rw-r--r-- | src/system_fsm/include/service_locator.hpp | 11 | ||||
| -rw-r--r-- | src/system_fsm/running.cpp | 4 |
4 files changed, 16 insertions, 3 deletions
diff --git a/src/system_fsm/CMakeLists.txt b/src/system_fsm/CMakeLists.txt index 449e14cc..8535a0e7 100644 --- a/src/system_fsm/CMakeLists.txt +++ b/src/system_fsm/CMakeLists.txt @@ -5,5 +5,5 @@ idf_component_register( SRCS "system_fsm.cpp" "running.cpp" "booting.cpp" "idle.cpp" "service_locator.cpp" INCLUDE_DIRS "include" - REQUIRES "tinyfsm" "drivers" "database" "ui" "result" "events" "audio" "app_console" "battery") + REQUIRES "tinyfsm" "drivers" "database" "ui" "result" "events" "audio" "app_console" "battery" "locale") target_compile_options(${COMPONENT_LIB} PRIVATE ${EXTRA_WARNINGS}) diff --git a/src/system_fsm/booting.cpp b/src/system_fsm/booting.cpp index 82d83836..893a4560 100644 --- a/src/system_fsm/booting.cpp +++ b/src/system_fsm/booting.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: GPL-3.0-only */ +#include "collation.hpp" #include "system_fsm.hpp" #include <stdint.h> @@ -76,6 +77,7 @@ auto Booting::entry() -> void { sServices->track_queue(std::make_unique<audio::TrackQueue>()); sServices->tag_parser(std::make_unique<database::TagParserImpl>()); + sServices->collator(locale::CreateCollator()); ESP_LOGI(kTag, "init bluetooth"); sServices->bluetooth(std::make_unique<drivers::Bluetooth>(sServices->nvs())); diff --git a/src/system_fsm/include/service_locator.hpp b/src/system_fsm/include/service_locator.hpp index 1dcf0f5e..24dc1eb9 100644 --- a/src/system_fsm/include/service_locator.hpp +++ b/src/system_fsm/include/service_locator.hpp @@ -10,6 +10,7 @@ #include "battery.hpp" #include "bluetooth.hpp" +#include "collation.hpp" #include "database.hpp" #include "gpios.hpp" #include "nvs.hpp" @@ -101,6 +102,15 @@ class ServiceLocator { queue_ = std::move(i); } + auto collator() -> locale::ICollator& { + assert(collator_ != nullptr); + return *collator_; + } + + auto collator(std::unique_ptr<locale::ICollator> i) { + collator_ = std::move(i); + } + // Not copyable or movable. ServiceLocator(const ServiceLocator&) = delete; ServiceLocator& operator=(const ServiceLocator&) = delete; @@ -117,6 +127,7 @@ class ServiceLocator { std::shared_ptr<database::Database> database_; std::unique_ptr<database::ITagParser> tag_parser_; + std::unique_ptr<locale::ICollator> collator_; drivers::SdState sd_; }; diff --git a/src/system_fsm/running.cpp b/src/system_fsm/running.cpp index 567553a9..91cd46af 100644 --- a/src/system_fsm/running.cpp +++ b/src/system_fsm/running.cpp @@ -55,8 +55,8 @@ void Running::entry() { ESP_LOGI(kTag, "opening database"); sFileGatherer = new database::FileGathererImpl(); - auto database_res = - database::Database::Open(*sFileGatherer, sServices->tag_parser()); + auto database_res = database::Database::Open( + *sFileGatherer, sServices->tag_parser(), sServices->collator()); if (database_res.has_error()) { ESP_LOGW(kTag, "failed to open!"); events::System().Dispatch(StorageError{}); |
