From e1bdc51ec2167d17da91a09c1cd3397da225d22e Mon Sep 17 00:00:00 2001 From: martin-s Date: Sat, 21 Mar 2009 17:17:41 +0000 Subject: [PATCH] Add:Core:Extended attribute system git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@2156 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/attr.h | 2 ++ navit/navit/attr_def.h | 2 ++ navit/navit/navit.c | 26 ++++++++++++++++++++++++-- navit/navit/route.c | 13 ++++++++++++- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/navit/navit/attr.h b/navit/navit/attr.h index 620e9c9..d0469cd 100644 --- a/navit/navit/attr.h +++ b/navit/navit/attr.h @@ -108,6 +108,8 @@ struct attr { struct element *element; struct speech *speech; struct cursor *cursor; + struct displaylist *displaylist; + struct transformation *transformation; struct range { short min, max; } range; diff --git a/navit/navit/attr_def.h b/navit/navit/attr_def.h index 723f946..f60d942 100644 --- a/navit/navit/attr_def.h +++ b/navit/navit/attr_def.h @@ -256,6 +256,8 @@ ATTR(speech) ATTR(coord) ATTR(private_data) ATTR(callback_list) +ATTR(displaylist) +ATTR(transformation) ATTR2(0x0008ffff,type_object_end) ATTR2(0x00090000,type_coord_begin) ATTR2(0x0009ffff,type_coord_end) diff --git a/navit/navit/navit.c b/navit/navit/navit.c index d5cbe3c..e6528bf 100644 --- a/navit/navit/navit.c +++ b/navit/navit/navit.c @@ -1688,9 +1688,15 @@ navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, stru return 0; attr->u.pcoord=&this_->destination; break; + case attr_displaylist: + attr->u.displaylist=this_->displaylist; + return (attr->u.displaylist != NULL); case attr_former_destination_map: attr->u.map=this_->former_destination; break; + case attr_graphics: + attr->u.graphics=this_->gra; + return (attr->u.graphics != NULL); case attr_gui: attr->u.gui=this_->gui; break; @@ -1722,6 +1728,9 @@ navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, stru return 0; } break; + case attr_mapset: + attr->u.mapset=this_->mapsets->data; + return (attr->u.mapset != NULL); case attr_navigation: attr->u.navigation=this_->navigation; break; @@ -1747,6 +1756,9 @@ navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, stru case attr_tracking: attr->u.num=this_->tracking_flag; break; + case attr_transformation: + attr->u.transformation=this_->trans; + break; case attr_vehicle: if(iter) { if(iter->u.list) { @@ -1800,6 +1812,9 @@ navit_add_attr(struct navit *this_, struct attr *attr) { int ret=1; switch (attr->type) { + case attr_callback: + navit_add_callback(this_, attr->u.callback); + break; case attr_log: ret=navit_add_log(this_, attr->u.log); break; @@ -1813,7 +1828,6 @@ navit_add_attr(struct navit *this_, struct attr *attr) this_->layouts = g_list_append(this_->layouts, attr->u.layout); if(!this_->layout_current) this_->layout_current=attr->u.layout; - ret=1; break; case attr_route: this_->route=attr->u.route; @@ -1849,7 +1863,15 @@ navit_add_attr(struct navit *this_, struct attr *attr) int navit_remove_attr(struct navit *this_, struct attr *attr) { - return 0; + int ret=1; + switch (attr->type) { + case attr_callback: + navit_remove_callback(this_, attr->u.callback); + break; + default: + return 0; + } + return ret; } struct attr_iter * diff --git a/navit/navit/route.c b/navit/navit/route.c index 3f9d2d8..2979e1e 100644 --- a/navit/navit/route.c +++ b/navit/navit/route.c @@ -2807,10 +2807,21 @@ route_remove_callback(struct route *this_, struct callback *cb) callback_list_remove(this_->cbl, cb); } - +int +route_get_attr(struct route *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) +{ + switch (type) { + case attr_map: + attr->u.map=route_get_map(this_); + return attr->u.map != NULL; + default: + return 0; + } +} void route_init(void) { plugin_register_map_type("route", route_map_new); plugin_register_map_type("route_graph", route_graph_map_new); } + -- 2.7.4