Navit SVN

/work/compile/navit/src/navit/attr.h

00001 
00020 #ifndef NAVIT_ATTR_H
00021 #define NAVIT_ATTR_H
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 #include "projection.h"
00028 
00029 enum item_type;
00030 
00031 enum attr_type {
00032 #define ATTR2(x,y) attr_##y=x,
00033 #define ATTR(x) attr_##x,
00034 #include "attr_def.h"
00035 #undef ATTR2
00036 #undef ATTR
00037 };
00038 
00039 #define AF_ONEWAY               (1<<0)
00040 #define AF_ONEWAYREV            (1<<1)
00041 #define AF_NOPASS               (AF_ONEWAY|AF_ONEWAYREV)
00042 #define AF_ONEWAYMASK           (AF_ONEWAY|AF_ONEWAYREV)
00043 #define AF_SEGMENTED            (1<<2)
00044 #define AF_ROUNDABOUT           (1<<3)
00045 #define AF_ROUNDABOUT_VALID     (1<<4)
00046 #define AF_ONEWAY_EXCEPTION     (1<<5)
00047 #define AF_SPEED_LIMIT          (1<<6)
00048 #define AF_RESERVED1            (1<<7)
00049 #define AF_SIZE_OR_WEIGHT_LIMIT (1<<8)
00050 #define AF_THROUGH_TRAFFIC_LIMIT (1<<9)
00051 #define AF_TOLL                 (1<<10)
00052 #define AF_SEASONAL             (1<<11)
00053 #define AF_UNPAVED              (1<<12)
00054 #define AF_FORD                 (1<<13)
00055 #define AF_UNDERGROUND          (1<<14)
00056 #define AF_DANGEROUS_GOODS      (1<<19)
00057 #define AF_EMERGENCY_VEHICLES   (1<<20)
00058 #define AF_TRANSPORT_TRUCK      (1<<21)
00059 #define AF_DELIVERY_TRUCK       (1<<22)
00060 #define AF_PUBLIC_BUS           (1<<23)
00061 #define AF_TAXI                 (1<<24) 
00062 #define AF_HIGH_OCCUPANCY_CAR   (1<<25) 
00063 #define AF_CAR                  (1<<26) 
00064 #define AF_MOTORCYCLE           (1<<27) 
00065 #define AF_MOPED                (1<<28) 
00066 #define AF_HORSE                (1<<29) 
00067 #define AF_BIKE                 (1<<30) 
00068 #define AF_PEDESTRIAN           (1<<31) 
00069 
00070 #define AF_PBH (AF_PEDESTRIAN|AF_BIKE|AF_HORSE)
00071 #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)
00072 #define AF_ALL (AF_PBH|AF_MOPED|AF_MOTORIZED_FAST)
00073 
00074 
00075 #define AF_DG_ANY               (1<<0)
00076 #define AF_DG_WATER_HARMFUL     (1<<1)
00077 #define AF_DG_EXPLOSIVE         (1<<2)
00078 #define AF_DG_FLAMMABLE         (1<<3)
00079 
00080 /* Values for attributes that could carry relative values */
00081 #define ATTR_REL_MAXABS                 0x40000000
00082 #define ATTR_REL_RELSHIFT               0x60000000
00083 
00084 enum attr_position_valid {
00085         attr_position_valid_invalid,
00086         attr_position_valid_static,
00087         attr_position_valid_extrapolated_time,
00088         attr_position_valid_extrapolated_spatial,
00089         attr_position_valid_valid,
00090 };
00091 
00092 #define ATTR_IS_INT(x) ((x) >= attr_type_int_begin && (x) <= attr_type_int_end)
00093 #define ATTR_IS_DOUBLE(x) ((x) >= attr_type_double_begin && (x) <= attr_type_double_end)
00094 #define ATTR_IS_STRING(x) ((x) >= attr_type_string_begin && (x) <= attr_type_string_end)
00095 #define ATTR_IS_OBJECT(x) ((x) >= attr_type_object_begin && (x) <= attr_type_object_end)
00096 #define ATTR_IS_ITEM(x) ((x) >= attr_type_item_begin && (x) <= attr_type_item_end)
00097 #define ATTR_IS_COORD_GEO(x) ((x) >= attr_type_coord_geo_begin && (x) <= attr_type_coord_geo_end)
00098 #define ATTR_IS_NUMERIC(x) (ATTR_IS_INT(x) || ATTR_IS_DOUBLE(x))
00099 #define ATTR_IS_COLOR(x) ((x) >= attr_type_color_begin && (x) <= attr_type_color_end)
00100 #define ATTR_IS_PCOORD(x) ((x) >= attr_type_pcoord_begin && (x) <= attr_type_pcoord_end)
00101 #define ATTR_IS_COORD(x) ((x) >= attr_type_coord_begin && (x) <= attr_type_coord_end)
00102 #define ATTR_IS_GROUP(x) ((x) >= attr_type_group_begin && (x) <= attr_type_group_end)
00103 
00104 #define ATTR_DEF_STR(x,y) (&(struct attr){attr_##x,{y}})
00105 #define ATTR_DEF_INT(x,y) (&(struct attr){attr_##x,{(char *)(y)}})
00106 #define ATTR_DEF_ITEMS(x,...) (&(struct attr){attr_##x,{(char *)((enum item_type[]){__VA_ARGS__ , type_none})}})
00107 #define ATTR_LIST(...) (struct attr *[]) { __VA_ARGS__, NULL}
00108 
00109 struct attr {
00110         enum attr_type type;
00111         union {
00112                 char *str;
00113                 void *data;
00114                 long num;
00115                 struct item *item;
00116                 enum item_type item_type;
00117                 enum projection projection;
00118                 double * numd;
00119                 struct color *color;
00120                 struct coord_geo *coord_geo;
00121                 struct navit *navit;
00122                 struct callback *callback;
00123                 struct callback_list *callback_list;
00124                 struct vehicle *vehicle;
00125                 struct layout *layout;
00126                 struct layer *layer;
00127                 struct map *map;
00128                 struct mapset *mapset;
00129                 struct log *log;
00130                 struct route *route;
00131                 struct navigation *navigation;
00132                 struct coord *coord;
00133                 struct pcoord *pcoord;
00134                 struct gui *gui;
00135                 struct graphics *graphics;
00136                 struct tracking *tracking;
00137                 struct itemgra *itemgra;
00138                 struct plugin *plugin;
00139                 struct plugins *plugins;
00140                 struct polygon *polygon;
00141                 struct polyline *polyline;
00142                 struct circle *circle;
00143                 struct text *text;
00144                 struct icon *icon;
00145                 struct image *image;
00146                 struct arrows *arrows;
00147                 struct element *element;
00148                 struct speech *speech;
00149                 struct cursor *cursor;
00150                 struct displaylist *displaylist;
00151                 struct transformation *transformation;
00152                 struct vehicleprofile *vehicleprofile;
00153                 struct roadprofile *roadprofile;
00154                 struct bookmarks *bookmarks;
00155                 struct config *config;
00156                 struct osd *osd;
00157                 struct range {
00158                         short min, max;
00159                 } range;
00160                 int *dash;
00161                 enum item_type *item_types;
00162                 enum attr_type *attr_types;
00163                 long long *num64;
00164                 struct attr *attrs;
00165         } u;
00166 };
00167 
00168 struct attr_iter;
00169 /* prototypes */
00170 enum attr_type attr_from_name(const char *name);
00171 char *attr_to_name(enum attr_type attr);
00172 struct attr *attr_new_from_text(const char *name, const char *value);
00173 char *attr_to_text(struct attr *attr, struct map *map, int pretty);
00174 struct attr *attr_search(struct attr **attrs, struct attr *last, enum attr_type attr);
00175 int attr_generic_get_attr(struct attr **attrs, struct attr **def_attrs, enum attr_type type, struct attr *attr, struct attr_iter *iter);
00176 struct attr **attr_generic_set_attr(struct attr **attrs, struct attr *attr);
00177 struct attr **attr_generic_add_attr(struct attr **attrs, struct attr *attr);
00178 struct attr **attr_generic_remove_attr(struct attr **attrs, struct attr *attr);
00179 enum attr_type attr_type_begin(enum attr_type type);
00180 int attr_data_size(struct attr *attr);
00181 void *attr_data_get(struct attr *attr);
00182 void attr_data_set(struct attr *attr, void *data);
00183 void attr_data_set_le(struct attr *attr, void *data);
00184 void attr_free(struct attr *attr);
00185 void attr_dup_content(struct attr *src, struct attr *dst);
00186 struct attr *attr_dup(struct attr *attr);
00187 void attr_list_free(struct attr **attrs);
00188 struct attr **attr_list_dup(struct attr **attrs);
00189 int attr_from_line(char *line, char *name, int *pos, char *val_ret, char *name_ret);
00190 int attr_types_contains(enum attr_type *types, enum attr_type type);
00191 int attr_types_contains_default(enum attr_type *types, enum attr_type type, int deflt);
00192 /* end of prototypes */
00193 #ifdef __cplusplus
00194 }
00195 #endif
00196 
00197 #endif