diff options
author | vng <viktor.govako@gmail.com> | 2011-08-15 18:13:19 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:21:38 +0300 |
commit | e367587b92521e47ef80e11f0c1488507b5ac4c4 (patch) | |
tree | 1717d1f807a8db485afa7e9c14e5870148b0e627 /indexer/types_mapping.hpp | |
parent | 4e8e88052775f4781f8a96e7688b7602db5d4e61 (diff) |
Add additional types mapping (index <-> type) in classificator.
Diffstat (limited to 'indexer/types_mapping.hpp')
-rw-r--r-- | indexer/types_mapping.hpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/indexer/types_mapping.hpp b/indexer/types_mapping.hpp new file mode 100644 index 0000000000..57605c4278 --- /dev/null +++ b/indexer/types_mapping.hpp @@ -0,0 +1,49 @@ +#pragma once +#include "../base/assert.hpp" + +#include "../std/vector.hpp" +#include "../std/map.hpp" + + +class BaseTypeMapper +{ +protected: + virtual void Add(uint32_t ind, uint32_t type) = 0; + +public: + void Load(string const & buffer); +}; + +class Index2Type : public BaseTypeMapper +{ + vector<uint32_t> m_types; + +protected: + virtual void Add(uint32_t ind, uint32_t type); + +public: + uint32_t GetType(uint32_t ind) const + { + ASSERT_LESS ( ind, m_types.size(), () ); + return m_types[ind]; + } +}; + +class Type2Index : public BaseTypeMapper +{ + typedef map<uint32_t, uint32_t> MapT; + MapT m_map; + +protected: + virtual void Add(uint32_t ind, uint32_t type); + +public: + uint32_t GetIndex(uint32_t t) const + { + MapT::const_iterator i = m_map.find(t); + ASSERT ( i != m_map.end(), () ); + return i->second; + } +}; + +void PrintTypesDefault(string const & fPath); |