Skip to content

Commit

Permalink
separate frun::run_stop to be able to forward declare it
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Oct 21, 2024
1 parent 93ba195 commit 7492c58
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 115 deletions.
137 changes: 69 additions & 68 deletions include/nigiri/rt/frun.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,81 +19,82 @@ struct timetable;

namespace nigiri::rt {

// Full run. Same as `run` data structure, extended with timetable and
// rt_timetable to be able to look up additional info.
struct frun : public run {
struct run_stop {
stop get_stop() const noexcept;
stop get_scheduled_stop() const noexcept;
location get_location() const noexcept;
geo::latlng pos() const noexcept;
location_idx_t get_location_idx() const noexcept;
location_idx_t get_scheduled_location_idx() const noexcept;
std::string_view name() const noexcept;
std::string_view track() const noexcept;
std::string_view id() const noexcept;

provider const& get_provider(event_type = event_type::kDep) const noexcept;
trip_idx_t get_trip_idx(event_type = event_type::kDep) const noexcept;
std::string_view trip_display_name(
event_type = event_type::kDep) const noexcept;

unixtime_t scheduled_time(event_type) const noexcept;
unixtime_t time(event_type) const noexcept;
duration_t delay(event_type) const noexcept;

std::string_view line(event_type = event_type::kDep) const noexcept;
std::string_view scheduled_line(
event_type = event_type::kDep) const noexcept;
std::string_view direction(event_type = event_type::kDep) const noexcept;

clasz get_clasz(event_type = event_type::kDep) const noexcept;
clasz get_scheduled_clasz(event_type = event_type::kDep) const noexcept;

bool bikes_allowed(event_type = event_type::kDep) const noexcept;

route_color get_route_color(event_type = event_type::kDep) const noexcept;

bool in_allowed() const noexcept;
bool out_allowed() const noexcept;
bool in_allowed_wheelchair() const noexcept;
bool out_allowed_wheelchair() const noexcept;
bool is_canceled() const noexcept;

bool in_allowed(bool const is_wheelchair) const noexcept;
bool out_allowed(bool const is_wheelchair) const noexcept;

template <enum direction SearchDir>
bool can_start(bool const is_wheelchair) const {
if constexpr (SearchDir == direction::kForward) {
return is_wheelchair ? in_allowed_wheelchair() : in_allowed();
} else {
return is_wheelchair ? out_allowed_wheelchair() : out_allowed();
}
}
struct frun;

struct run_stop {
stop get_stop() const noexcept;
stop get_scheduled_stop() const noexcept;
location get_location() const noexcept;
geo::latlng pos() const noexcept;
location_idx_t get_location_idx() const noexcept;
location_idx_t get_scheduled_location_idx() const noexcept;
std::string_view name() const noexcept;
std::string_view track() const noexcept;
std::string_view id() const noexcept;

provider const& get_provider(event_type = event_type::kDep) const noexcept;
trip_idx_t get_trip_idx(event_type = event_type::kDep) const noexcept;
std::string_view trip_display_name(
event_type = event_type::kDep) const noexcept;

unixtime_t scheduled_time(event_type) const noexcept;
unixtime_t time(event_type) const noexcept;
duration_t delay(event_type) const noexcept;

std::string_view line(event_type = event_type::kDep) const noexcept;
std::string_view scheduled_line(event_type = event_type::kDep) const noexcept;
std::string_view direction(event_type = event_type::kDep) const noexcept;

clasz get_clasz(event_type = event_type::kDep) const noexcept;
clasz get_scheduled_clasz(event_type = event_type::kDep) const noexcept;

bool bikes_allowed(event_type = event_type::kDep) const noexcept;

template <enum direction SearchDir>
bool can_finish(bool const is_wheelchair) const {
if constexpr (SearchDir == direction::kForward) {
return is_wheelchair ? out_allowed_wheelchair() : out_allowed();
} else {
return is_wheelchair ? in_allowed_wheelchair() : in_allowed();
}
route_color get_route_color(event_type = event_type::kDep) const noexcept;

bool in_allowed() const noexcept;
bool out_allowed() const noexcept;
bool in_allowed_wheelchair() const noexcept;
bool out_allowed_wheelchair() const noexcept;
bool is_canceled() const noexcept;

bool in_allowed(bool const is_wheelchair) const noexcept;
bool out_allowed(bool const is_wheelchair) const noexcept;

template <enum direction SearchDir>
bool can_start(bool const is_wheelchair) const {
if constexpr (SearchDir == direction::kForward) {
return is_wheelchair ? in_allowed_wheelchair() : in_allowed();
} else {
return is_wheelchair ? out_allowed_wheelchair() : out_allowed();
}
}

template <enum direction SearchDir>
bool can_finish(bool const is_wheelchair) const {
if constexpr (SearchDir == direction::kForward) {
return is_wheelchair ? out_allowed_wheelchair() : out_allowed();
} else {
return is_wheelchair ? in_allowed_wheelchair() : in_allowed();
}
}

stop_idx_t section_idx(event_type) const noexcept;
stop_idx_t section_idx(event_type) const noexcept;

timetable const& tt() const noexcept;
rt_timetable const* rtt() const noexcept;
timetable const& tt() const noexcept;
rt_timetable const* rtt() const noexcept;

void print(std::ostream&, bool first = false, bool last = false) const;
bool operator==(run_stop const&) const = default;
friend std::ostream& operator<<(std::ostream&, run_stop const&);
void print(std::ostream&, bool first = false, bool last = false) const;
bool operator==(run_stop const&) const = default;
friend std::ostream& operator<<(std::ostream&, run_stop const&);

frun const* fr_{nullptr};
stop_idx_t stop_idx_{0U};
};
frun const* fr_{nullptr};
stop_idx_t stop_idx_{0U};
};

// Full run. Same as `run` data structure, extended with timetable and
// rt_timetable to be able to look up additional info.
struct frun : public run {
struct iterator {
using difference_type = stop_idx_t;
using value_type = run_stop;
Expand Down
Loading

0 comments on commit 7492c58

Please sign in to comment.