#include "ManifestRegistry.h" #include "Mutex.h" #include "TactilityCore.h" #include #define TAG "app" namespace tt::app { typedef std::unordered_map 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); if (app_manifest_map[manifest->id] == nullptr) { app_manifest_map[manifest->id] = manifest; } else { TT_LOG_E(TAG, "App id in use: %s", manifest->id.c_str()); } hash_mutex.release(); } _Nullable const AppManifest * findAppById(const std::string& id) { hash_mutex.acquire(TtWaitForever); _Nullable const AppManifest* result = app_manifest_map[id.c_str()]; hash_mutex.release(); return result; } std::vector getApps() { std::vector manifests; hash_mutex.acquire(TtWaitForever); for (const auto& item: app_manifest_map) { manifests.push_back(item.second); } hash_mutex.release(); return manifests; } } // namespace