Welcome to mirror list, hosted at ThFree Co, Russian Federation.

joint_segment.hpp « routing - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 062945bb5b5d20f4b3d1c8b8364952dff6586eb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#pragma once

#include "routing/road_point.hpp"
#include "routing/route_weight.hpp"
#include "routing/segment.hpp"

#include "base/assert.hpp"

#include <cstdint>
#include <limits>
#include <string>

namespace routing
{
class JointSegment
{
public:
  static uint32_t constexpr kInvalidId = std::numeric_limits<uint32_t>::max();

  JointSegment() = default;
  JointSegment(Segment const & from, Segment const & to);

  uint32_t & GetFeatureId() { return m_featureId; }
  uint32_t GetFeatureId() const { return m_featureId; }
  NumMwmId GetMwmId() const { return m_numMwmId; }
  NumMwmId & GetMwmId() { return m_numMwmId; }
  uint32_t GetStartSegmentId() const { return m_startSegmentId; }
  uint32_t GetEndSegmentId() const { return m_endSegmentId; }
  uint32_t GetSegmentId(bool start) const { return start ? m_startSegmentId : m_endSegmentId; }
  bool IsForward() const { return m_forward; }

  void ToFake(uint32_t fakeId);
  bool IsFake() const;

  Segment GetSegment(bool start) const
  {
    return {m_numMwmId, m_featureId, start ? m_startSegmentId : m_endSegmentId, m_forward};
  }

  bool operator<(JointSegment const & rhs) const;
  bool operator==(JointSegment const & rhs) const;

  bool operator!=(JointSegment const & rhs) const
  {
    return !(*this == rhs);
  }

private:
  uint32_t m_featureId = kInvalidId;
  uint32_t m_startSegmentId = kInvalidId;
  uint32_t m_endSegmentId = kInvalidId;
  NumMwmId m_numMwmId = kFakeNumMwmId;
  bool m_forward = false;
};

class JointEdge
{
public:
  JointEdge(JointSegment const & target, RouteWeight const & weight)
    : m_target(target), m_weight(weight) {}

  JointSegment const & GetTarget() const { return m_target; }
  JointSegment & GetTarget() { return m_target; }
  RouteWeight & GetWeight() { return m_weight; }
  RouteWeight const & GetWeight() const { return m_weight; }

private:
  JointSegment m_target;
  RouteWeight m_weight;
};

std::string DebugPrint(JointSegment const & jointSegment);
}  // namespace routing