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

statistics.hpp « generator - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 74e66229674e8f40126c07fea1a8a707b94ebf6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once

#include "../indexer/feature.hpp"

#include "../std/map.hpp"


namespace stats
{
  struct GeneralInfo
  {
    uint64_t m_count, m_size;

    GeneralInfo() : m_count(0), m_size(0) {}

    void Add(uint64_t sz)
    {
      if (sz > 0)
      {
        ++m_count;
        m_size += sz;
      }
    }
  };

  template <class TKey>
  struct GeneralInfoKey
  {
    TKey m_key;
    GeneralInfo m_info;

    GeneralInfoKey(TKey key) : m_key(key) {}

    bool operator< (GeneralInfoKey const & rhs) const
    {
      return m_key < rhs.m_key;
    }
  };

  struct TypeTag
  {
    uint32_t m_val;

    TypeTag(uint32_t v) : m_val(v) {}

    bool operator< (TypeTag const & rhs) const
    {
      return m_val < rhs.m_val;
    }
  };

  struct MapInfo
  {
    set<GeneralInfoKey<feature::EGeomType> > m_byGeomType;
    set<GeneralInfoKey<TypeTag> > m_byClassifType;
    set<GeneralInfoKey<uint32_t> > m_byPointsCount, m_byTrgCount;

    GeneralInfo m_inner[3];

    template <class TKey, class TSet>
    void AddToSet(TKey key, uint32_t sz, TSet & theSet)
    {
      if (sz > 0)
      {
        // GCC doesn't allow to modify set value ...
        const_cast<GeneralInfo &>(
            theSet.insert(GeneralInfoKey<TKey>(key)).first->m_info).Add(sz);
      }
    }
  };

  void FileContainerStatistic(string const & fPath);

  void CalcStatistic(string const & fPath, MapInfo & info);
  void PrintStatistic(MapInfo & info);
}