* Remove version from artifact name * Target C++ 20 and higher * Use cpp string * Better crash implementation * String utils in cpp style * Replace parameter methods with start() method * MutexType to Mutex::Type * Kernel c to cpp style * Cleanup event flag * More cpp conversions * Test fixes * Updated ideas docs
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
#include "ManifestRegistry.h"
|
|
#include "Mutex.h"
|
|
#include "TactilityCore.h"
|
|
#include <unordered_map>
|
|
|
|
#define TAG "app"
|
|
|
|
namespace tt::app {
|
|
|
|
typedef std::unordered_map<std::string, const AppManifest*> AppManifestMap;
|
|
|
|
static AppManifestMap app_manifest_map;
|
|
static Mutex hash_mutex(Mutex::TypeNormal);
|
|
|
|
void addApp(const AppManifest* manifest) {
|
|
TT_LOG_I(TAG, "Registering manifest %s", manifest->id.c_str());
|
|
|
|
hash_mutex.acquire(TtWaitForever);
|
|
app_manifest_map[manifest->id] = manifest;
|
|
hash_mutex.release();
|
|
}
|
|
|
|
_Nullable const AppManifest * findAppById(const std::string& id) {
|
|
hash_mutex.acquire(TtWaitForever);
|
|
auto iterator = app_manifest_map.find(id);
|
|
_Nullable const AppManifest* result = iterator != app_manifest_map.end() ? iterator->second : nullptr;
|
|
hash_mutex.release();
|
|
return result;
|
|
}
|
|
|
|
std::vector<const AppManifest*> getApps() {
|
|
std::vector<const AppManifest*> manifests;
|
|
hash_mutex.acquire(TtWaitForever);
|
|
for (const auto& item: app_manifest_map) {
|
|
manifests.push_back(item.second);
|
|
}
|
|
hash_mutex.release();
|
|
return manifests;
|
|
}
|
|
|
|
} // namespace
|