Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Annotation of /trunk/src/segmentsx.h
Parent Directory
|
Revision Log
Revision 452 -
(hide annotations)
(download)
(as text)
Wed Jul 14 18:00:10 2010 UTC (14 years, 8 months ago) by amb
File MIME type: text/x-chdr
File size: 5874 byte(s)
Wed Jul 14 18:00:10 2010 UTC (14 years, 8 months ago) by amb
File MIME type: text/x-chdr
File size: 5874 byte(s)
Replaced the runtime selection of slim mode / non-slim mode with compile time selection that gives no runtime overhead but gives two executables.
1 | amb | 110 | /*************************************** |
2 | amb | 452 | $Header: /home/amb/CVS/routino/src/segmentsx.h,v 1.24 2010-07-14 18:00:10 amb Exp $ |
3 | amb | 110 | |
4 | A header file for the extended segments. | ||
5 | amb | 151 | |
6 | Part of the Routino routing software. | ||
7 | amb | 110 | ******************/ /****************** |
8 | amb | 326 | This file Copyright 2008-2010 Andrew M. Bishop |
9 | amb | 110 | |
10 | amb | 151 | This program is free software: you can redistribute it and/or modify |
11 | it under the terms of the GNU Affero General Public License as published by | ||
12 | the Free Software Foundation, either version 3 of the License, or | ||
13 | (at your option) any later version. | ||
14 | |||
15 | This program is distributed in the hope that it will be useful, | ||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | GNU Affero General Public License for more details. | ||
19 | |||
20 | You should have received a copy of the GNU Affero General Public License | ||
21 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
22 | amb | 110 | ***************************************/ |
23 | |||
24 | |||
25 | #ifndef SEGMENTSX_H | ||
26 | #define SEGMENTSX_H /*+ To stop multiple inclusions. +*/ | ||
27 | |||
28 | #include <stdint.h> | ||
29 | |||
30 | amb | 449 | #include "types.h" |
31 | amb | 448 | #include "segments.h" |
32 | |||
33 | amb | 199 | #include "typesx.h" |
34 | amb | 110 | |
35 | amb | 451 | #include "files.h" |
36 | amb | 110 | |
37 | amb | 451 | |
38 | amb | 110 | /* Data structures */ |
39 | |||
40 | |||
41 | /*+ An extended structure used for processing. +*/ | ||
42 | struct _SegmentX | ||
43 | { | ||
44 | amb | 209 | node_t node1; /*+ The id of the starting node. +*/ |
45 | node_t node2; /*+ The id of the finishing node. +*/ | ||
46 | amb | 110 | |
47 | amb | 209 | way_t way; /*+ The id of the way. +*/ |
48 | amb | 203 | |
49 | amb | 209 | distance_t distance; /*+ The distance between the nodes. +*/ |
50 | amb | 110 | }; |
51 | |||
52 | |||
53 | /*+ A structure containing a set of segments (memory format). +*/ | ||
54 | struct _SegmentsX | ||
55 | { | ||
56 | amb | 256 | char *filename; /*+ The name of the temporary file. +*/ |
57 | int fd; /*+ The file descriptor of the temporary file. +*/ | ||
58 | amb | 216 | |
59 | amb | 256 | uint32_t xnumber; /*+ The number of unsorted extended nodes. +*/ |
60 | amb | 216 | |
61 | amb | 452 | #if !SLIM |
62 | |||
63 | amb | 256 | SegmentX *xdata; /*+ The extended segment data (unsorted). +*/ |
64 | |||
65 | amb | 452 | #else |
66 | |||
67 | SegmentX xcached[2]; /*+ Two cached segments read from the file in slim mode. +*/ | ||
68 | |||
69 | #endif | ||
70 | |||
71 | amb | 128 | uint32_t number; /*+ How many entries are still useful? +*/ |
72 | amb | 110 | |
73 | amb | 275 | node_t *idata; /*+ The extended segment data (sorted by node1 then node2). +*/ |
74 | amb | 279 | index_t *firstnode; /*+ The first segment index for each node. +*/ |
75 | amb | 209 | |
76 | amb | 452 | #if !SLIM |
77 | |||
78 | amb | 229 | Segment *sdata; /*+ The segment data (same order as n1data). +*/ |
79 | amb | 448 | |
80 | amb | 452 | #else |
81 | |||
82 | amb | 448 | char *sfilename; /*+ The name of the temporary file for segments in slim mode. +*/ |
83 | int sfd; /*+ The file descriptor of the temporary file. +*/ | ||
84 | |||
85 | Segment scached[2]; /*+ Two cached segments read from the file in slim mode. +*/ | ||
86 | amb | 452 | |
87 | #endif | ||
88 | amb | 110 | }; |
89 | |||
90 | |||
91 | /* Functions */ | ||
92 | |||
93 | |||
94 | amb | 326 | SegmentsX *NewSegmentList(int append); |
95 | void FreeSegmentList(SegmentsX *segmentsx,int keep); | ||
96 | amb | 110 | |
97 | void SaveSegmentList(SegmentsX *segmentsx,const char *filename); | ||
98 | |||
99 | amb | 275 | index_t IndexFirstSegmentX(SegmentsX* segmentsx,node_t node); |
100 | amb | 256 | |
101 | amb | 279 | index_t IndexNextSegmentX(SegmentsX* segmentsx,index_t segindex,index_t nodeindex); |
102 | |||
103 | amb | 209 | void AppendSegment(SegmentsX* segmentsx,way_t way,node_t node1,node_t node2,distance_t distance); |
104 | amb | 110 | |
105 | amb | 279 | void SortSegmentList(SegmentsX* segmentsx); |
106 | amb | 110 | |
107 | amb | 204 | void RemoveBadSegments(NodesX *nodesx,SegmentsX *segmentsx); |
108 | amb | 110 | |
109 | amb | 279 | void UpdateSegments(SegmentsX *segmentsx,NodesX *nodesx,WaysX *waysx); |
110 | amb | 110 | |
111 | amb | 275 | void RotateSegments(SegmentsX* segmentsx); |
112 | |||
113 | amb | 279 | void DeduplicateSegments(SegmentsX* segmentsx,NodesX *nodesx,WaysX *waysx); |
114 | amb | 110 | |
115 | amb | 209 | void CreateRealSegments(SegmentsX *segmentsx,WaysX *waysx); |
116 | |||
117 | amb | 110 | void IndexSegments(SegmentsX* segmentsx,NodesX *nodesx); |
118 | |||
119 | |||
120 | amb | 452 | /* Macros / inline functions */ |
121 | amb | 451 | |
122 | |||
123 | amb | 452 | #if !SLIM |
124 | |||
125 | #define LookupSegmentX(segmentsx,index,position) &(segmentsx)->xdata[index] | ||
126 | |||
127 | #define LookupSegmentXSegment(segmentsx,index,position) &(segmentsx)->sdata[index] | ||
128 | |||
129 | #else | ||
130 | |||
131 | static SegmentX *LookupSegmentX(SegmentsX* segmentsx,index_t index,int position); | ||
132 | |||
133 | static Segment *LookupSegmentXSegment(SegmentsX* segmentsx,index_t index,int position); | ||
134 | |||
135 | static void PutBackSegmentXSegment(SegmentsX* segmentsx,index_t index,int position); | ||
136 | |||
137 | |||
138 | amb | 451 | /*++++++++++++++++++++++++++++++++++++++ |
139 | Lookup a particular extended segment. | ||
140 | |||
141 | SegmentX *LookupSegmentX Returns a pointer to the extended segment with the specified id. | ||
142 | |||
143 | SegmentsX* segmentsx The set of segments to process. | ||
144 | |||
145 | index_t index The segment index to look for. | ||
146 | |||
147 | int position The position in the cache to use. | ||
148 | ++++++++++++++++++++++++++++++++++++++*/ | ||
149 | |||
150 | static inline SegmentX *LookupSegmentX(SegmentsX* segmentsx,index_t index,int position) | ||
151 | { | ||
152 | amb | 452 | SeekFile(segmentsx->fd,index*sizeof(SegmentX)); |
153 | amb | 451 | |
154 | amb | 452 | ReadFile(segmentsx->fd,&segmentsx->xcached[position-1],sizeof(SegmentX)); |
155 | amb | 451 | |
156 | amb | 452 | return(&segmentsx->xcached[position-1]); |
157 | amb | 451 | } |
158 | |||
159 | |||
160 | /*++++++++++++++++++++++++++++++++++++++ | ||
161 | Lookup a particular extended segment's normal segment. | ||
162 | |||
163 | Segment *LookupSegmentXSegment Returns a pointer to the segment with the specified id. | ||
164 | |||
165 | SegmentsX* segmentsx The set of segments to process. | ||
166 | |||
167 | index_t index The segment index to look for. | ||
168 | |||
169 | int position The position in the cache to use. | ||
170 | ++++++++++++++++++++++++++++++++++++++*/ | ||
171 | |||
172 | static inline Segment *LookupSegmentXSegment(SegmentsX* segmentsx,index_t index,int position) | ||
173 | { | ||
174 | amb | 452 | SeekFile(segmentsx->sfd,index*sizeof(Segment)); |
175 | amb | 451 | |
176 | amb | 452 | ReadFile(segmentsx->sfd,&segmentsx->scached[position-1],sizeof(Segment)); |
177 | amb | 451 | |
178 | amb | 452 | return(&segmentsx->scached[position-1]); |
179 | amb | 451 | } |
180 | |||
181 | |||
182 | /*++++++++++++++++++++++++++++++++++++++ | ||
183 | Put back an extended segment's normal segment. | ||
184 | |||
185 | SegmentsX* segmentsx The set of segments to process. | ||
186 | |||
187 | index_t index The segment index to look for. | ||
188 | |||
189 | int position The position in the cache to use. | ||
190 | ++++++++++++++++++++++++++++++++++++++*/ | ||
191 | |||
192 | static inline void PutBackSegmentXSegment(SegmentsX* segmentsx,index_t index,int position) | ||
193 | { | ||
194 | amb | 452 | SeekFile(segmentsx->sfd,index*sizeof(Segment)); |
195 | amb | 451 | |
196 | amb | 452 | WriteFile(segmentsx->sfd,&segmentsx->scached[position-1],sizeof(Segment)); |
197 | amb | 451 | } |
198 | |||
199 | amb | 452 | #endif /* SLIM */ |
200 | amb | 451 | |
201 | amb | 452 | |
202 | amb | 110 | #endif /* SEGMENTSX_H */ |
Properties
Name | Value |
---|---|
cvs:description | Extended segments header. |