forked from organicmaps/organicmaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditor_notes.hpp
60 lines (44 loc) · 1.4 KB
/
editor_notes.hpp
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
#pragma once
#include "editor/server_api.hpp"
#include "geometry/latlon.hpp"
#include "base/macros.hpp"
#include <list>
#include <memory>
#include <mutex>
#include <string>
namespace editor
{
struct Note
{
Note(ms::LatLon const & point, std::string const & text) : m_point(point), m_note(text) {}
ms::LatLon m_point;
std::string m_note;
};
inline bool operator==(Note const & a, Note const & b)
{
return a.m_point == b.m_point && b.m_note == b.m_note;
}
class Notes : public std::enable_shared_from_this<Notes>
{
public:
static float constexpr kTolerance = 1e-7;
static std::shared_ptr<Notes> MakeNotes(std::string const & fileName = "notes.xml",
bool const fullPath = false);
void CreateNote(ms::LatLon const & latLon, std::string const & text);
/// Uploads notes to the server in a separate thread.
/// Called on main thread from system event.
void Upload(osm::OsmOAuth const & auth);
std::list<Note> GetNotes() const;
size_t NotUploadedNotesCount() const;
size_t UploadedNotesCount() const;
private:
explicit Notes(std::string const & fileName);
std::string const m_fileName;
mutable std::mutex m_mu;
// m_notes keeps the notes that have not been uploaded yet.
// Once a note has been uploaded, it is removed from m_notes.
std::list<Note> m_notes;
uint32_t m_uploadedNotesCount = 0;
DISALLOW_COPY_AND_MOVE(Notes);
};
} // namespace