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

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

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

#include "geometry/rect2d.hpp"

#include <cstdint>
#include <functional>
#include <memory>
#include <string>

enum class FeatureStatus
{
  Untouched,  // The feature hasn't been saved in the editor.
  Deleted,    // The feature has been marked as deleted.
  Obsolete,   // The feature has been marked for deletion via note.
  Modified,   // The feature has been saved in the editor and differs from the original one.
  Created     // The feature was created by a user and has been saved in the editor.
  // Note: If a feature was created by a user but hasn't been saved in the editor yet
  // its status is Untouched.
}; // enum class FeatureStatus

std::string ToString(FeatureStatus fs);
inline std::string DebugPrint(FeatureStatus fs) { return ToString(fs); }

class FeatureSource
{
public:
  explicit FeatureSource(MwmSet::MwmHandle const & handle);
  virtual ~FeatureSource() {}

  size_t GetNumFeatures() const;

  std::unique_ptr<FeatureType> GetOriginalFeature(uint32_t index) const;

  FeatureID GetFeatureId(uint32_t index) const { return FeatureID(m_handle.GetId(), index); }

  virtual FeatureStatus GetFeatureStatus(uint32_t index) const;

  virtual std::unique_ptr<FeatureType> GetModifiedFeature(uint32_t index) const;

  // Runs |fn| for each feature, that is not present in the mwm. 
  virtual void ForEachAdditionalFeature(m2::RectD const & rect, int scale,
                                        std::function<void(uint32_t)> const & fn) const;

protected:
  MwmSet::MwmHandle const & m_handle;
  std::unique_ptr<FeaturesVector> m_vector;
};  // class FeatureSource

// Lightweight FeatureSource factory. Each DataSource owns factory object.
class FeatureSourceFactory
{
public:
  virtual ~FeatureSourceFactory() = default;
  virtual std::unique_ptr<FeatureSource> operator()(MwmSet::MwmHandle const & handle) const
  {
    return std::make_unique<FeatureSource>(handle);
  }
};