#include "Instance.h" #include #include namespace tgcalls { namespace { std::function globalLoggingFunction; std::map> &MetaMap() { static auto result = std::map>(); return result; } } // namespace std::vector Meta::Versions() { auto &map = MetaMap(); auto result = std::vector(); result.reserve(map.size()); for (const auto &entry : map) { result.push_back(entry.first); } return result; } int Meta::MaxLayer() { auto result = 0; for (const auto &entry : MetaMap()) { result = std::max(result, entry.second->connectionMaxLayer()); } return result; } std::unique_ptr Meta::Create( const std::string &version, Descriptor &&descriptor) { const auto i = MetaMap().find(version); return (i != MetaMap().end()) ? i->second->construct(std::move(descriptor)) : nullptr; } void Meta::RegisterOne(std::shared_ptr meta) { if (meta) { const auto versions = meta->versions(); for (auto &it : versions) { MetaMap().emplace(it, meta); } } } void SetLoggingFunction(std::function loggingFunction) { globalLoggingFunction = loggingFunction; } } // namespace tgcalls