navit  0.5.3-trunk
attr.h
Go to the documentation of this file.
1 
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 
34 enum attr_type {
35 #define ATTR2(x,y) attr_##y=x,
36 #define ATTR(x) attr_##x,
37 
38 /* Special macro for unused attribute types. Creates a placeholder entry
39  * in the enum so the following values do not change. */
40 #define ATTR_UNUSED ATTR_UNUSED_L(__LINE__)
41 #define ATTR_UNUSED_L(x) ATTR_UNUSED_WITH_LINE_NUMBER(x)
42 #define ATTR_UNUSED_WITH_LINE_NUMBER(x) ATTR_UNUSED_##x,
43 
44 #include "attr_def.h"
45 
46 #undef ATTR_UNUSED_WITH_LINE_NUMBER
47 #undef ATTR_UNUSED_L
48 #undef ATTR_UNUSED
49 
50 #undef ATTR2
51 #undef ATTR
52 };
53 
57 };
58 
59 #define AF_ONEWAY (1<<0)
60 #define AF_ONEWAYREV (1<<1)
61 #define AF_NOPASS (AF_ONEWAY|AF_ONEWAYREV)
62 #define AF_ONEWAYMASK (AF_ONEWAY|AF_ONEWAYREV)
63 #define AF_SEGMENTED (1<<2)
64 #define AF_ROUNDABOUT (1<<3)
65 #define AF_ROUNDABOUT_VALID (1<<4)
66 #define AF_ONEWAY_EXCEPTION (1<<5)
67 #define AF_SPEED_LIMIT (1<<6)
68 #define AF_RESERVED1 (1<<7)
69 #define AF_SIZE_OR_WEIGHT_LIMIT (1<<8)
70 #define AF_THROUGH_TRAFFIC_LIMIT (1<<9)
71 #define AF_TOLL (1<<10)
72 #define AF_SEASONAL (1<<11)
73 #define AF_UNPAVED (1<<12)
74 #define AF_FORD (1<<13)
75 #define AF_UNDERGROUND (1<<14)
76 #define AF_HIGH_OCCUPANCY_CAR_ONLY (1<<18)
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 #define AF_DISTORTIONMASK (AF_ALL|AF_ONEWAYMASK)
95 
96 
97 #define AF_DG_ANY (1<<0)
98 #define AF_DG_WATER_HARMFUL (1<<1)
99 #define AF_DG_EXPLOSIVE (1<<2)
100 #define AF_DG_FLAMMABLE (1<<3)
101 
102 /*
103  * Values for attributes that could carry relative values.
104  * Some attributes allow both absolute and relative values. The value for these
105  * attributes is stored as an int. Absolute values are stored as-is, relative
106  * values are stored shifted by adding ATTR_REL_RELSHIFT.
107  */
109 #define ATTR_REL_MINABS -0x40000000
110 
111 #define ATTR_REL_MAXABS 0x40000000
112 
113 #define ATTR_REL_MINREL -0x1FFFFFFF
114 
115 #define ATTR_REL_MAXREL 0x20000000
116 
119 #define ATTR_REL_RELSHIFT 0x60000000
120 
136 };
137 
138 #define ATTR_IS_INT(x) ((x) >= attr_type_int_begin && (x) <= attr_type_int_end)
139 #define ATTR_IS_DOUBLE(x) ((x) >= attr_type_double_begin && (x) <= attr_type_double_end)
140 #define ATTR_IS_STRING(x) ((x) >= attr_type_string_begin && (x) <= attr_type_string_end)
141 #define ATTR_IS_OBJECT(x) ((x) >= attr_type_object_begin && (x) <= attr_type_object_end)
142 #define ATTR_IS_ITEM(x) ((x) >= attr_type_item_begin && (x) <= attr_type_item_end)
143 #define ATTR_IS_COORD_GEO(x) ((x) >= attr_type_coord_geo_begin && (x) <= attr_type_coord_geo_end)
144 #define ATTR_IS_NUMERIC(x) (ATTR_IS_INT(x) || ATTR_IS_DOUBLE(x))
145 #define ATTR_IS_COLOR(x) ((x) >= attr_type_color_begin && (x) <= attr_type_color_end)
146 #define ATTR_IS_PCOORD(x) ((x) >= attr_type_pcoord_begin && (x) <= attr_type_pcoord_end)
147 #define ATTR_IS_COORD(x) ((x) >= attr_type_coord_begin && (x) <= attr_type_coord_end)
148 #define ATTR_IS_GROUP(x) ((x) >= attr_type_group_begin && (x) <= attr_type_group_end)
149 
150 #define ATTR_INT(x,y) ((struct attr){attr_##x,{.num=y}})
151 #define ATTR_OBJECT(x,y) ((struct attr){attr_##x,{.navit=y}})
152 
153 struct range {
154  short min, max;
155 };
156 
157 struct attr {
159  union {
160  char *str;
161  void *data;
162  long num;
163  struct item *item;
166  double * numd;
167  struct color *color;
169  struct navit *navit;
172  struct vehicle *vehicle;
173  struct layout *layout;
174  struct layer *layer;
175  struct map *map;
176  struct mapset *mapset;
177  struct log *log;
178  struct route *route;
180  struct coord *coord;
181  struct pcoord *pcoord;
182  struct gui *gui;
185  struct itemgra *itemgra;
186  struct plugin *plugin;
187  struct plugins *plugins;
188  struct polygon *polygon;
189  struct polyline *polyline;
190  struct circle *circle;
191  struct text *text;
192  struct icon *icon;
193  struct image *image;
194  struct arrows *arrows;
195  struct element *element;
196  struct speech *speech;
197  struct cursor *cursor;
203  struct config *config;
204  struct osd *osd;
205  struct range range;
207  int *dash;
208  enum item_type *item_types;
210  long long *num64;
211  struct attr *attrs;
212  } u;
213 };
214 
215 struct attr_iter;
216 /* prototypes */
217 void attr_create_hash(void);
218 void attr_destroy_hash(void);
219 enum attr_type attr_from_name(const char *name);
220 char *attr_to_name(enum attr_type attr);
221 struct attr *attr_new_from_text(const char *name, const char *value);
222 char *attr_to_text_ext(struct attr *attr, char *sep, enum attr_format fmt, enum attr_format def_fmt, struct map *map);
223 char *attr_to_text(struct attr *attr, struct map *map, int pretty);
224 struct attr *attr_search(struct attr **attrs, struct attr *last, enum attr_type attr);
225 int attr_generic_get_attr(struct attr **attrs, struct attr **def_attrs, enum attr_type type, struct attr *attr, struct attr_iter *iter);
226 struct attr **attr_generic_set_attr(struct attr **attrs, struct attr *attr);
227 struct attr **attr_generic_add_attr(struct attr **attrs, struct attr *attr);
228 struct attr **attr_generic_add_attr_list(struct attr **attrs, struct attr **add);
229 struct attr **attr_generic_prepend_attr(struct attr **attrs, struct attr *attr);
230 struct attr **attr_generic_remove_attr(struct attr **attrs, struct attr *attr);
232 int attr_data_size(struct attr *attr);
233 void *attr_data_get(struct attr *attr);
234 void attr_data_set(struct attr *attr, void *data);
235 void attr_data_set_le(struct attr *attr, void *data);
236 void attr_free_content(struct attr *attr);
237 void attr_free(struct attr *attr);
238 void attr_dup_content(struct attr *src, struct attr *dst);
239 struct attr *attr_dup(struct attr *attr);
240 void attr_list_free(struct attr **attrs);
241 struct attr **attr_list_dup(struct attr **attrs);
242 struct attr **attr_list_append(struct attr **attrs, struct attr *attr);
243 int attr_from_line(char *line, char *name, int *pos, char *val_ret, char *name_ret);
245 int attr_types_contains_default(enum attr_type *types, enum attr_type type, int deflt);
246 int attr_rel2real(int attrval, int whole, int treat_neg_as_rel);
247 /* end of prototypes */
248 #ifdef __cplusplus
249 }
250 #endif
251 
252 #endif
Definition: navigation.c:161
Definition: speech.c:28
attr_type
Definition: attr.h:34
struct polyline * polyline
Definition: attr.h:189
int attr_data_size(struct attr *attr)
Definition: attr.c:740
unsigned char types
Definition: garmin_img.c:484
struct tracking * tracking
Definition: attr.h:184
char * attr_to_text_ext(struct attr *attr, char *sep, enum attr_format fmt, enum attr_format def_fmt, struct map *map)
Converts attribute data to human-readable text.
Definition: attr.c:362
struct speech * speech
Definition: attr.h:196
enum attr_type * attr_types
Definition: attr.h:209
struct mapset * mapset
Definition: attr.h:176
Definition: config_.c:34
struct plugins * plugins
Definition: attr.h:187
struct coord_geo * coord_geo
Definition: attr.h:168
struct gui * gui
Definition: attr.h:182
Attribute definitions.
short max
Definition: attr.h:154
attr_format
Definition: attr.h:54
struct circle * circle
Definition: attr.h:190
struct icon * icon
Definition: attr.h:192
Definition: graphics.c:1491
Definition: item.h:99
Definition: color.h:23
struct displaylist * displaylist
Definition: attr.h:198
A mapset.
Definition: mapset.c:44
struct image * image
Definition: attr.h:193
void attr_list_free(struct attr **attrs)
Frees a list of attributes.
Definition: attr.c:873
enum item_type * item_types
Definition: attr.h:208
Definition: attr.h:124
Definition: gui.c:30
struct pcoord * pcoord
Definition: attr.h:181
Definition: log.c:57
struct attr ** attr_generic_prepend_attr(struct attr **attrs, struct attr *attr)
Definition: attr.c:656
struct attr ** attr_generic_remove_attr(struct attr **attrs, struct attr *attr)
Removes an attribute from an attribute list.
Definition: attr.c:686
struct plugin * plugin
Definition: attr.h:186
item_type
Definition: item.h:29
void attr_data_set(struct attr *attr, void *data)
Definition: attr.c:786
Definition: vehicle.c:58
void * attr_data_get(struct attr *attr)
Definition: attr.c:777
Definition: roadprofile.h:24
Definition: vehicleprofile.h:33
struct graphics * graphics
Definition: attr.h:183
struct element * element
Definition: attr.h:195
Definition: track.c:84
struct log * log
Definition: attr.h:177
struct config * config
Definition: attr.h:203
Definition: plugin.c:121
static GValue value
Definition: datawindow.c:42
struct item * item
Definition: attr.h:163
void attr_create_hash(void)
Definition: attr.c:70
struct navit_object * navit_object
Definition: attr.h:206
char * attr_to_name(enum attr_type attr)
Converts an attr_type to a string.
Definition: attr.c:116
void attr_dup_content(struct attr *src, struct attr *dst)
Definition: attr.c:832
Definition: layout.h:31
short min
Definition: attr.h:154
A complete route.
Definition: route.c:201
Definition: bookmarks.c:53
struct navit * navit
Definition: attr.h:169
void attr_data_set_le(struct attr *attr, void *data)
Definition: attr.c:794
struct vehicleprofile * vehicleprofile
Definition: attr.h:200
Definition: plugin.c:132
void * data
Definition: attr.h:161
struct attr ** attr_list_dup(struct attr **attrs)
Duplicates a list of attributes.
Definition: attr.c:893
attr_position_valid
Definition: attr.h:122
int attr_rel2real(int attrval, int whole, int treat_neg_as_rel)
Derive absolute value from relative attribute, given value of the whole range.
Definition: attr.c:1005
projection
Definition: projection.h:23
struct attr ** attr_generic_add_attr_list(struct attr **attrs, struct attr **add)
Definition: attr.c:647
graphics object A graphics object serves as the target for drawing operations. It encapsulates variou...
Definition: graphics.c:71
Definition: config_.c:47
Definition: layout.h:87
pos
Definition: startup.py:3
union attr::@0 u
struct color * color
Definition: attr.h:167
Definition: attr.h:135
long num
Definition: attr.h:162
struct polygon * polygon
Definition: attr.h:188
Definition: callback.c:37
Definition: attr.h:153
char data
Definition: garmin_img.c:330
Definition: attr.h:157
struct coord * coord
Definition: attr.h:180
struct callback_list * callback_list
Definition: attr.h:171
struct route * route
Definition: attr.h:178
Definition: callback.c:27
Definition: layout.h:71
struct roadprofile * roadprofile
Definition: attr.h:201
void attr_free_content(struct attr *attr)
Definition: attr.c:822
int * dash
Definition: attr.h:207
Definition: attr.h:123
void attr_free(struct attr *attr)
Definition: attr.c:827
enum attr_type attr_type_begin(enum attr_type type)
Definition: attr.c:710
char * str
Definition: attr.h:160
Holds information about a map.
Definition: map.c:60
long long * num64
Definition: attr.h:210
struct attr * attr_new_from_text(const char *name, const char *value)
Creates an attribute from text information.
Definition: attr.c:137
Definition: attr.h:55
struct text * text
Definition: attr.h:191
struct osd * osd
Definition: attr.h:204
struct arrows * arrows
Definition: attr.h:194
Definition: osd.c:34
struct attr * attrs
Definition: attr.h:211
void attr_destroy_hash(void)
Definition: attr.c:78
double * numd
Definition: attr.h:166
struct attr ** attr_list_append(struct attr **attrs, struct attr *attr)
int attr_from_line(char *line, char *name, int *pos, char *val_ret, char *name_ret)
Definition: attr.c:908
struct layout * layout
Definition: attr.h:173
Definition: graphics.c:116
struct attr * attr_dup(struct attr *attr)
Definition: attr.c:858
struct bookmarks * bookmarks
Definition: attr.h:202
enum attr_type attr_from_name(const char *name)
Converts a string to an attr_type.
Definition: attr.c:91
struct transformation * transformation
Definition: attr.h:199
struct vehicle * vehicle
Definition: attr.h:172
struct layer * layer
Definition: attr.h:174
char type[3]
Definition: garmin_img.c:123
Definition: coord.h:34
char name[0]
Definition: street.c:496
struct itemgra * itemgra
Definition: attr.h:185
struct map * map
Definition: attr.h:175
Definition: navit.c:112
Definition: coord.h:52
struct callback * callback
Definition: attr.h:170
int attr_types_contains_default(enum attr_type *types, enum attr_type type, int deflt)
Check if an enumeration of attribute types contains a specific attribute.
Definition: attr.c:989
Definition: attr.h:56
struct attr * attr_search(struct attr **attrs, struct attr *last, enum attr_type attr)
Searches for an attribute of a given type.
Definition: attr.c:503
A WGS84 coordinate.
Definition: coord.h:97
struct cursor * cursor
Definition: attr.h:197
struct navigation * navigation
Definition: attr.h:179
The parameters needed to transform a map for display.
Definition: transform.c:64
struct attr ** attr_generic_set_attr(struct attr **attrs, struct attr *attr)
Generic set function.
Definition: attr.c:597
char * attr_to_text(struct attr *attr, struct map *map, int pretty)
Converts an attribute to a string that can be displayed.
Definition: attr.c:486
int attr_types_contains(enum attr_type *types, enum attr_type type)
Checks if an enumeration of attribute types contains a specific attribute.
Definition: attr.c:968
int attr_generic_get_attr(struct attr **attrs, struct attr **def_attrs, enum attr_type type, struct attr *attr, struct attr_iter *iter)
Generic get function.
Definition: attr.c:557
Definition: xmlconfig.h:120
struct attr ** attr_generic_add_attr(struct attr **attrs, struct attr *attr)
Generic add function.
Definition: attr.c:629
Definition: layout.h:77
Definition: layout.h:95