Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

separate frun::run_stop to be able to forward declare it #146

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading