/[zanavi_public1]/navit/navit/attr.h
ZANavi

Contents of /navit/navit/attr.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 29 - (show annotations) (download)
Tue Aug 21 19:31:50 2012 UTC (11 years, 7 months ago) by zoff99
File MIME type: text/plain
File size: 7617 byte(s)
some fixes
1 /**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2011-2012 Zoff <zoff@zoff.cc>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 /**
21 * Navit, a modular navigation system.
22 * Copyright (C) 2005-2008 Navit Team
23 *
24 * This program is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU Library General Public License
26 * version 2 as published by the Free Software Foundation.
27 *
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU Library General Public License for more details.
32 *
33 * You should have received a copy of the GNU Library General Public
34 * License along with this program; if not, write to the
35 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
36 * Boston, MA 02110-1301, USA.
37 */
38
39 #ifndef NAVIT_ATTR_H
40 #define NAVIT_ATTR_H
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 #include "projection.h"
47
48 enum item_type;
49
50 enum attr_type {
51 #define ATTR2(x,y) attr_##y=x,
52 #define ATTR(x) attr_##x,
53 #include "attr_def.h"
54 #undef ATTR2
55 #undef ATTR
56 };
57
58 #define AF_ONEWAY (1<<0)
59 #define AF_ONEWAYREV (1<<1)
60 #define AF_NOPASS (AF_ONEWAY|AF_ONEWAYREV)
61 #define AF_ONEWAYMASK (AF_ONEWAY|AF_ONEWAYREV)
62 #define AF_SEGMENTED (1<<2)
63 #define AF_ROUNDABOUT (1<<3)
64 #define AF_ROUNDABOUT_VALID (1<<4)
65 #define AF_ONEWAY_EXCEPTION (1<<5)
66 #define AF_SPEED_LIMIT (1<<6)
67 #define AF_RESERVED1 (1<<7)
68 #define AF_SIZE_OR_WEIGHT_LIMIT (1<<8)
69 #define AF_THROUGH_TRAFFIC_LIMIT (1<<9)
70 #define AF_TOLL (1<<10)
71 #define AF_SEASONAL (1<<11)
72 #define AF_UNPAVED (1<<12)
73 #define AF_FORD (1<<13)
74 #define AF_UNDERGROUND (1<<14)
75 #define AF_BRIDGE (1<<15) // NEW !!
76 // 16 - 18 is still free!!
77 #define AF_DANGEROUS_GOODS (1<<19)
78 #define AF_EMERGENCY_VEHICLES (1<<20)
79 #define AF_TRANSPORT_TRUCK (1<<21)
80 #define AF_DELIVERY_TRUCK (1<<22)
81 #define AF_PUBLIC_BUS (1<<23)
82 #define AF_TAXI (1<<24)
83 #define AF_HIGH_OCCUPANCY_CAR (1<<25)
84 #define AF_CAR (1<<26)
85 #define AF_MOTORCYCLE (1<<27)
86 #define AF_MOPED (1<<28)
87 #define AF_HORSE (1<<29)
88 #define AF_BIKE (1<<30)
89 #define AF_PEDESTRIAN (1<<31)
90
91 #define AF_PBH (AF_PEDESTRIAN|AF_BIKE|AF_HORSE)
92 #define AF_MOTORIZED_FAST (AF_MOTORCYCLE|AF_CAR|AF_HIGH_OCCUPANCY_CAR|AF_TAXI|AF_PUBLIC_BUS|AF_DELIVERY_TRUCK|AF_TRANSPORT_TRUCK|AF_EMERGENCY_VEHICLES)
93 #define AF_ALL (AF_PBH|AF_MOPED|AF_MOTORIZED_FAST)
94
95
96 #define AF_DG_ANY (1<<0)
97 #define AF_DG_WATER_HARMFUL (1<<1)
98 #define AF_DG_EXPLOSIVE (1<<2)
99 #define AF_DG_FLAMMABLE (1<<3)
100
101 /* Values for attributes that could carry relative values */
102 #define ATTR_REL_MAXABS 0x40000000
103 #define ATTR_REL_RELSHIFT 0x60000000
104
105 enum attr_position_valid {
106 attr_position_valid_invalid,
107 attr_position_valid_static,
108 attr_position_valid_extrapolated_time,
109 attr_position_valid_extrapolated_spatial,
110 attr_position_valid_valid,
111 };
112
113 #define ATTR_IS_INT(x) ((x) >= attr_type_int_begin && (x) <= attr_type_int_end)
114 #define ATTR_IS_DOUBLE(x) ((x) >= attr_type_double_begin && (x) <= attr_type_double_end)
115 #define ATTR_IS_STRING(x) ((x) >= attr_type_string_begin && (x) <= attr_type_string_end)
116 #define ATTR_IS_OBJECT(x) ((x) >= attr_type_object_begin && (x) <= attr_type_object_end)
117 #define ATTR_IS_ITEM(x) ((x) >= attr_type_item_begin && (x) <= attr_type_item_end)
118 #define ATTR_IS_COORD_GEO(x) ((x) >= attr_type_coord_geo_begin && (x) <= attr_type_coord_geo_end)
119 #define ATTR_IS_NUMERIC(x) (ATTR_IS_INT(x) || ATTR_IS_DOUBLE(x))
120 #define ATTR_IS_COLOR(x) ((x) >= attr_type_color_begin && (x) <= attr_type_color_end)
121 #define ATTR_IS_PCOORD(x) ((x) >= attr_type_pcoord_begin && (x) <= attr_type_pcoord_end)
122 #define ATTR_IS_COORD(x) ((x) >= attr_type_coord_begin && (x) <= attr_type_coord_end)
123 #define ATTR_IS_GROUP(x) ((x) >= attr_type_group_begin && (x) <= attr_type_group_end)
124
125 #define ATTR_DEF_STR(x,y) (&(struct attr){attr_##x,{y}})
126 #define ATTR_DEF_INT(x,y) (&(struct attr){attr_##x,{(char *)(y)}})
127 #define ATTR_DEF_ITEMS(x,...) (&(struct attr){attr_##x,{(char *)((enum item_type[]){__VA_ARGS__ , type_none})}})
128 #define ATTR_LIST(...) (struct attr *[]) { __VA_ARGS__, NULL}
129
130 struct attr {
131 enum attr_type type;
132 union {
133 char *str;
134 void *data;
135 long num;
136 struct item *item;
137 enum item_type item_type;
138 enum projection projection;
139 double * numd;
140 struct color *color;
141 struct coord_geo *coord_geo;
142 struct navit *navit;
143 struct callback *callback;
144 struct callback_list *callback_list;
145 struct vehicle *vehicle;
146 struct layout *layout;
147 struct layer *layer;
148 struct map *map;
149 struct mapset *mapset;
150 struct log *log;
151 struct route *route;
152 struct navigation *navigation;
153 struct coord *coord;
154 struct pcoord *pcoord;
155 struct gui *gui;
156 struct graphics *graphics;
157 struct tracking *tracking;
158 struct itemgra *itemgra;
159 struct plugin *plugin;
160 struct plugins *plugins;
161 struct polygon *polygon;
162 struct polyline *polyline;
163 struct circle *circle;
164 struct text *text;
165 struct icon *icon;
166 struct image *image;
167 struct arrows *arrows;
168 struct element *element;
169 struct speech *speech;
170 struct cursor *cursor;
171 struct displaylist *displaylist;
172 struct transformation *transformation;
173 struct vehicleprofile *vehicleprofile;
174 struct roadprofile *roadprofile;
175 struct bookmarks *bookmarks;
176 struct range {
177 short min, max;
178 } range;
179 int *dash;
180 enum item_type *item_types;
181 enum attr_type *attr_types;
182 long long *num64;
183 struct attr *attrs;
184 } u;
185 };
186
187 struct attr_iter;
188 /* prototypes */
189 enum attr_type attr_from_name(const char *name);
190 char *attr_to_name(enum attr_type attr);
191 struct attr *attr_new_from_text(const char *name, const char *value);
192 char *attr_to_text(struct attr *attr, struct map *map, int pretty);
193 struct attr *attr_search(struct attr **attrs, struct attr *last, enum attr_type attr);
194 int attr_generic_get_attr(struct attr **attrs, struct attr **def_attrs, enum attr_type type, struct attr *attr, struct attr_iter *iter);
195 struct attr **attr_generic_set_attr(struct attr **attrs, struct attr *attr);
196 struct attr **attr_generic_add_attr(struct attr **attrs, struct attr *attr);
197 struct attr **attr_generic_remove_attr(struct attr **attrs, struct attr *attr);
198 enum attr_type attr_type_begin(enum attr_type type);
199 int attr_data_size(struct attr *attr);
200 void *attr_data_get(struct attr *attr);
201 void attr_data_set(struct attr *attr, void *data);
202 void attr_data_set_le(struct attr *attr, void *data);
203 void attr_free(struct attr *attr);
204 void attr_dup_content(struct attr *src, struct attr *dst);
205 struct attr *attr_dup(struct attr *attr);
206 void attr_list_free(struct attr **attrs);
207 struct attr **attr_list_dup(struct attr **attrs);
208 int attr_from_line(char *line, char *name, int *pos, char *val_ret, char *name_ret);
209 int attr_types_contains(enum attr_type *types, enum attr_type type);
210 int attr_types_contains_default(enum attr_type *types, enum attr_type type, int deflt);
211
212 char *flags_to_text(int flags);
213
214 /* end of prototypes */
215 #ifdef __cplusplus
216 }
217 #endif
218
219 #endif

   
Visit the ZANavi Wiki