All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CityThemeLoader.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include <string>
6 #include <vector>
7 #include "Types.h"
8 #include "ICallback.h"
9 #include "CityThemes.h"
10 #include "Web.h"
11 #include "CityThemeLoader.h"
12 #include "WebLoadRequestCompletionCallback.h"
13 #include "PendingWebRequestsContainer.h"
14 #include "IWorkPool.h"
15 #include "ICityThemeChangedObserver.h"
16 #include "ConfigSections.h"
17 
18 namespace Eegeo
19 {
20  namespace Resources
21  {
22  namespace CityThemes
23  {
24  namespace LoaderState
25  {
26  enum Values
27  {
28  NotStarted,
29  InProgress,
30  Completed,
31  Failed
32  };
33  }
34 
36  {
37  public:
38  CityThemeLoader(const std::string& streamedThemeNameContains,
39  const std::string& streamedThemeStateName,
40  Web::IWebLoadRequestFactory& webRequestFactory,
42  CityThemeRepository& repository,
43  CityThemesUpdater& cityThemesUpdater,
44  CityThemesService& cityThemesService,
45  const Config::CityThemesConfigSection& cityThemesConfig,
46  Helpers::IFileIO& fileIO);
47 
48  ~CityThemeLoader();
49 
50  void LoadThemes(const std::string& url, const std::string& targetThemeNameContains, const std::string& targetStateName);
51 
52  LoaderState::Values GetState() const;
53 
54  bool IsStreaming() const;
55 
56  bool OnThemesLoaded(const EnvironmentThemesData& environmentThemesData);
57 
58  void OnThemeRequested(const CityThemeData& newTheme) { };
59  void OnThemeChanged(const CityThemeData& newTheme);
60 
61  void LoadEmbeddedTheme(const dv3& cameraEcefLocation);
62  void LoadStreamedManifest(const dv3& cameraEcefLocation);
63  void TryApplyTheme();
64  void Update(float dt, const dv3& cameraEcefLocation, const dv3& ecefInterestPoint);
65  bool IsMissingThemeData() const;
66 
67  private:
68  void WebLoadCompletedHandler(Eegeo::Web::IWebResponse& webResponse);
69 
70  Web::IWebLoadRequestFactory& m_webRequestFactory;
72  CityThemeRepository& m_repository;
73  CityThemesUpdater& m_cityThemesUpdater;
74  CityThemesService& m_cityThemesService;
75 
76  const Config::CityThemesConfigSection m_cityThemesConfig;
77  Helpers::IFileIO& m_fileIO;
78 
79  LoaderState::Values m_state;
81  Web::PendingWebRequestsContainer m_pendingWebRequestsContainer;
82 
83  std::string m_targetThemeNameContains;
84  std::string m_targetThemeStateName;
85  std::string m_manifestUrlToLoad;
86  dv3 m_locationLastUpdate;
87 
88  bool m_shouldChangeState;
89  int m_nextManifestId;
90  bool m_hasBegunLoadingStreamedThemes;
91  };
92  }
93  }
94 }