All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
NavigationGraphLinkManager.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "Navigation.h"
7 #include "Streaming.h"
8 #include "ICallback.h"
9 #include "CallbackCollection.h"
10 
11 #include <vector>
12 
13 namespace Eegeo
14 {
15  namespace Resources
16  {
17  namespace Roads
18  {
19  namespace Navigation
20  {
21  typedef Helpers::ICallback1<const NavigationGraph> INavigationGraphLinkedCallback;
22  typedef Helpers::ICallback1<const NavigationGraph> INavigationGraphUnlinkedCallback;
23 
25  {
26  public:
27  NavigationGraphLinkManager(bool debugLog, float maxLinkDist = 2.0f)
28  : m_maxLinkDistSqr(maxLinkDist*maxLinkDist)
29  , m_debugLog(debugLog)
30  {
31 
32  }
33  typedef std::vector<NavigationGraphLink*> TLinksVector;
34 
35  void FormConnections(NavigationGraph& newNavGraph);
36  void Disconnect(NavigationGraph& oldNavGraph);
37 
38 
39 
40  void RegisterLinkedCallback(INavigationGraphLinkedCallback& callback);
41  void UnregisterLinkedCallback(INavigationGraphLinkedCallback& callback);
42  void RegisterUnlinkedCallback(INavigationGraphUnlinkedCallback& callback);
43  void UnregisterUnlinkedCallback(INavigationGraphUnlinkedCallback& callback);
44 
45 
46  private:
47  TLinksVector m_pendingLinks;
48  TLinksVector m_newLinksScratch;
49  TLinksVector m_newPendingLinksScratch;
50 
51  const float m_maxLinkDistSqr;
52  const bool m_debugLog;
53 
56 
57  void FormConnectionsWithLinks(const NavigationGraph& navGraphA, const TLinksVector& newLinksToA);
58 
59  void ConnectRoads(NavigationGraphLink* linkAtoB, NavigationGraphLink* linkBtoA);
60  void RemovePendingLinksWithThisGraph(NavigationGraph* navGraph);
61  void DisconnectRoad(NavigationGraphRoad& road, const NavigationGraph& navGraph);
62  void DisconnectLink(NavigationGraphRoad& roadA, const NavigationGraph& navGraphA, NavigationGraphLink& linkAToB);
63 
64  TLinksVector::iterator FindBestAdmissableLink(const NavigationGraphLink& link, TLinksVector::iterator pendingLinksBegin, TLinksVector::iterator pendingLinksEnd);
65 
66  void RaiseLinkedCallbacks(const NavigationGraph& navGraph);
67  void RaiseUnlinkedCallbacks(const NavigationGraph& navGraph);
68 
69  };
70  }
71  }
72  }
73 }