Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Pimenov <m@maps.me>2016-05-27 19:40:55 +0300
committerMaxim Pimenov <m@maps.me>2016-05-31 14:54:46 +0300
commitf672cb0b8227ddafcd6b271724dda3e05df9bfef (patch)
tree423ac795cf5da4a96136416827e943040f19a1b5 /search/house_to_street_table.cpp
parent59f40d7669598a229ffa4f6269e17234f9af9506 (diff)
[search] Got rid of the v2 directory and namespace.
Diffstat (limited to 'search/house_to_street_table.cpp')
-rw-r--r--search/house_to_street_table.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/search/house_to_street_table.cpp b/search/house_to_street_table.cpp
new file mode 100644
index 0000000000..6321b0c636
--- /dev/null
+++ b/search/house_to_street_table.cpp
@@ -0,0 +1,69 @@
+#include "search/house_to_street_table.hpp"
+
+#include "indexer/index.hpp"
+
+#include "platform/mwm_traits.hpp"
+
+#include "coding/fixed_bits_ddvector.hpp"
+#include "coding/reader.hpp"
+
+#include "base/assert.hpp"
+
+#include "defines.hpp"
+
+namespace search
+{
+namespace
+{
+class Fixed3BitsTable : public HouseToStreetTable
+{
+public:
+ using TVector = FixedBitsDDVector<3, ModelReaderPtr>;
+
+ Fixed3BitsTable(MwmValue & value)
+ : m_vector(TVector::Create(value.m_cont.GetReader(SEARCH_ADDRESS_FILE_TAG)))
+ {
+ ASSERT(m_vector.get(), ("Can't instantiate FixedBitsDDVector."));
+ }
+
+ // HouseToStreetTable overrides:
+ bool Get(uint32_t houseId, uint32_t & streetIndex) const override
+ {
+ return m_vector->Get(houseId, streetIndex);
+ }
+
+private:
+ unique_ptr<TVector> m_vector;
+};
+
+class DummyTable : public HouseToStreetTable
+{
+public:
+ // HouseToStreetTable overrides:
+ bool Get(uint32_t /* houseId */, uint32_t & /* streetIndex */) const override { return false; }
+};
+} // namespace
+
+unique_ptr<HouseToStreetTable> HouseToStreetTable::Load(MwmValue & value)
+{
+ version::MwmTraits traits(value.GetMwmVersion().GetFormat());
+ auto const format = traits.GetHouseToStreetTableFormat();
+
+ unique_ptr<HouseToStreetTable> result;
+
+ try
+ {
+ if (format == version::MwmTraits::HouseToStreetTableFormat::Fixed3BitsDDVector)
+ result.reset(new Fixed3BitsTable(value));
+ }
+ catch (Reader::OpenException const & ex)
+ {
+ LOG(LWARNING, (ex.Msg()));
+ }
+
+ if (!result)
+ result.reset(new DummyTable());
+ return result;
+}
+
+} // namespace search