Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Annotation of /trunk/src/waysx.h
Parent Directory
|
Revision Log
Revision 499 -
(hide annotations)
(download)
(as text)
Fri Sep 17 18:38:39 2010 UTC (14 years, 6 months ago) by amb
File MIME type: text/x-chdr
File size: 3575 byte(s)
Fri Sep 17 18:38:39 2010 UTC (14 years, 6 months ago) by amb
File MIME type: text/x-chdr
File size: 3575 byte(s)
Split the sorting of waysx from the compacting so that the route relation information can be included before compacting.
1 | amb | 110 | /*************************************** |
2 | amb | 499 | $Header: /home/amb/CVS/routino/src/waysx.h,v 1.27 2010-09-17 18:38:39 amb Exp $ |
3 | amb | 110 | |
4 | A header file for the extended Ways structure. | ||
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 WAYSX_H | ||
26 | #define WAYSX_H /*+ To stop multiple inclusions. +*/ | ||
27 | |||
28 | #include <stdint.h> | ||
29 | |||
30 | amb | 449 | #include "types.h" |
31 | |||
32 | amb | 199 | #include "typesx.h" |
33 | amb | 262 | #include "ways.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 containing a single way. +*/ | ||
42 | struct _WayX | ||
43 | { | ||
44 | amb | 203 | way_t id; /*+ The way identifier. +*/ |
45 | |||
46 | amb | 310 | index_t prop; /*+ The index of the properties of the way in the compacted list. +*/ |
47 | |||
48 | amb | 262 | Way way; /*+ The real Way data. +*/ |
49 | amb | 110 | }; |
50 | |||
51 | |||
52 | /*+ A structure containing a set of ways (memory format). +*/ | ||
53 | struct _WaysX | ||
54 | { | ||
55 | amb | 262 | char *filename; /*+ The name of the temporary file (for the WaysX). +*/ |
56 | int fd; /*+ The file descriptor of the temporary file (for the WaysX). +*/ | ||
57 | amb | 216 | |
58 | amb | 465 | index_t xnumber; /*+ The number of unsorted extended ways. +*/ |
59 | amb | 216 | |
60 | amb | 452 | #if !SLIM |
61 | |||
62 | amb | 262 | WayX *xdata; /*+ The extended data for the Ways (sorted). +*/ |
63 | |||
64 | amb | 452 | #else |
65 | |||
66 | WayX xcached[2]; /*+ Two cached ways read from the file in slim mode. +*/ | ||
67 | |||
68 | #endif | ||
69 | |||
70 | amb | 465 | index_t number; /*+ How many entries are still useful? +*/ |
71 | amb | 110 | |
72 | amb | 465 | index_t cnumber; /*+ How many entries are there after compacting? +*/ |
73 | amb | 203 | |
74 | amb | 310 | index_t *idata; /*+ The index of the extended data for the Ways (sorted by ID). +*/ |
75 | amb | 203 | |
76 | amb | 262 | char *nfilename; /*+ The name of the temporary file (for the names). +*/ |
77 | amb | 203 | |
78 | amb | 262 | uint32_t nlength; /*+ How long is the string of name entries? +*/ |
79 | amb | 110 | }; |
80 | |||
81 | |||
82 | /* Functions */ | ||
83 | |||
84 | |||
85 | amb | 326 | WaysX *NewWayList(int append); |
86 | void FreeWayList(WaysX *waysx,int keep); | ||
87 | amb | 110 | |
88 | amb | 398 | void SaveWayList(WaysX *waysx,const char *filename); |
89 | amb | 110 | |
90 | amb | 262 | index_t IndexWayX(WaysX* waysx,way_t id); |
91 | amb | 110 | |
92 | amb | 262 | void AppendWay(WaysX* waysx,way_t id,Way *way,const char *name); |
93 | amb | 203 | |
94 | amb | 110 | void SortWayList(WaysX *waysx); |
95 | |||
96 | amb | 499 | void CompactWayList(WaysX *waysx); |
97 | amb | 451 | |
98 | amb | 499 | |
99 | amb | 452 | /* Macros / inline functions */ |
100 | amb | 451 | |
101 | amb | 452 | #if !SLIM |
102 | amb | 451 | |
103 | amb | 452 | #define LookupWayX(waysx,index,position) &(waysx)->xdata[index] |
104 | |||
105 | #else | ||
106 | |||
107 | static WayX *LookupWayX(WaysX* waysx,index_t index,int position); | ||
108 | |||
109 | |||
110 | amb | 451 | /*++++++++++++++++++++++++++++++++++++++ |
111 | Lookup a particular way. | ||
112 | |||
113 | WayX *LookupWayX Returns a pointer to the extended way with the specified id. | ||
114 | |||
115 | WaysX* waysx The set of ways to process. | ||
116 | |||
117 | index_t index The way index to look for. | ||
118 | |||
119 | int position The position in the cache to use. | ||
120 | ++++++++++++++++++++++++++++++++++++++*/ | ||
121 | |||
122 | static inline WayX *LookupWayX(WaysX* waysx,index_t index,int position) | ||
123 | { | ||
124 | amb | 464 | SeekFile(waysx->fd,(off_t)index*sizeof(WayX)); |
125 | amb | 451 | |
126 | amb | 452 | ReadFile(waysx->fd,&waysx->xcached[position-1],sizeof(WayX)); |
127 | amb | 451 | |
128 | amb | 452 | return(&waysx->xcached[position-1]); |
129 | amb | 451 | } |
130 | |||
131 | amb | 452 | #endif /* SLIM */ |
132 | amb | 451 | |
133 | amb | 452 | |
134 | amb | 110 | #endif /* WAYSX_H */ |
Properties
Name | Value |
---|---|
cvs:description | Extended ways header. |