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

user_marks_provider.hpp « drape_frontend - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8a9b45e4a7f1a157045a58817853f1c8ceb6a3e1 (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
77
78
79
80
81
82
83
#pragma once

#include "drape/drape_global.hpp"

#include "geometry/point2d.hpp"

#include "base/mutex.hpp"

#include "std/atomic.hpp"

namespace df
{

class UserPointMark
{
public:
  virtual ~UserPointMark() {}
  virtual m2::PointD const & GetPivot() const = 0;
  virtual m2::PointD GetPixelOffset() const = 0;
  virtual string GetSymbolName() const  = 0;
  virtual dp::Anchor GetAnchor() const = 0;
  virtual float GetDepth() const = 0;
  virtual bool RunCreationAnim() const = 0;
};

class UserLineMark
{
public:
  virtual ~UserLineMark() {}

  virtual size_t GetLayerCount() const = 0;
  virtual dp::Color const & GetColor(size_t layerIndex) const = 0;
  virtual float GetWidth(size_t layerIndex) const = 0;
  virtual float GetLayerDepth(size_t layerIndex) const = 0;

  /// Line geometry enumeration
  virtual size_t GetPointCount() const = 0;
  virtual m2::PointD const & GetPoint(size_t pointIndex) const = 0;
};

class UserMarksProvider
{
public:
  UserMarksProvider();
  virtual ~UserMarksProvider() {}

  void BeginRead();

  bool IsDirty() const;
  virtual bool IsDrawable() const = 0;

  virtual size_t GetUserPointCount() const = 0;
  /// never store UserPointMark reference
  virtual UserPointMark const * GetUserPointMark(size_t index) const = 0;

  virtual size_t GetUserLineCount() const = 0;
  /// never store UserLineMark reference
  virtual UserLineMark const * GetUserLineMark(size_t index) const = 0;

  void EndRead();

  void IncrementCounter();
  void DecrementCounter();
  bool CanBeDeleted();
  bool IsPendingOnDelete();
  void DeleteLater();

protected:
  void BeginWrite();
  void SetDirty();
  void EndWrite();

private:
  void Lock();
  void Unlock();

  threads::Mutex m_mutex;
  bool m_isDirty = false;
  atomic<bool> m_pendingOnDelete;
  atomic<int> m_counter;
};

} // namespace df