All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TagService.h
1 // Copyright eeGeo Ltd (2012-2017), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "ITagService.h"
7 #include "IWebLoadRequestFactory.h"
8 #include "SearchTag.h"
9 #include "PoiSearch.h"
10 #include "WebLoadRequestCompletionCallback.h"
11 #include "CallbackCollection.h"
12 #include <string>
13 #include <map>
14 
15 namespace Eegeo
16 {
17  namespace PoiSearch
18  {
19  class TagService : public ITagService
20  {
21  public:
22 
23  TagService(Web::IWebLoadRequestFactory& webRequestFactory,
24  const std::string& manifestUrl,
25  const std::string& defaultReadableTag,
26  const std::string& defaultIconKey);
27  ~TagService();
28 
29  void LoadTags();
30 
31  bool HasLoadedTags() const;
32 
33  bool HasTag(const std::string& tag) const;
34  const std::string& GetDefaultIconKey() const;
35  const std::string& GetDefaultHumanReadableTag() const;
36 
37  bool FindIconKeyByTagsString(const std::string& tagsString, std::string& out_iconKey) const;
38  bool FindHumanReadableTagsByTagString(const std::string& tagsString, std::vector<std::string>& out_readableTags) const;
39 
40  void RegisterTagsLoadedCallback(Helpers::ICallback0& callback);
41  void UnregisterTagsLoadedCallback(Helpers::ICallback0& callback);
42 
43  private:
44 
45  const SearchTag& GetTag(const std::string& tag) const;
46 
47  void OnRequestComplete(Web::IWebResponse& webResponse);
48 
49  Web::IWebLoadRequestFactory& m_webRequestFactory;
50  Eegeo::Web::IWebLoadRequest* m_pRequest;
52 
53  Helpers::CallbackCollection0 m_tagsLoadedCallbacks;
54 
55  std::map<std::string, SearchTag> m_searchTagsMap;
56  std::string m_defaultReadableTag;
57  std::string m_defaultIconKey;
58  const std::string m_manifestUrl;
59  bool m_hasLoadedTags;
60  };
61  }
62 }
63