All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
RouteFittingService.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "Routes.h"
7 #include "Streaming.h"
8 #include "UniqueKeyFifo.h"
9 
10 #include <vector>
11 #include <deque>
12 
13 namespace Eegeo
14 {
15  namespace Routes
16  {
17  namespace Fitting
18  {
20  {
21  FittedRouteRepository& m_fittedRouteRepository;
22  FittedRouteFactory& m_fittedRouteFactory;
23  const RouteRepository& m_routeRepository;
24  const Streaming::SceneGraphCellRepository& m_sceneGraphCellRepository;
25 
26  UniqueKeyFifo m_keysNeedingRefresh;
27  std::deque<Streaming::MortonKey> m_keysNotInSceneGraphScratch;
28 
29  bool m_enabled;
30  public:
31  RouteFittingService(FittedRouteRepository& fittedRouteRepository,
32  FittedRouteFactory& fittedRouteFactory,
33  const RouteRepository& routeRepository,
34  const Streaming::SceneGraphCellRepository& sceneGraphCellRepository);
35 
36  virtual ~RouteFittingService();
37 
38  const FittedRoute* GetFittedRoute(const Route* pRoute, const Eegeo::Streaming::MortonKey& key) const;
39 
40  void DestroyFittedRoutesForKey(const Eegeo::Streaming::MortonKey& key);
41 
42  void DestroyFittedRoutesForRoute(const Route* pRoute);
43 
44  void SetNeedsUpdatingForKey(const Eegeo::Streaming::MortonKey& key);
45 
46  void SetNeedsUpdatingForKeys(const std::vector<Eegeo::Streaming::MortonKey>& keys);
47 
48  void Update();
49 
50  void FlushPendingUpdates();
51 
52  void RefitAll();
53 
54 
55  bool IsEnabled() const { return m_enabled; }
56 
57  // enabled/disabled by RouteObserver when Route repo gets entry / becomes emtpy
58  void Enable();
59 
60  void Disable();
61  private:
62 
63  void DestroyAll();
64 
65  void CreateFittedRoutesForKey(const Eegeo::Streaming::MortonKey& key, bool attemptNavGraphConforming, std::vector<FittedRoute*>& out_fittedRoutes);
66 
67  void UpdateRepositoryWithFittedRoutes(std::vector<FittedRoute*>& fittedRoutes);
68  };
69  }
70  }
71 }