[DEV] ordered etk::typeInfo

This commit is contained in:
Edouard DUPIN 2017-10-14 11:16:19 +02:00
parent 4a62e68b09
commit 0dbd99ac34
2 changed files with 16 additions and 9 deletions

View File

@ -8,19 +8,26 @@
#include <etk/String.hpp>
#include <etk/UString.hpp>
#include <etk/Stream.hpp>
#include <etk/Map.hpp>
static etk::Vector<const char*>& getListType() {
static etk::Vector<const char*> s_list;
static etk::Map<const char*, size_t>& getListElement() {
static etk::Map<const char*, size_t> s_list(0, true, [](etk::Pair<const char*, size_t>* const & _key1,
etk::Pair<const char*, size_t>* const & _key2) {
return strcoll(_key1->first, _key2->first) < 0;
});
return s_list;
}
const etk::Vector<const char*>& etk::getListDeclaredType() {
return getListType();
etk::Vector<const char*> 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();
}

View File

@ -13,18 +13,18 @@ namespace etk {
template<typename ETK_TYPE>
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<const char*>& getListDeclaredType();
etk::Vector<const char*> getListDeclaredType();
/**
* @brief Add an element declared type in the system database.
* @param[in] Name of the type