All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
BuildingFootprintResourceService.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "BuildingFootprints.h"
7 #include "Web.h"
8 #include "BuildingFootprintWebLoader.h"
9 #include "MortonKey.h"
10 #include "ICallback.h"
11 #include "BuildingFootprintResourceStore.h"
12 #include "Streaming.h"
13 #include "CoverageTrees.h"
14 
15 
16 #include <string>
17 #include <unordered_map>
18 #include <vector>
19 #include <map>
20 
21 
22 namespace Eegeo
23 {
24  namespace BuildingFootprints
25  {
26  struct BuildingFootprintWebLoaderRequest;
27 
28 
29 
31  {
32  public:
33  using CancelHandle = Web::TWebRequestId;
34 
36  {
37  const bool Succeeded;
38  const bool NotFound;
39  const Streaming::MortonKey Key;
40 
41  LoadForKeyResult(bool succeeded, bool notFound, const Streaming::MortonKey& key)
42  : Succeeded(succeeded)
43  , NotFound(notFound)
44  , Key(key)
45  {}
46  };
47 
49 
50 
52  BuildingFootprintRepository& buildingFootprintRepository,
53  const IBuildingFootprintResourceCoverageFactory& buildingFootprintResourceCoverageFactory,
55 
57 
58 
59  virtual CancelHandle LoadForKey(const Eegeo::Streaming::MortonKey& cellKey, ILoadForKeyCallback& callback);
60 
61  virtual void CancelLoad(CancelHandle handle);
62 
63  virtual void DestroyForKey(const Eegeo::Streaming::MortonKey& cellKey);
64 
65  virtual void DestroyAll();
66 
67  virtual void CoverageTreeManifestLoadedHandler(const Streaming::CoverageTrees::CoverageTreeManifest& coverageTreeManifest);
68 
69  virtual bool IsReady() const;
70 
71  private:
72  struct WebLoaderRequest;
73 
74  bool TryComposeUrlFor(const Eegeo::Streaming::MortonKey& key, std::string& out_url) const;
75 
76  void OnRequestCompleted(CancelHandle cancelHandle);
77 
78  BuildingFootprintWebLoader& m_buildingFootprintWebLoader;
79  BuildingFootprintRepository& m_buildingFootprintRepository;
80  const IBuildingFootprintResourceCoverageFactory& m_buildingFootprintResourceCoverageFactory;
81  Streaming::CoverageTrees::CoverageTreeManifestNotifier& m_coverageTreeManifestNotifier;
82  IBuildingFootprintResourceCoverage* m_pBuildingFootprintResourceCoverage;
83  std::unordered_map<CancelHandle, WebLoaderRequest*> m_pendingRequests;
84 
86  CoverageTreeManifestLoadedCallback m_coverageTreeManifestLoadedCallback;
87  };
88  }
89 }