]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/trackpart.h
Turn TrackPart into a proper class
[r2c2.git] / source / libmarklin / trackpart.h
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2010  Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef MARKLIN_TRACKPART_H_
9 #define MARKLIN_TRACKPART_H_
10
11 #include <msp/datafile/loader.h>
12 #include "endpoint.h"
13 #include "geometry.h"
14
15 namespace Marklin {
16
17 class TrackPart
18 {
19 public:
20         class Loader: public Msp::DataFile::BasicLoader<TrackPart>
21         {
22         public:
23                 Loader(TrackPart &);
24         private:
25                 virtual void finish();
26                 void start(float, float, float);
27         };
28
29 private:
30         Point pos;
31         float dir;
32         float length;
33         float radius;
34         unsigned path;
35         bool dead_end;
36         TrackPart *links[2];
37
38 public:
39         TrackPart();
40
41         float get_length() const;
42         bool is_curved() const { return radius; }
43         TrackPoint get_point(float) const;
44         unsigned get_path() const { return path; }
45         bool is_dead_end() const { return dead_end; }
46         void check_link(TrackPart &);
47         TrackPart *get_link(unsigned) const;
48 };
49
50 } // namespace Marklin
51
52 #endif