Repos
C++
979 B37 lines Opens in site
Directory
Raw
Download
#include "app/ScreenRegistry.hpp"
namespace dp {
void ScreenRegistry::add(const std::string& id, Factory factory, bool needsLogin) {
entries_[id] = Entry{std::move(factory), needsLogin};
}
ui::ScreenPtr ScreenRegistry::make(const std::string& id) const {
auto it = entries_.find(id);
return it == entries_.end() ? nullptr : it->second.factory();
}
bool ScreenRegistry::needsLogin(const std::string& id) const {
auto it = entries_.find(id);
return it != entries_.end() && it->second.needsLogin;
}
std::vector<std::string> ScreenRegistry::ids() const {
std::vector<std::string> out;
for (const auto& kv : entries_) out.push_back(kv.first);
return out;
}
ScreenRegistry& ScreenRegistry::instance() {
static ScreenRegistry* registry = [] {
auto* r = new ScreenRegistry();
registerFeedScreens(*r);
registerComposeScreens(*r);
registerSocialScreens(*r);
registerAppScreens(*r);
return r;
}();
return *registry;
}
} // namespace dp