From f686478f0bdbe0e9d2fc12969fc2fb6da4be0fc9 Mon Sep 17 00:00:00 2001 From: Daria Volvenkova Date: Wed, 28 Jun 2017 20:39:40 +0300 Subject: [PATCH] Minor refactoring. --- map/bookmark.hpp | 71 +++++++++++++++++++++------------------- map/bookmark_manager.cpp | 6 ++-- map/bookmark_manager.hpp | 6 ++-- map/framework.cpp | 2 +- 4 files changed, 44 insertions(+), 41 deletions(-) diff --git a/map/bookmark.hpp b/map/bookmark.hpp index 5b0c1827cc..2b343deb28 100644 --- a/map/bookmark.hpp +++ b/map/bookmark.hpp @@ -10,10 +10,11 @@ #include "base/timer.hpp" -#include "std/string.hpp" #include "std/noncopyable.hpp" -#include "std/iostream.hpp" -#include "std/shared_ptr.hpp" + +#include +#include +#include namespace anim { @@ -31,9 +32,11 @@ public: { } - BookmarkData(string const & name, string const & type, - string const & description = "", double scale = -1.0, - time_t timeStamp = my::INVALID_TIME_STAMP) + BookmarkData(std::string const & name, + std::string const & type, + std::string const & description = "", + double scale = -1.0, + time_t timeStamp = my::INVALID_TIME_STAMP) : m_name(name) , m_description(description) , m_type(type) @@ -42,14 +45,14 @@ public: { } - string const & GetName() const { return m_name; } - void SetName(const string & name) { m_name = name; } + std::string const & GetName() const { return m_name; } + void SetName(const std::string & name) { m_name = name; } - string const & GetDescription() const { return m_description; } - void SetDescription(const string & description) { m_description = description; } + std::string const & GetDescription() const { return m_description; } + void SetDescription(const std::string & description) { m_description = description; } - string const & GetType() const { return m_type; } - void SetType(const string & type) { m_type = type; } + std::string const & GetType() const { return m_type; } + void SetType(const std::string & type) { m_type = type; } double const & GetScale() const { return m_scale; } void SetScale(double scale) { m_scale = scale; } @@ -58,9 +61,9 @@ public: void SetTimeStamp(const time_t & timeStamp) { m_timeStamp = timeStamp; } private: - string m_name; - string m_description; - string m_type; ///< Now it stores bookmark color (category style). + std::string m_name; + std::string m_description; + std::string m_type; ///< Now it stores bookmark color (category style). double m_scale; ///< Viewport scale. -1.0 - is a default value (no scale set). time_t m_timeStamp; }; @@ -78,21 +81,21 @@ public: BookmarkData const & GetData() const; dp::Anchor GetAnchor() const override; - string GetSymbolName() const override; + std::string GetSymbolName() const override; Type GetMarkType() const override; bool HasCreationAnimation() const override; void SetCreationAnimationShown(bool shown); - string const & GetName() const; - void SetName(string const & name); + std::string const & GetName() const; + void SetName(std::string const & name); /// @return Now its a bookmark color - name of icon file - string const & GetType() const; - void SetType(string const & type); + std::string const & GetType() const; + void SetType(std::string const & type); m2::RectD GetViewport() const; - string const & GetDescription() const; - void SetDescription(string const & description); + std::string const & GetDescription() const; + void SetDescription(std::string const & description); /// @return my::INVALID_TIME_STAMP if bookmark has no timestamp time_t GetTimeStamp() const; @@ -109,11 +112,11 @@ private: class BookmarkCategory : public UserMarkContainer { typedef UserMarkContainer TBase; - vector> m_tracks; + vector> m_tracks; - string m_name; + std::string m_name; /// Stores file name from which category was loaded - string m_file; + std::string m_file; public: class Guard @@ -136,13 +139,13 @@ public: BookmarkCategory & m_cat; }; - BookmarkCategory(string const & name, Framework & framework); + BookmarkCategory(std::string const & name, Framework & framework); ~BookmarkCategory() override; size_t GetUserLineCount() const override; df::UserLineMark const * GetUserLineMark(size_t index) const override; - static string GetDefaultType(); + static std::string GetDefaultType(); void ClearTracks(); @@ -154,27 +157,27 @@ public: void DeleteTrack(size_t index); //@} - void SetName(string const & name) { m_name = name; } - string const & GetName() const { return m_name; } - string const & GetFileName() const { return m_file; } + void SetName(std::string const & name) { m_name = name; } + std::string const & GetName() const { return m_name; } + std::string const & GetFileName() const { return m_file; } /// @name Theese fuctions are public for unit tests only. /// You don't need to call them from client code. //@{ bool LoadFromKML(ReaderPtr const & reader); - void SaveToKML(ostream & s); + void SaveToKML(std::ostream & s); /// Uses the same file name from which was loaded, or /// creates unique file name on first save and uses it every time. bool SaveToKMLFile(); /// @return 0 in the case of error - static BookmarkCategory * CreateFromKMLFile(string const & file, Framework & framework); + static BookmarkCategory * CreateFromKMLFile(std::string const & file, Framework & framework); /// Get valid file name from input (remove illegal symbols). - static string RemoveInvalidSymbols(string const & name); + static std::string RemoveInvalidSymbols(std::string const & name); /// Get unique bookmark file name from path and valid file name. - static string GenerateUniqueFileName(const string & path, string name); + static std::string GenerateUniqueFileName(const std::string & path, std::string name); //@} protected: diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index b2a3c04027..63a8215cc8 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -32,7 +32,7 @@ BookmarkManager::~BookmarkManager() { m_userMarkLayers.clear(); - ClearItems(); + ClearCategories(); } namespace @@ -53,14 +53,14 @@ void BookmarkManager::LoadState() UNUSED_VALUE(settings::Get(BOOKMARK_TYPE, m_lastType)); } -void BookmarkManager::ClearItems() +void BookmarkManager::ClearCategories() { m_categories.clear(); } void BookmarkManager::LoadBookmarks() { - ClearItems(); + ClearCategories(); string const dir = GetPlatform().SettingsDir(); diff --git a/map/bookmark_manager.hpp b/map/bookmark_manager.hpp index 12ce09fee0..85dc54588a 100644 --- a/map/bookmark_manager.hpp +++ b/map/bookmark_manager.hpp @@ -3,8 +3,8 @@ #include "map/bookmark.hpp" #include "map/user_mark_container.hpp" -#include "std/function.hpp" -#include "std/unique_ptr.hpp" +#include +#include class Framework; @@ -33,7 +33,7 @@ public: BookmarkManager(Framework & f); ~BookmarkManager(); - void ClearItems(); + void ClearCategories(); void PrepareToShutdown(); diff --git a/map/framework.cpp b/map/framework.cpp index b9f94e1b15..e5dd799c04 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1040,7 +1040,7 @@ void Framework::ShowTrack(Track const & track) void Framework::ClearBookmarks() { - m_bmManager.ClearItems(); + m_bmManager.ClearCategories(); } namespace