This commit is contained in:
aozhiwei 2022-12-25 15:37:12 +08:00
parent 48be5120bc
commit f95d61c75f
2 changed files with 18 additions and 1 deletions

View File

@ -4,7 +4,20 @@
IMPL_TABLE(mt::SafeArea) IMPL_TABLE(mt::SafeArea)
std::map<int, const mt::SafeArea*> mt::SafeArea::type_hash_;
namespace mt namespace mt
{ {
void SafeArea::Init1()
{
type_hash_[type()] = this;
}
const SafeArea* SafeArea::GetByType(int type)
{
auto itr = type_hash_.find(type);
return itr != type_hash_.end() ? itr->second : nullptr;
}
} }

View File

@ -11,7 +11,11 @@ namespace mt
"id") "id")
public: public:
static const SafeArea* GetByType(int type) {}; void Init1();
static const SafeArea* GetByType(int type);
private:
static std::map<int, const SafeArea*> type_hash_;
}; };
} }