2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
4 * Copyright (C) 2012-2013, Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * SECTION:vikroutingengine
23 * @short_description: the base class to describe routing engine
25 * The #VikRoutingEngine class is both the interface and the base class
26 * for the hierarchie of routing engines.
34 #include <glib/gstdio.h>
35 #include <glib/gi18n.h>
39 #include "vikroutingengine.h"
41 static void vik_routing_engine_finalize ( GObject *gob );
42 static GObjectClass *parent_class;
44 typedef struct _VikRoutingPrivate VikRoutingPrivate;
45 struct _VikRoutingPrivate
52 #define VIK_ROUTING_ENGINE_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VIK_ROUTING_ENGINE_TYPE, VikRoutingPrivate))
64 G_DEFINE_ABSTRACT_TYPE (VikRoutingEngine, vik_routing_engine, G_TYPE_OBJECT)
67 vik_routing_engine_set_property (GObject *object,
72 VikRoutingPrivate *priv = VIK_ROUTING_ENGINE_PRIVATE ( object );
78 priv->id = g_strdup(g_value_get_string (value));
83 priv->label = g_strdup(g_value_get_string (value));
87 g_free (priv->format);
88 priv->format = g_strdup(g_value_get_string (value));
92 /* We don't have any other property... */
93 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
99 vik_routing_engine_get_property (GObject *object,
104 VikRoutingPrivate *priv = VIK_ROUTING_ENGINE_PRIVATE ( object );
109 g_value_set_string (value, priv->id);
113 g_value_set_string (value, priv->label);
117 g_value_set_string (value, priv->format);
121 /* We don't have any other property... */
122 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
128 vik_routing_engine_class_init ( VikRoutingEngineClass *klass )
130 GObjectClass *object_class;
131 VikRoutingEngineClass *routing_class;
132 GParamSpec *pspec = NULL;
134 object_class = G_OBJECT_CLASS (klass);
136 object_class->set_property = vik_routing_engine_set_property;
137 object_class->get_property = vik_routing_engine_get_property;
138 object_class->finalize = vik_routing_engine_finalize;
140 parent_class = g_type_class_peek_parent (klass);
142 routing_class = VIK_ROUTING_ENGINE_CLASS ( klass );
143 routing_class->find = NULL;
146 pspec = g_param_spec_string ("id",
148 "The identifier of the routing engine",
149 "<no-set>" /* default value */,
150 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
151 g_object_class_install_property (object_class, PROP_ID, pspec);
153 pspec = g_param_spec_string ("label",
155 "The label of the routing engine",
156 "<no-set>" /* default value */,
157 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
158 g_object_class_install_property (object_class, PROP_LABEL, pspec);
160 pspec = g_param_spec_string ("format",
162 "The format of the output (see gpsbabel)",
163 "<no-set>" /* default value */,
164 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
165 g_object_class_install_property (object_class, PROP_FORMAT, pspec);
167 g_type_class_add_private (klass, sizeof (VikRoutingPrivate));
171 vik_routing_engine_init ( VikRoutingEngine *self )
173 VikRoutingPrivate *priv = VIK_ROUTING_ENGINE_PRIVATE (self);
181 vik_routing_engine_finalize ( GObject *self )
183 VikRoutingPrivate *priv = VIK_ROUTING_ENGINE_PRIVATE (self);
188 g_free (priv->label);
191 g_free (priv->format);
194 G_OBJECT_CLASS(parent_class)->finalize(self);
198 * vik_routing_engine_find:
201 * @start: starting point
204 * Retrieve a route between two coordinates.
206 * Returns: indicates success or not.
209 vik_routing_engine_find ( VikRoutingEngine *self, VikTrwLayer *vtl, struct LatLon start, struct LatLon end )
211 VikRoutingEngineClass *klass;
213 g_return_val_if_fail ( VIK_IS_ROUTING_ENGINE (self), 0 );
214 klass = VIK_ROUTING_ENGINE_GET_CLASS( self );
215 g_return_val_if_fail ( klass->find != NULL, 0 );
217 return klass->find( self, vtl, start, end );
221 * vik_routing_engine_get_id:
223 * Returns: the id of self
226 vik_routing_engine_get_id ( VikRoutingEngine *self )
228 VikRoutingPrivate *priv = VIK_ROUTING_ENGINE_PRIVATE (self);
234 * vik_routing_engine_get_label:
236 * Returns: the label of self
239 vik_routing_engine_get_label ( VikRoutingEngine *self )
241 VikRoutingPrivate *priv = VIK_ROUTING_ENGINE_PRIVATE (self);
247 * vik_routing_engine_get_format:
249 * Returns: the format of self
252 vik_routing_engine_get_format ( VikRoutingEngine *self )
254 VikRoutingPrivate *priv = VIK_ROUTING_ENGINE_PRIVATE (self);