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