]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/section.h
Initial revision
[r2c2.git] / source / libmarklin / section.h
1 #ifndef MARKLIN_3D_SECTION_H_
2 #define MARKLIN_3D_SECTION_H_
3
4 #include <list>
5 #include <set>
6 #include "track.h"
7
8 namespace Marklin {
9
10 class Train;
11 class TrafficManager;
12
13 class Section
14 {
15 public:
16         struct Endpoint
17         {
18                 Track *track;
19                 const Track::Endpoint *track_ep;
20                 Section  *link;
21                 unsigned routes;
22
23                 Endpoint(Track *, const Track::Endpoint *);
24         };
25         typedef std::list<Endpoint> EndpointSeq;
26
27         Section(TrafficManager &, Track *);
28         unsigned get_sensor_id() const { return sensor_id; }
29         const TrackSet &get_tracks() const { return tracks; }
30         const Endpoint *get_endpoint_by_link(const Section *) const;
31         const Endpoint *traverse(const Endpoint *) const;
32         void check_link(Section &);
33         bool reserve(const Train *);
34         void print_debug();
35 private:
36         TrafficManager &trfc_mgr;
37         unsigned       id;
38         unsigned       sensor_id;
39         TrackSet       tracks;
40         EndpointSeq    endpoints;
41         const Train    *train;
42
43         void find_routes(Track *, const Track::Endpoint *, unsigned, TrackSet &);
44
45         static unsigned next_id;
46 };
47 typedef std::list<Section *> SectionSeq;
48
49 } // namespace Marklin
50
51 #endif