chiark / gitweb /
84391c7b213026a1bd9aba351e0c16fd3b21cd16
[trains.git] / layout / layout-data.h
1 /*
2  */
3 /* The output from the layout processing system to the control
4  * software, describing the layout and the trains, is a data structure
5  * as described in this header file, in <name-of-layout>.layout-data.o
6  * (where <name-of-layout> is currently `ours').
7  *
8  * Alternatively, <name-of-layout>.redacted.forsafety contains data in
9  * the form described at the top of redactgraph.c.
10  */
11
12 #ifndef LAYOUT_DATA_H
13 #define LAYOUT_DATA_H
14
15 /*========== basic types etc. ==========*/
16
17 typedef unsigned short TrainNum;
18 typedef unsigned short SegmentNum;
19 typedef unsigned short MovPosComb;
20 typedef unsigned short BoardObject;
21
22 typedef unsigned char Small;
23
24 typedef short Distance;
25 typedef char Speed;
26   /* for units, see safety.h */
27
28 typedef enum {
29   mfk_none,
30   mfk_point
31 } MovFeatKind;
32
33 /*========== data from config files and layout cad/cam ==========*/
34
35 typedef struct {
36   unsigned next_backwards:1;
37   SegmentNum next;
38 } SegmentLinkInfo;
39
40 typedef struct {
41   const char *pname;
42   MovFeatKind kind;
43   Small posns;
44   MovPosComb weight;
45   const BoardObject *boob;
46 } MovFeatInfo;
47
48 typedef struct {
49   const char *pname;
50   Distance dist;
51   SegmentLinkInfo backwards, forwards;
52 } SegPosCombInfo;
53
54 typedef struct {
55   const char *pname;
56   unsigned invertible:1;
57   Small n_movfeats;
58   const MovFeatInfo *movfeats;
59   MovPosComb n_poscombs;
60   const SegPosCombInfo *poscombs;
61   BoardObject sense, invert;
62 } SegmentInfo;
63
64 typedef struct {
65   Speed maxspeed;
66   Distance tail, detectable, head;
67   const char *pname;
68 } TrainInfo;
69
70 /* These data arrays have no sentinel members.  Use the info_nfoobars
71  * constants.  Alternatively, it is legal to sed out everything from
72  * <name-of-layout>.layout-data.c from the first #include onwards, and
73  * this will give definitions of NUM_SEGMENTS and NUM_TRAINS.
74  */
75
76 extern const SegmentNum info_nsegments;
77 extern const SegmentInfo info_segments[]; 
78
79 extern const TrainNum info_nsegments;
80 extern const TrainInfo info_trains[];
81
82 extern const BoardObject info_nreverses; /* max. reverse + 1 */
83
84 #define NOTA(x) (~(x##Num)0)
85
86 #endif /*LAYOUT_DATA_H*/