diff options
-rw-r--r-- | navit/profile_option.c | 8 | ||||
-rw-r--r-- | navit/vehicleprofile.c | 37 | ||||
-rw-r--r-- | navit/vehicleprofile.h | 1 |
3 files changed, 34 insertions, 12 deletions
diff --git a/navit/profile_option.c b/navit/profile_option.c index a9d5a880f..c155ef6a5 100644 --- a/navit/profile_option.c +++ b/navit/profile_option.c @@ -47,12 +47,12 @@ profile_option_destroy(struct profile_option *po) struct object_func profile_option_func = { attr_profile_option, (object_func_new)profile_option_new, - (object_func_get_attr)NULL, + (object_func_get_attr)navit_object_get_attr, (object_func_iter_new)NULL, (object_func_iter_destroy)NULL, - (object_func_set_attr)NULL, - (object_func_add_attr)NULL, - (object_func_remove_attr)NULL, + (object_func_set_attr)navit_object_set_attr, + (object_func_add_attr)navit_object_add_attr, + (object_func_remove_attr)navit_object_remove_attr, (object_func_init)NULL, (object_func_destroy)profile_option_destroy, (object_func_dup)NULL, diff --git a/navit/vehicleprofile.c b/navit/vehicleprofile.c index a51ecb34f..6bfbfbbf4 100644 --- a/navit/vehicleprofile.c +++ b/navit/vehicleprofile.c @@ -25,6 +25,7 @@ #include "xmlconfig.h" #include "roadprofile.h" #include "vehicleprofile.h" +#include "callback.h" static void vehicleprofile_set_attr_do(struct vehicleprofile *this_, struct attr *attr) @@ -84,6 +85,27 @@ vehicleprofile_set_attr_do(struct vehicleprofile *this_, struct attr *attr) } } +static void +vehicleprofile_clear(struct vehicleprofile *this_) +{ + if (this_->roadprofile_hash) + g_hash_table_destroy(this_->roadprofile_hash); + this_->roadprofile_hash=g_hash_table_new(NULL, NULL); + this_->length=-1; + this_->width=-1; + this_->height=-1; + this_->weight=-1; + this_->axle_weight=-1; + this_->through_traffic_penalty=9000; +} + +static void +vehicleprofile_update(struct vehicleprofile *this_) +{ + dbg(0,"enter\n"); +} + + struct vehicleprofile * vehicleprofile_new(struct attr *parent, struct attr **attrs) { @@ -96,13 +118,9 @@ vehicleprofile_new(struct attr *parent, struct attr **attrs) this_->func=&vehicleprofile_func; navit_object_ref((struct navit_object *)this_); this_->attrs=attr_list_dup(attrs); - this_->roadprofile_hash=g_hash_table_new(NULL, NULL); - this_->length=-1; - this_->width=-1; - this_->height=-1; - this_->weight=-1; - this_->axle_weight=-1; - this_->through_traffic_penalty=9000; + this_->active_callback.type=attr_callback; + this_->active_callback.u.callback=callback_new_attr_1(callback_cast(vehicleprofile_update), attr_active, this_); + vehicleprofile_clear(this_); for (attr=attrs;*attr; attr++) vehicleprofile_set_attr_do(this_, *attr); return this_; @@ -111,7 +129,7 @@ vehicleprofile_new(struct attr *parent, struct attr **attrs) struct attr_iter * vehicleprofile_attr_iter_new(void) { - return g_new0(void *,1); + return (struct attr_iter *)g_new0(void *,1); } void @@ -154,6 +172,9 @@ vehicleprofile_add_attr(struct vehicleprofile *this_, struct attr *attr) } } break; + case attr_profile_option: + attr->u.navit_object->func->add_attr(attr->u.navit_object, &this_->active_callback); + break; default: break; } diff --git a/navit/vehicleprofile.h b/navit/vehicleprofile.h index 39f9cff6a..ecded6bba 100644 --- a/navit/vehicleprofile.h +++ b/navit/vehicleprofile.h @@ -39,6 +39,7 @@ struct vehicleprofile { int dangerous_goods; /**< Flags of dangerous goods present */ int through_traffic_penalty; /**< Penalty when driving on a through traffic limited road */ GHashTable *roadprofile_hash; + struct attr active_callback; }; struct vehicleprofile * vehicleprofile_new(struct attr *parent, struct attr **attrs); |