Debian Codegraph @

src/common/route.hpp

raw symbols SCIP
1 // This file is part of Dust Racing 2D.
2 // Copyright (C) 2015 Jussi Lind <[email protected]>
3 //
4 // Dust Racing 2D is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 // Dust Racing 2D is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>.
15
16 #ifndef ROUTE_HPP
17 #define ROUTE_HPP
18
19 #include "targetnodebase.hpp"
20
21 #include <vector>
22
23 class TrackTileBase;
24 class TargetNodeBase;
25
26 //! Route is used to define the race route as a sequence
27 //! of TrackTiles.
28 class Route
29 {
30 public:
31 //! Constructor.
32 Route();
33
34 Route(const Route & other) = delete;
35
36 Route & operator=(const Route & other) = delete;
37
38 typedef std::vector<TargetNodeBasePtr> RouteVector;
39
40 //! Clear the current route.
41 void clear();
42
43 //! Push new target to the route and return true
44 //! if the route got closed.
45 bool push(TargetNodeBasePtr target);
46
47 //! Build route from an (unordered) vector of Targets.
48 //! Will be sorted with respect to their indices.
49 void buildFromVector(RouteVector & routeVector);
50
51 //! Return number of target nodes.
52 size_t numNodes() const;
53
54 //! Return Target for the given index.
55 TargetNodeBasePtr get(size_t index) const;
56
57 //! Get all nodes.
58 void getAll(RouteVector & routeVector) const;
59
60 //! Return length based on target node locations.
61 double geometricLength() const;
62
63 RouteVector::iterator begin();
64
65 RouteVector::iterator end();
66
67 RouteVector::const_iterator cbegin() const;
68
69 RouteVector::const_iterator cend() const;
70
71 private:
72 bool isClosed() const;
73
74 std::vector<TargetNodeBasePtr> m_route;
75 };
76
77 #endif // ROUTE_HPP