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

loader.hpp « ugc - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: afcfc7e848c1a32641da9c054fd37049f6b0ac57 (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
#pragma once

#include "ugc/binary/serdes.hpp"
#include "ugc/types.hpp"

#include "indexer/mwm_set.hpp"

#include <map>
#include <memory>
#include <mutex>

class DataSource;
struct FeatureID;

namespace ugc
{
// *NOTE* This class IS thread-safe.
class Loader
{
public:
  Loader(DataSource const & dataSource);
  UGC GetUGC(FeatureID const & featureId);

private:
  struct Entry
  {
    std::mutex m_mutex;
    binary::UGCDeserializer m_deserializer;
  };

  using EntryPtr = std::shared_ptr<Entry>;

  DataSource const & m_dataSource;
  std::map<MwmSet::MwmId, EntryPtr> m_deserializers;
  std::mutex m_mutex;
};
}  // namespace ugc