Racing Web
RacingWebApplication.h
Go to the documentation of this file.
1// Copyright (c) 2022 Cameron King.
2// Dual licensed under MIT and GPLv2 with OpenSSL exception.
3// See LICENSE for details.
5
6#ifndef RACINGWEB_SRC_RACINGWEBAPPLICATION_H_
7#define RACINGWEB_SRC_RACINGWEBAPPLICATION_H_
8
9#include <Wt/WApplication.h>
10#include <Wt/WContainerWidget.h>
11#include <Wt/WGridLayout.h>
12#include <Wt/WHBoxLayout.h>
13#include <Wt/WLineEdit.h>
14#include <Wt/WMenuItem.h>
15#include <Wt/WPanel.h>
16#include <Wt/WPushButton.h>
17#include <Wt/WTabWidget.h>
18#include <Wt/WText.h>
19#include <Wt/WVBoxLayout.h>
20
21#include <algorithm>
22#include <climits>
23#include <map>
24#include <memory>
25#include <sstream>
26#include <string>
27#include <utility>
28#include <vector>
29
30#include "src/Car.h"
31#include "src/Result.h"
32#include "src/pregen.h"
33#include "src/raceutil.h"
34
38class RacingWebApplication : public Wt::WApplication {
39 public:
44 explicit RacingWebApplication(const Wt::WEnvironment &env);
45
46 private:
51 std::unique_ptr<Wt::WContainerWidget> BuildSetupContainer();
52
57 std::unique_ptr<Wt::WContainerWidget> BuildRunContainer();
58
63 std::unique_ptr<Wt::WContainerWidget> BuildStandingsContainer();
64
68 void UpdateLineupContainer();
69
76 std::vector<const Car *> CalculateFinalStandings();
77
81 void UpdateStandingsContainer();
82
92 void GenerateSchedule();
93
102 void SetCurrentHeat(int heat);
103
110 void FinishRacing();
111
117 void MarkPlace(const Car &car, int lane, int place);
118
123 [[nodiscard]] int IdentifyNextHeat() const;
124
129 [[nodiscard]] int IdentifyHeatOnDeck() const;
130
132 Wt::WLineEdit *number_of_cars;
133
135 Wt::WLineEdit *number_of_lanes;
136
138 Wt::WText *schedule_text;
139
141 Wt::WTabWidget *tabs;
142
144 Wt::WMenuItem *setup_tab;
145
147 Wt::WMenuItem *run_tab;
148
150 Wt::WMenuItem *standings_tab;
151
153 std::vector<Car> roster;
154
156 std::vector<std::vector<const Car *>> schedule;
157
165 std::vector<std::vector<std::unique_ptr<Result>>> results;
166
168 int current_heat = 0;
169
171 Wt::WText *run_title;
172
174 Wt::WContainerWidget *lineup_container;
175
177 Wt::WContainerWidget *standings_container;
178
180 Wt::WText *heat_preview_text;
181
183 std::vector<std::vector<Wt::WPushButton *>> place_button_matrix;
184
186 Wt::WPushButton *accept_results_button;
187};
188
189#endif // RACINGWEB_SRC_RACINGWEBAPPLICATION_H_
application state container class
Definition: RacingWebApplication.h:38
RacingWebApplication(const Wt::WEnvironment &env)
initializes the application
Definition: RacingWebApplication.cc:8
a race participant
Definition: Car.h:13