diff options
author | ExMix <rahuba.youri@mapswithme.com> | 2014-05-13 14:31:41 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:15:35 +0300 |
commit | 369d5da2473f4d4c3de6fb3feb0907eab54fd41d (patch) | |
tree | 65a6748a22fb49c9c4f85c1d3add90baba06a7da /map/user_mark.hpp | |
parent | 6b4563e0d0a2df0b5d89378706c8407c390d1327 (diff) |
[core] new way of bookmark, search results and api points store
Diffstat (limited to 'map/user_mark.hpp')
-rw-r--r-- | map/user_mark.hpp | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/map/user_mark.hpp b/map/user_mark.hpp new file mode 100644 index 0000000000..3490985729 --- /dev/null +++ b/map/user_mark.hpp @@ -0,0 +1,114 @@ +#pragma once + +#include "../geometry/point2d.hpp" + +#include "../std/string.hpp" +#include "../std/noncopyable.hpp" + +class UserMarkContainer; + +class UserCustomData +{ +public: + enum Type + { + EMPTY, + POI, + SEARCH, + API, + BOOKMARK + }; + + virtual ~UserCustomData() {} + + virtual Type GetType() const = 0; +}; + +class EmptyCustomData : public UserCustomData +{ +public: + virtual Type GetType() const { return EMPTY; } +}; + +class BaseCustomData : public UserCustomData +{ +public: + BaseCustomData(string const & name, string const & typeName, string address) + : m_name(name) + , m_typeName(typeName) + , m_address(address) {} + + string const & GetName() const { return m_name; } + string const & GetTypeName() const { return m_typeName; } + string const & GetAddress() const { return m_address; } + +private: + string m_name; + string m_typeName; + string m_address; +}; + +class PoiCustomData : public BaseCustomData +{ + typedef BaseCustomData base_t; +public: + PoiCustomData(string const & name, string const & typeName, string address) + : base_t(name, typeName, address) {} + + virtual Type GetType() const { return POI; } +}; + +class SearchCustomData : public BaseCustomData +{ + typedef BaseCustomData base_t; +public: + SearchCustomData(string const & name, string const & typeName, string address) + : base_t(name, typeName, address) {} + + virtual Type GetType() const { return SEARCH; } +}; + +class ApiCustomData : public UserCustomData +{ + typedef UserCustomData base_t; +public: + ApiCustomData(string const & name, string const & id) + : m_name(name) + , m_id(id) {} + + virtual Type GetType() const { return API; } + + string const & GetName() const { return m_name; } + string const & GetID() const {return m_id; } + +private: + string m_name; + string m_id; +}; + +class UserMark : private noncopyable +{ +public: + UserMark(m2::PointD const & ptOrg, UserMarkContainer * container); + virtual ~UserMark(); + + UserMarkContainer const * GetContainer() const; + m2::PointD const & GetOrg() const; + void GetLatLon(double & lat, double & lon) const; + + // custom data must be allocated in head + // memory where allocated custom data will be deallocated by UserMark + void InjectCustomData(UserCustomData * customData); + UserCustomData const & GetCustomData() const; + +protected: + friend class BookmarkManager; + void Activate() const; + void Diactivate() const; + UserCustomData & GetCustomData(); + +protected: + m2::PointD m_ptOrg; + mutable UserMarkContainer * m_container; + UserCustomData * m_customData; +}; |