Routino SVN Repository Browser

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

ViewVC logotype

Contents of /trunk/src/waysx.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 557 - (show annotations) (download) (as text)
Mon Dec 20 19:11:02 2010 UTC (14 years, 2 months ago) by amb
File MIME type: text/x-chdr
File size: 4260 byte(s)
Make the PutBack*() functions be no-ops in slim mode and remove the
pre-processor guards from around the function calls.

1 /***************************************
2 $Header: /home/amb/CVS/routino/src/waysx.h,v 1.31 2010-12-20 19:11:02 amb Exp $
3
4 A header file for the extended Ways structure.
5
6 Part of the Routino routing software.
7 ******************/ /******************
8 This file Copyright 2008-2010 Andrew M. Bishop
9
10 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 ***************************************/
23
24
25 #ifndef WAYSX_H
26 #define WAYSX_H /*+ To stop multiple inclusions. +*/
27
28 #include <stdint.h>
29
30 #include "types.h"
31
32 #include "typesx.h"
33 #include "ways.h"
34
35 #include "files.h"
36
37
38 /* Data structures */
39
40
41 /*+ An extended structure containing a single way. +*/
42 struct _WayX
43 {
44 way_t id; /*+ The way identifier; the OSM value. +*/
45
46 index_t prop; /*+ The index of the properties of the way in the compacted list. +*/
47
48 Way way; /*+ The real Way data. +*/
49 };
50
51
52 /*+ A structure containing a set of ways (memory format). +*/
53 struct _WaysX
54 {
55 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
58 index_t xnumber; /*+ The number of unsorted extended ways. +*/
59
60 #if !SLIM
61
62 WayX *xdata; /*+ The extended data for the Ways (sorted). +*/
63
64 #else
65
66 WayX xcached[2]; /*+ Two cached ways read from the file in slim mode. +*/
67
68 #endif
69
70 index_t number; /*+ How many entries are still useful? +*/
71
72 index_t cnumber; /*+ How many entries are there after compacting? +*/
73
74 index_t *idata; /*+ The index of the extended data for the Ways (sorted by ID). +*/
75
76 char *nfilename; /*+ The name of the temporary file (for the names). +*/
77 int nfd; /*+ The file descriptor of the temporary file (for the names). +*/
78
79 uint32_t nlength; /*+ How long is the string of name entries? +*/
80 };
81
82
83 /* Functions */
84
85
86 WaysX *NewWayList(int append);
87 void FreeWayList(WaysX *waysx,int keep);
88
89 void SaveWayList(WaysX *waysx,const char *filename);
90
91 index_t IndexWayX(WaysX* waysx,way_t id);
92
93 void AppendWay(WaysX* waysx,way_t id,Way *way,const char *name);
94
95 void SortWayList(WaysX *waysx);
96
97 void CompactWayList(WaysX *waysx);
98
99
100 /* Macros / inline functions */
101
102 #if !SLIM
103
104 #define LookupWayX(waysx,index,position) &(waysx)->xdata[index]
105
106 #define PutBackWayX(waysx,index,position) /* nop */
107
108 #else
109
110 static WayX *LookupWayX(WaysX* waysx,index_t index,int position);
111
112 static void PutBackWayX(WaysX* waysx,index_t index,int position);
113
114
115 /*++++++++++++++++++++++++++++++++++++++
116 Lookup a particular extended way.
117
118 WayX *LookupWayX Returns a pointer to the extended way with the specified id.
119
120 WaysX* waysx The set of ways to process.
121
122 index_t index The way index to look for.
123
124 int position The position in the cache to use.
125 ++++++++++++++++++++++++++++++++++++++*/
126
127 static inline WayX *LookupWayX(WaysX* waysx,index_t index,int position)
128 {
129 SeekFile(waysx->fd,(off_t)index*sizeof(WayX));
130
131 ReadFile(waysx->fd,&waysx->xcached[position-1],sizeof(WayX));
132
133 return(&waysx->xcached[position-1]);
134 }
135
136
137 /*++++++++++++++++++++++++++++++++++++++
138 Put back an extended way.
139
140 WaysX* waysx The set of ways to process.
141
142 index_t index The way index to put back.
143
144 int position The position in the cache to use.
145 ++++++++++++++++++++++++++++++++++++++*/
146
147 static inline void PutBackWayX(WaysX* waysx,index_t index,int position)
148 {
149 SeekFile(waysx->fd,(off_t)index*sizeof(WayX));
150
151 WriteFile(waysx->fd,&waysx->xcached[position-1],sizeof(WayX));
152 }
153
154 #endif /* SLIM */
155
156
157 #endif /* WAYSX_H */

Properties

Name Value
cvs:description Extended ways header.