From 0dbd99ac34ba09ed9eb47b82e08ed191150865df Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sat, 14 Oct 2017 11:16:19 +0200 Subject: [PATCH] [DEV] ordered etk::typeInfo --- etk/typeInfo.cpp | 19 +++++++++++++------ etk/typeInfo.hpp | 6 +++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/etk/typeInfo.cpp b/etk/typeInfo.cpp index 92cea2c..02f3621 100644 --- a/etk/typeInfo.cpp +++ b/etk/typeInfo.cpp @@ -8,19 +8,26 @@ #include #include #include +#include -static etk::Vector& getListType() { - static etk::Vector s_list; +static etk::Map& getListElement() { + static etk::Map s_list(0, true, [](etk::Pair* const & _key1, + etk::Pair* const & _key2) { + return strcoll(_key1->first, _key2->first) < 0; + }); return s_list; } -const etk::Vector& etk::getListDeclaredType() { - return getListType(); +etk::Vector etk::getListDeclaredType() { + return getListElement().getKeys(); } size_t etk::addType(const char* _name) { - getListType().pushBack(_name); - return getListType().size(); + size_t id = getListElement().size()+1; + getListElement().set(_name, id); + return id; + // return size_t(_name); + // return getListType().size(); } diff --git a/etk/typeInfo.hpp b/etk/typeInfo.hpp index 680d5af..da00f97 100644 --- a/etk/typeInfo.hpp +++ b/etk/typeInfo.hpp @@ -13,18 +13,18 @@ namespace etk { template class TypeTraitInfo { public: - // Name of the Type + // Name of the type static const char* m_name; // Size of the type static const size_t m_size; - // Dynamic Usnique ID of the Type + // Dynamic unique ID of the Type static const size_t m_id; }; /** * @brief Get list of all type declared in this software. * @return A static list of all register type in the system. */ - const etk::Vector& getListDeclaredType(); + etk::Vector getListDeclaredType(); /** * @brief Add an element declared type in the system database. * @param[in] Name of the type