summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2013-05-24 20:45:46 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2013-05-24 20:45:46 +0000
commitcf89c725ac1edbb4e9b833fb111ae61c532622ec (patch)
treec9f6422f7ac47f48ceefe717a8d6171360f723af
parent074ba8f63d30267a4607f8cedd67ef5d5dd19ea5 (diff)
downloadnavit-cf89c725ac1edbb4e9b833fb111ae61c532622ec.tar.gz
Add:Core:Converted log object to new scheme
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@5506 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r--navit/navit/log.c23
-rw-r--r--navit/navit/vehicle.c14
-rw-r--r--navit/navit/xmlconfig.c3
-rw-r--r--navit/navit/xmlconfig.h4
4 files changed, 29 insertions, 15 deletions
diff --git a/navit/navit/log.c b/navit/navit/log.c
index 574b7732d..60ae5c385 100644
--- a/navit/navit/log.c
+++ b/navit/navit/log.c
@@ -36,6 +36,7 @@
#include "event.h"
#include "callback.h"
#include "debug.h"
+#include "xmlconfig.h"
#include "log.h"
struct log_data {
@@ -45,6 +46,7 @@ struct log_data {
};
struct log {
+ NAVIT_OBJECT
FILE *f;
int overwrite;
int empty;
@@ -63,7 +65,6 @@ struct log {
struct log_data header;
struct log_data data;
struct log_data trailer;
- struct attr **attrs;
};
static void
@@ -240,6 +241,8 @@ log_new(struct attr * parent,struct attr **attrs)
char *filename, **wexp_data;
dbg(1,"enter\n");
+ ret->func=&log_func;
+ navit_object_ref((struct navit_object *)ret);
data=attr_search(attrs, NULL, attr_data);
if (! data)
return NULL;
@@ -347,6 +350,7 @@ log_printf(struct log *this_, char *fmt, ...)
void
log_destroy(struct log *this_)
{
+ dbg(0,"enter\n");
attr_list_free(this_->attrs);
callback_destroy(this_->timer_callback);
event_remove_timeout(this_->timer);
@@ -354,3 +358,20 @@ log_destroy(struct log *this_)
log_close(this_);
g_free(this_);
}
+
+struct object_func log_func = {
+ attr_log,
+ (object_func_new)log_new,
+ (object_func_get_attr)navit_object_get_attr,
+ (object_func_iter_new)navit_object_attr_iter_new,
+ (object_func_iter_destroy)navit_object_attr_iter_destroy,
+ (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)log_destroy,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
+};
+
diff --git a/navit/navit/vehicle.c b/navit/navit/vehicle.c
index 9e9a63a8d..a67779467 100644
--- a/navit/navit/vehicle.c
+++ b/navit/navit/vehicle.c
@@ -146,15 +146,7 @@ vehicle_new(struct attr *parent, struct attr **attrs)
void
vehicle_destroy(struct vehicle *this_)
{
- /* flush all logfiles on exit to avoid loss of yet unwritten data*/
- GList *ll, *l;
- gpointer key;
- for(ll=l=g_hash_to_list_keys(this_->log_to_cb);l;l=g_list_next(l)) {
- key=l->data;
- log_write(key,"",0,log_flag_force_flush);
- }
- g_list_free(ll);
-
+ dbg(0,"enter\n");
if (this_->animate_callback) {
callback_destroy(this_->animate_callback);
event_remove_timeout(this_->animate_timer);
@@ -707,10 +699,10 @@ vehicle_add_log(struct vehicle *this_, struct log *log)
} else if (!strcmp(type_attr.u.str, "binfile")) {
cb=callback_new_attr_2(callback_cast(vehicle_log_binfile), attr_position_coord_geo, this_, log);
} else
- return 1;
+ return 0;
g_hash_table_insert(this_->log_to_cb, log, cb);
callback_list_add(this_->cbl, cb);
- return 0;
+ return 1;
}
struct object_func vehicle_func = {
diff --git a/navit/navit/xmlconfig.c b/navit/navit/xmlconfig.c
index 337687895..f8a01e507 100644
--- a/navit/navit/xmlconfig.c
+++ b/navit/navit/xmlconfig.c
@@ -267,7 +267,6 @@ static struct object_func object_funcs[] = {
{ attr_icon, NEW(icon_new), NULL, NULL, NULL, NULL, ADD(element_add_attr)},
{ attr_image, NEW(image_new)},
{ attr_itemgra, NEW(itemgra_new), NULL, NULL, NULL, NULL, ADD(itemgra_add_attr)},
- { attr_log, NEW(log_new)},
{ attr_navigation, NEW(navigation_new), GET(navigation_get_attr)},
{ attr_plugins, NEW(plugins_new), NULL, NULL, NULL, NULL, NULL, NULL, INIT(plugins_init)},
{ attr_plugin, NEW(plugin_new)},
@@ -289,6 +288,8 @@ object_func_lookup(enum attr_type type)
return &layer_func;
case attr_layout:
return &layout_func;
+ case attr_log:
+ return &log_func;
case attr_map:
return &map_func;
case attr_maps:
diff --git a/navit/navit/xmlconfig.h b/navit/navit/xmlconfig.h
index 1a2ee3691..a2b6632ca 100644
--- a/navit/navit/xmlconfig.h
+++ b/navit/navit/xmlconfig.h
@@ -54,9 +54,9 @@ struct object_func {
void *(*unref)(void *);
};
-extern struct object_func map_func, mapset_func, navit_func, osd_func, tracking_func, vehicle_func, maps_func, layout_func, roadprofile_func, vehicleprofile_func, layer_func, config_func, profile_option_func, script_func;
+extern struct object_func map_func, mapset_func, navit_func, osd_func, tracking_func, vehicle_func, maps_func, layout_func, roadprofile_func, vehicleprofile_func, layer_func, config_func, profile_option_func, script_func, log_func;
-#define HAS_OBJECT_FUNC(x) ((x) == attr_map || (x) == attr_mapset || (x) == attr_navit || (x) == attr_osd || (x) == attr_trackingo || (x) == attr_vehicle || (x) == attr_maps || (x) == attr_layout || (x) == attr_roadprofile || (x) == attr_vehicleprofile || (x) == attr_layer || (x) == attr_config || (x) == attr_profile_option || (x) == attr_script)
+#define HAS_OBJECT_FUNC(x) ((x) == attr_map || (x) == attr_mapset || (x) == attr_navit || (x) == attr_osd || (x) == attr_trackingo || (x) == attr_vehicle || (x) == attr_maps || (x) == attr_layout || (x) == attr_roadprofile || (x) == attr_vehicleprofile || (x) == attr_layer || (x) == attr_config || (x) == attr_profile_option || (x) == attr_script || (x) == attr_log)
#define NAVIT_OBJECT struct object_func *func; int refcount; struct attr **attrs;
struct navit_object {