All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TiledGraph.h
1 #pragma once
2 
3 #include "Graphs.h"
4 #include "Types.h"
5 #include "TiledGraphNode.h"
6 #include "TiledGraphEdge.h"
7 #include "TiledGraphCell.h"
8 #include "CallbackCollection.h"
9 
10 #include <unordered_map>
11 
12 namespace Eegeo
13 {
14  namespace Graphs
15  {
16  typedef Helpers::ICallback1<const Streaming::MortonKey> ITiledGraphCellAddedCallback;
17  typedef Helpers::ICallback1<const Streaming::MortonKey> ITiledGraphCellRemovedCallback;
18  typedef Helpers::ICallback1<const Streaming::MortonKey> ITiledGraphCellUpdatedCallback;
19 
21  {
22  public:
23  typedef std::unordered_map<Streaming::MortonKey, TiledGraphCell*, Streaming::MortonKeyHash> TKeyToCell;
24 
25  TiledGraph(const ITiledGraphLinker& tiledGraphLinker);
26  ~TiledGraph();
27 
28 
29  void RegisterCellAddedCallback(ITiledGraphCellAddedCallback& callback);
30  void RegisterCellRemovedCallback(ITiledGraphCellRemovedCallback& callback);
31  void RegisterCellUpdatedCallback(ITiledGraphCellUpdatedCallback& callback);
32 
33  void UnregisterCellAddedCallback(ITiledGraphCellAddedCallback& callback);
34  void UnregisterCellRemovedCallback(ITiledGraphCellRemovedCallback& callback);
35  void UnregisterCellUpdatedCallback(ITiledGraphCellUpdatedCallback& callback);
36 
37  void Add(TiledGraphCell& cell);
38  void Remove(TiledGraphCell& cell);
39 
40  bool CellExists(const Streaming::MortonKey& cellKey) const;
41  TiledGraphCell& GetCell(const Streaming::MortonKey& cellKey) const;
42  const TKeyToCell& GetCells() const { return m_cells; }
43  size_t CountNodes() const;
44  size_t CountEdges() const;
45  size_t CountUniqueEdgeAttributes() const;
46 
47  dv3 GetNodePoint(const TiledGraphNodeId& nodeId) const;
48  const TiledGraphNode& GetNode(const TiledGraphNodeId& nodeId) const;
49  const TiledGraphEdge& GetEdge(const TiledGraphEdgeId& edgeId) const;
50 
51  bool NodeExists(const TiledGraphNodeId& nodeId) const;
52  bool EdgeExists(const TiledGraphEdgeId& edgeId) const;
53 
54  void GetIncidentEdgeIds(const TiledGraphNodeId& nodeId, std::vector<TiledGraphEdgeId>& out_incidentEdgeIds) const;
55 
56  bool FindEdgeId(const TiledGraphNodeId& nodeIdA, const TiledGraphNodeId& nodeIdB, TiledGraphEdgeId& out_edgeId) const;
57 
58  bool TryGetPointOnEdge(const TiledGraphEdgeId& graphEdgeId, const double param, dv3& out_pointOnEdge) const;
59 
60  bool ValidateAllUnlinked(const Streaming::MortonKey& cellKey) const;
61  bool ValidateExternalNodesExist() const;
62  private:
63 
64  TKeyToCell m_cells;
65 
66  const ITiledGraphLinker& m_tiledGraphLinker;
67 
71  };
72  }
73 }