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 451 - (hide annotations) (download) (as text)
Tue Jul 13 17:43:51 2010 UTC (14 years, 8 months ago) by amb
File MIME type: text/x-chdr
File size: 3637 byte(s)
Move the functions for slim mode out into the header file and make it inline.

1 amb 110 /***************************************
2 amb 451 $Header: /home/amb/CVS/routino/src/waysx.h,v 1.23 2010-07-13 17:43:51 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 amb 451 #include <assert.h>
29 amb 110 #include <stdint.h>
30    
31 amb 449 #include "types.h"
32    
33 amb 199 #include "typesx.h"
34 amb 262 #include "ways.h"
35 amb 110
36 amb 451 #include "files.h"
37 amb 110
38 amb 451
39 amb 110 /* Data structures */
40    
41    
42     /*+ An extended structure containing a single way. +*/
43     struct _WayX
44     {
45 amb 203 way_t id; /*+ The way identifier. +*/
46    
47 amb 310 index_t prop; /*+ The index of the properties of the way in the compacted list. +*/
48    
49 amb 262 Way way; /*+ The real Way data. +*/
50 amb 110 };
51    
52    
53     /*+ A structure containing a set of ways (memory format). +*/
54     struct _WaysX
55     {
56 amb 262 char *filename; /*+ The name of the temporary file (for the WaysX). +*/
57     int fd; /*+ The file descriptor of the temporary file (for the WaysX). +*/
58 amb 216
59 amb 262 uint32_t xnumber; /*+ The number of unsorted extended ways. +*/
60 amb 216
61 amb 262 WayX *xdata; /*+ The extended data for the Ways (sorted). +*/
62     WayX cached[2]; /*+ Two cached ways read from the file in slim mode. +*/
63    
64 amb 215 uint32_t number; /*+ How many entries are still useful? +*/
65 amb 110
66 amb 262 uint32_t cnumber; /*+ How many entries are there after compacting? +*/
67 amb 203
68 amb 310 index_t *idata; /*+ The index of the extended data for the Ways (sorted by ID). +*/
69 amb 203
70 amb 262 char *nfilename; /*+ The name of the temporary file (for the names). +*/
71 amb 203
72 amb 262 uint32_t nlength; /*+ How long is the string of name entries? +*/
73 amb 110 };
74    
75    
76     /* Functions */
77    
78    
79 amb 326 WaysX *NewWayList(int append);
80     void FreeWayList(WaysX *waysx,int keep);
81 amb 110
82 amb 398 void SaveWayList(WaysX *waysx,const char *filename);
83 amb 110
84 amb 262 index_t IndexWayX(WaysX* waysx,way_t id);
85 amb 451 static WayX *LookupWayX(WaysX* waysx,index_t index,int position);
86 amb 110
87 amb 262 void AppendWay(WaysX* waysx,way_t id,Way *way,const char *name);
88 amb 203
89 amb 110 void SortWayList(WaysX *waysx);
90    
91 amb 451
92     /* Inline the frequently called functions */
93    
94     /*+ The command line '--slim' option. +*/
95     extern int option_slim;
96    
97     /*++++++++++++++++++++++++++++++++++++++
98     Lookup a particular way.
99    
100     WayX *LookupWayX Returns a pointer to the extended way with the specified id.
101    
102     WaysX* waysx The set of ways to process.
103    
104     index_t index The way index to look for.
105    
106     int position The position in the cache to use.
107     ++++++++++++++++++++++++++++++++++++++*/
108    
109     static inline WayX *LookupWayX(WaysX* waysx,index_t index,int position)
110     {
111     assert(index!=NO_WAY); /* Must be a valid way */
112    
113     if(option_slim)
114     {
115     SeekFile(waysx->fd,index*sizeof(WayX));
116    
117     ReadFile(waysx->fd,&waysx->cached[position-1],sizeof(WayX));
118    
119     return(&waysx->cached[position-1]);
120     }
121     else
122     {
123     return(&waysx->xdata[index]);
124     }
125     }
126    
127    
128 amb 110 #endif /* WAYSX_H */

Properties

Name Value
cvs:description Extended ways header.