Routino SVN Repository Browser

Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino

ViewVC logotype

Annotation of /trunk/src/waysx.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1739 - (hide annotations) (download) (as text)
Fri Jul 10 18:59:01 2015 UTC (9 years, 9 months ago) by amb
File MIME type: text/x-chdr
File size: 5184 byte(s)
Clarify the comments surrounding the definition of the slim mode cache
data structures.

1 amb 110 /***************************************
2     A header file for the extended Ways structure.
3 amb 151
4     Part of the Routino routing software.
5 amb 110 ******************/ /******************
6 amb 1739 This file Copyright 2008-2015 Andrew M. Bishop
7 amb 110
8 amb 151 This program is free software: you can redistribute it and/or modify
9     it under the terms of the GNU Affero General Public License as published by
10     the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12    
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16     GNU Affero General Public License for more details.
17    
18     You should have received a copy of the GNU Affero General Public License
19     along with this program. If not, see <http://www.gnu.org/licenses/>.
20 amb 110 ***************************************/
21    
22    
23     #ifndef WAYSX_H
24     #define WAYSX_H /*+ To stop multiple inclusions. +*/
25    
26     #include <stdint.h>
27    
28 amb 449 #include "types.h"
29 amb 1597 #include "ways.h"
30 amb 449
31 amb 199 #include "typesx.h"
32 amb 110
33 amb 1297 #include "cache.h"
34 amb 451 #include "files.h"
35 amb 110
36 amb 451
37 amb 110 /* Data structures */
38    
39    
40     /*+ An extended structure containing a single way. +*/
41     struct _WayX
42     {
43 amb 1100 way_t id; /*+ The way identifier; initially the OSM value, later the Way index. +*/
44 amb 203
45 amb 1090 Way way; /*+ The real way data. +*/
46 amb 110 };
47    
48    
49     /*+ A structure containing a set of ways (memory format). +*/
50     struct _WaysX
51     {
52 amb 1120 char *filename; /*+ The name of the intermediate file (for the WaysX). +*/
53     char *filename_tmp; /*+ The name of the temporary file (for the WaysX). +*/
54 amb 216
55 amb 1120 int fd; /*+ The file descriptor of the open file (for the WaysX). +*/
56    
57 amb 650 index_t number; /*+ The number of extended ways still being considered. +*/
58 amb 1317 index_t knumber; /*+ The number of extended ways kept for next time. +*/
59 amb 216
60 amb 1380 transports_t allow; /*+ The types of traffic that were seen when parsing. +*/
61    
62 amb 452 #if !SLIM
63    
64 amb 651 WayX *data; /*+ The extended ways data (when mapped into memory). +*/
65 amb 262
66 amb 452 #else
67    
68 amb 964 WayX cached[3]; /*+ Three cached extended ways read from the file in slim mode. +*/
69     index_t incache[3]; /*+ The indexes of the cached extended ways. +*/
70 amb 452
71 amb 1297 WayXCache *cache; /*+ A RAM cache of extended ways read from the file. +*/
72    
73 amb 452 #endif
74    
75 amb 755 way_t *idata; /*+ The extended way IDs (sorted by ID). +*/
76 amb 1317 off_t *odata; /*+ The offset of the way in the file (used for error log). +*/
77 amb 203
78 amb 1100 index_t *cdata; /*+ The compacted way IDs (same order as sorted ways). +*/
79 amb 1093
80 amb 1120 char *nfilename_tmp; /*+ The name of the temporary file (for the WaysX names). +*/
81 amb 203
82 amb 1120 int nfd; /*+ The file descriptor of the temporary file (for the WaysX names). +*/
83    
84 amb 680 uint32_t nlength; /*+ The length of the string of name entries. +*/
85 amb 110 };
86    
87    
88 amb 680 /* Functions in waysx.c */
89 amb 110
90    
91 amb 1158 WaysX *NewWayList(int append,int readonly);
92 amb 1167 void FreeWayList(WaysX *waysx,int keep);
93 amb 110
94 amb 1338 void AppendWayList(WaysX *waysx,way_t id,Way *way,node_t *nodes,int nnodes,const char *name);
95 amb 1151 void FinishWayList(WaysX *waysx);
96    
97 amb 682 index_t IndexWayX(WaysX *waysx,way_t id);
98 amb 110
99     void SortWayList(WaysX *waysx);
100    
101 amb 1349 SegmentsX *SplitWays(WaysX *waysx,NodesX *nodesx,int keep);
102 amb 1136
103 amb 1348 void SortWayNames(WaysX *waysx);
104 amb 1339
105 amb 1100 void CompactWayList(WaysX *waysx,SegmentsX *segmentsx);
106 amb 451
107 amb 1160 void SaveWayList(WaysX *waysx,const char *filename);
108 amb 499
109 amb 1160
110 amb 452 /* Macros / inline functions */
111 amb 451
112 amb 452 #if !SLIM
113 amb 451
114 amb 651 #define LookupWayX(waysx,index,position) &(waysx)->data[index]
115 amb 452
116 amb 1308 #define PutBackWayX(waysx,wayx) while(0) { /* nop */ }
117 amb 557
118 amb 452 #else
119    
120 amb 1297 /* Prototypes */
121 amb 452
122 amb 1297 static inline WayX *LookupWayX(WaysX *waysx,index_t index,int position);
123 amb 452
124 amb 1297 static inline void PutBackWayX(WaysX *waysx,WayX *wayx);
125 amb 557
126 amb 1297 CACHE_NEWCACHE_PROTO(WayX)
127     CACHE_DELETECACHE_PROTO(WayX)
128     CACHE_FETCHCACHE_PROTO(WayX)
129     CACHE_REPLACECACHE_PROTO(WayX)
130     CACHE_INVALIDATECACHE_PROTO(WayX)
131    
132 amb 1739 /* Data type */
133 amb 1297
134 amb 1739 CACHE_STRUCTURE(WayX)
135    
136 amb 1297 /* Inline functions */
137    
138     CACHE_NEWCACHE(WayX)
139     CACHE_DELETECACHE(WayX)
140     CACHE_FETCHCACHE(WayX)
141     CACHE_REPLACECACHE(WayX)
142     CACHE_INVALIDATECACHE(WayX)
143    
144    
145 amb 451 /*++++++++++++++++++++++++++++++++++++++
146 amb 680 Lookup a particular extended way with the specified id from the file on disk.
147 amb 451
148 amb 680 WayX *LookupWayX Returns a pointer to a cached copy of the extended way.
149 amb 451
150 amb 682 WaysX *waysx The set of ways to use.
151 amb 451
152     index_t index The way index to look for.
153    
154     int position The position in the cache to use.
155     ++++++++++++++++++++++++++++++++++++++*/
156    
157 amb 682 static inline WayX *LookupWayX(WaysX *waysx,index_t index,int position)
158 amb 451 {
159 amb 1297 waysx->cached[position-1]=*FetchCachedWayX(waysx->cache,index,waysx->fd,0);
160 amb 451
161 amb 942 waysx->incache[position-1]=index;
162    
163 amb 651 return(&waysx->cached[position-1]);
164 amb 451 }
165    
166 amb 505
167     /*++++++++++++++++++++++++++++++++++++++
168 amb 680 Put back an extended way's data into the file on disk.
169 amb 505
170 amb 682 WaysX *waysx The set of ways to use.
171 amb 505
172 amb 942 WayX *wayx The extended way to be put back.
173 amb 505 ++++++++++++++++++++++++++++++++++++++*/
174    
175 amb 942 static inline void PutBackWayX(WaysX *waysx,WayX *wayx)
176 amb 505 {
177 amb 942 int position1=wayx-&waysx->cached[0];
178    
179 amb 1297 ReplaceCachedWayX(waysx->cache,wayx,waysx->incache[position1],waysx->fd,0);
180 amb 505 }
181    
182 amb 452 #endif /* SLIM */
183 amb 451
184 amb 452
185 amb 110 #endif /* WAYSX_H */

Properties

Name Value
cvs:description Extended ways header.