summaryrefslogtreecommitdiff
path: root/navit/vehicle.c
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2012-02-01 13:32:50 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2012-02-01 13:32:50 +0000
commit92bcfaabdeee3596aeb6fe43e6c7022367da6a53 (patch)
tree69c9033c4072681fe6f246dab34a496bbf5362cf /navit/vehicle.c
parent396ea5f57eec21238f0660e24a9f22263d6a893b (diff)
downloadnavit-92bcfaabdeee3596aeb6fe43e6c7022367da6a53.tar.gz
Add:Core:Moved object functions of vehicle to vehicle.c, added reference counting
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@4922 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/vehicle.c')
-rw-r--r--navit/vehicle.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/navit/vehicle.c b/navit/vehicle.c
index 974683519..e15f7610f 100644
--- a/navit/vehicle.c
+++ b/navit/vehicle.c
@@ -39,8 +39,11 @@
#include "color.h"
#include "layout.h"
#include "vehicle.h"
+#include "xmlconfig.h"
struct vehicle {
+ struct object_func *func;
+ int refcount;
struct vehicle_methods meth;
struct vehicle_priv *priv;
struct callback_list *cbl;
@@ -63,6 +66,8 @@ struct vehicle {
GHashTable *log_to_cb;
};
+struct object_func vehicle_func;
+
static void vehicle_draw_do(struct vehicle *this_, int lazy);
static void vehicle_log_nmea(struct vehicle *this_, struct log *log);
static void vehicle_log_gpx(struct vehicle *this_, struct log *log);
@@ -109,6 +114,8 @@ vehicle_new(struct attr *parent, struct attr **attrs)
}
g_free(type);
this_ = g_new0(struct vehicle, 1);
+ this_->func=&vehicle_func;
+ this_->refcount = 1;
this_->cbl = callback_list_new();
this_->priv = vehicletype_new(&this_->meth, this_->cbl, attrs);
if (!this_->priv) {
@@ -153,6 +160,23 @@ vehicle_destroy(struct vehicle *this_)
g_free(this_);
}
+struct vehicle *
+vehicle_ref(struct vehicle *this_)
+{
+ this_->refcount++;
+ dbg(0,"refcount %d\n",this_->refcount);
+ return this_;
+}
+
+void
+vehicle_unref(struct vehicle *this_)
+{
+ this_->refcount--;
+ dbg(0,"refcount %d\n",this_->refcount);
+ if (this_->refcount <= 0)
+ vehicle_destroy(this_);
+}
+
/**
* Creates an attribute iterator to be used with vehicles
*/
@@ -680,3 +704,18 @@ vehicle_add_log(struct vehicle *this_, struct log *log)
return 0;
}
+struct object_func vehicle_func = {
+ attr_vehicle,
+ (object_func_new)vehicle_new,
+ (object_func_get_attr)vehicle_get_attr,
+ (object_func_iter_new)vehicle_attr_iter_new,
+ (object_func_iter_destroy)vehicle_attr_iter_destroy,
+ (object_func_set_attr)vehicle_set_attr,
+ (object_func_add_attr)vehicle_add_attr,
+ (object_func_remove_attr)vehicle_remove_attr,
+ (object_func_init)NULL,
+ (object_func_destroy)vehicle_destroy,
+ (object_func_dup)NULL,
+ (object_func_ref)vehicle_ref,
+ (object_func_unref)vehicle_unref,
+};