Verified Commit acc4b2c9 authored by James Westman's avatar James Westman
Browse files

Remove ShumateMapSourceChain

There is only one map source left, so there is no need for map source chains.
parent 86925e40
......@@ -85,7 +85,6 @@
</chapter>
<chapter>
<title>Map Source Utilities</title>
<xi:include href="xml/shumate-map-source-chain.xml"/>
<xi:include href="xml/shumate-map-source-factory.xml"/>
<xi:include href="xml/shumate-map-source-desc.xml"/>
</chapter>
......
......@@ -378,26 +378,6 @@ ShumateMapSourceFactoryClass
ShumateMapSourceFactoryPrivate
</SECTION>
<SECTION>
<FILE>shumate-map-source-chain</FILE>
<TITLE>ShumateMapSourceChain</TITLE>
ShumateMapSourceChain
shumate_map_source_chain_new
shumate_map_source_chain_push
shumate_map_source_chain_pop
<SUBSECTION Standard>
SHUMATE_MAP_SOURCE_CHAIN
SHUMATE_IS_MAP_SOURCE_CHAIN
SHUMATE_TYPE_MAP_SOURCE_CHAIN
shumate_map_source_chain_get_type
SHUMATE_MAP_SOURCE_CHAIN_CLASS
SHUMATE_IS_MAP_SOURCE_CHAIN_CLASS
SHUMATE_MAP_SOURCE_CHAIN_GET_CLASS
<SUBSECTION Private>
ShumateMapSourceChainClass
ShumateMapSourceChainPrivate
</SECTION>
<SECTION>
<FILE>shumate-license</FILE>
<TITLE>ShumateLicense</TITLE>
......
......@@ -4,7 +4,6 @@ shumate_layer_get_type
shumate_license_get_type
shumate_location_get_type
shumate_map_layer_get_type
shumate_map_source_chain_get_type
shumate_map_source_desc_get_type
shumate_map_source_factory_get_type
shumate_map_source_get_type
......
......@@ -5,7 +5,6 @@ libshumate_public_h = [
'shumate-license.h',
'shumate-location.h',
'shumate-map-layer.h',
'shumate-map-source-chain.h',
'shumate-map-source-desc.h',
'shumate-map-source-factory.h',
'shumate-map-source.h',
......@@ -38,7 +37,6 @@ libshumate_sources = [
'shumate-license.c',
'shumate-location.c',
'shumate-map-layer.c',
'shumate-map-source-chain.c',
'shumate-map-source-desc.c',
'shumate-map-source-factory.c',
'shumate-map-source.c',
......
/*
* Copyright (C) 2010-2013 Jiri Techet <techet@gmail.com>
* Copyright (C) 2019 Marcus Lundblad <ml@update.uu.se>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* SECTION:shumate-map-source-chain
* @short_description: A map source simplifying creation of source chains
*
* This map source simplifies creation of map chains by providing two
* functions for their creation and modification in a stack-like manner:
* shumate_map_source_chain_push() and shumate_map_source_chain_pop().
* For instance, to create a chain consisting of #ShumateMemoryCache,
* #ShumateFileCache and #ShumateNetworkTileSource, the map
* sources have to be pushed into the chain in the reverse order starting
* from #ShumateNetworkTileSource. After its creation, #ShumateMapSourceChain
* behaves as a chain of map sources it contains.
*/
#include "shumate-map-source-chain.h"
#include "shumate-tile-source.h"
typedef struct
{
ShumateMapSource *stack_top;
ShumateMapSource *stack_bottom;
} ShumateMapSourceChainPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (ShumateMapSourceChain, shumate_map_source_chain, SHUMATE_TYPE_MAP_SOURCE);
static const char *get_id (ShumateMapSource *map_source);
static const char *get_name (ShumateMapSource *map_source);
static const char *get_license (ShumateMapSource *map_source);
static const char *get_license_uri (ShumateMapSource *map_source);
static guint get_min_zoom_level (ShumateMapSource *map_source);
static guint get_max_zoom_level (ShumateMapSource *map_source);
static guint get_tile_size (ShumateMapSource *map_source);
static void fill_tile_async (ShumateMapSource *map_source,
ShumateTile *tile,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
static void on_set_next_source_cb (ShumateMapSourceChain *source_chain,
G_GNUC_UNUSED gpointer user_data);
static void
shumate_map_source_chain_dispose (GObject *object)
{
ShumateMapSourceChain *source_chain = SHUMATE_MAP_SOURCE_CHAIN (object);
ShumateMapSourceChainPrivate *priv = shumate_map_source_chain_get_instance_private (source_chain);
while (priv->stack_top)
shumate_map_source_chain_pop (source_chain);
G_OBJECT_CLASS (shumate_map_source_chain_parent_class)->dispose (object);
}
static void
shumate_map_source_chain_class_init (ShumateMapSourceChainClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
ShumateMapSourceClass *map_source_class = SHUMATE_MAP_SOURCE_CLASS (klass);
object_class->dispose = shumate_map_source_chain_dispose;
map_source_class->get_id = get_id;
map_source_class->get_name = get_name;
map_source_class->get_license = get_license;
map_source_class->get_license_uri = get_license_uri;
map_source_class->get_min_zoom_level = get_min_zoom_level;
map_source_class->get_max_zoom_level = get_max_zoom_level;
map_source_class->get_tile_size = get_tile_size;
map_source_class->fill_tile_async = fill_tile_async;
}
static void
shumate_map_source_chain_init (ShumateMapSourceChain *source_chain)
{
g_signal_connect (source_chain, "notify::next-source",
G_CALLBACK (on_set_next_source_cb), NULL);
}
/**
* shumate_map_source_chain_new:
*
* Constructor of #ShumateMapSourceChain.
*
* Returns: a new empty #ShumateMapSourceChain.
*/
ShumateMapSourceChain *
shumate_map_source_chain_new (void)
{
return g_object_new (SHUMATE_TYPE_MAP_SOURCE_CHAIN, NULL);
}
static const char *
get_id (ShumateMapSource *map_source)
{
ShumateMapSourceChain *source_chain = SHUMATE_MAP_SOURCE_CHAIN (map_source);
ShumateMapSourceChainPrivate *priv = shumate_map_source_chain_get_instance_private (source_chain);
g_return_val_if_fail (SHUMATE_IS_MAP_SOURCE_CHAIN (map_source), NULL);
g_return_val_if_fail (priv->stack_top, NULL);
return shumate_map_source_get_id (priv->stack_top);
}
static const char *
get_name (ShumateMapSource *map_source)
{
ShumateMapSourceChain *source_chain = SHUMATE_MAP_SOURCE_CHAIN (map_source);
ShumateMapSourceChainPrivate *priv = shumate_map_source_chain_get_instance_private (source_chain);
g_return_val_if_fail (SHUMATE_IS_MAP_SOURCE_CHAIN (map_source), NULL);
g_return_val_if_fail (priv->stack_top, NULL);
return shumate_map_source_get_name (priv->stack_top);
}
static const char *
get_license (ShumateMapSource *map_source)
{
ShumateMapSourceChain *source_chain = SHUMATE_MAP_SOURCE_CHAIN (map_source);
ShumateMapSourceChainPrivate *priv = shumate_map_source_chain_get_instance_private (source_chain);
g_return_val_if_fail (SHUMATE_IS_MAP_SOURCE_CHAIN (map_source), NULL);
g_return_val_if_fail (priv->stack_top, NULL);
return shumate_map_source_get_license (priv->stack_top);
}
static const char *
get_license_uri (ShumateMapSource *map_source)
{
ShumateMapSourceChain *source_chain = SHUMATE_MAP_SOURCE_CHAIN (map_source);
ShumateMapSourceChainPrivate *priv = shumate_map_source_chain_get_instance_private (source_chain);
g_return_val_if_fail (SHUMATE_IS_MAP_SOURCE_CHAIN (map_source), NULL);
g_return_val_if_fail (priv->stack_top, NULL);
return shumate_map_source_get_license_uri (priv->stack_top);
}
static guint
get_min_zoom_level (ShumateMapSource *map_source)
{
ShumateMapSourceChain *source_chain = SHUMATE_MAP_SOURCE_CHAIN (map_source);
ShumateMapSourceChainPrivate *priv = shumate_map_source_chain_get_instance_private (source_chain);
g_return_val_if_fail (SHUMATE_IS_MAP_SOURCE_CHAIN (map_source), 0);
g_return_val_if_fail (priv->stack_top, 0);
return shumate_map_source_get_min_zoom_level (priv->stack_top);
}
static guint
get_max_zoom_level (ShumateMapSource *map_source)
{
ShumateMapSourceChain *source_chain = SHUMATE_MAP_SOURCE_CHAIN (map_source);
ShumateMapSourceChainPrivate *priv = shumate_map_source_chain_get_instance_private (source_chain);
g_return_val_if_fail (SHUMATE_IS_MAP_SOURCE_CHAIN (map_source), 0);
g_return_val_if_fail (priv->stack_top, 0);
return shumate_map_source_get_max_zoom_level (priv->stack_top);
}
static guint
get_tile_size (ShumateMapSource *map_source)
{
ShumateMapSourceChain *source_chain = SHUMATE_MAP_SOURCE_CHAIN (map_source);
ShumateMapSourceChainPrivate *priv = shumate_map_source_chain_get_instance_private (source_chain);
g_return_val_if_fail (SHUMATE_IS_MAP_SOURCE_CHAIN (map_source), 0);
g_return_val_if_fail (priv->stack_top, 0);
return shumate_map_source_get_tile_size (priv->stack_top);
}
static void
fill_tile_async (ShumateMapSource *map_source,
ShumateTile *tile,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
ShumateMapSourceChain *source_chain = SHUMATE_MAP_SOURCE_CHAIN (map_source);
ShumateMapSourceChainPrivate *priv = shumate_map_source_chain_get_instance_private (source_chain);
g_return_if_fail (SHUMATE_IS_MAP_SOURCE_CHAIN (map_source));
g_return_if_fail (priv->stack_top);
shumate_map_source_fill_tile_async (priv->stack_top, tile, cancellable, callback, user_data);
}
static void
on_set_next_source_cb (ShumateMapSourceChain *source_chain,
G_GNUC_UNUSED gpointer user_data)
{
ShumateMapSourceChainPrivate *priv = shumate_map_source_chain_get_instance_private (source_chain);
g_return_if_fail (source_chain);
ShumateMapSource *map_source = SHUMATE_MAP_SOURCE (source_chain);
ShumateMapSource *next_source;
next_source = shumate_map_source_get_next_source (map_source);
if (priv->stack_bottom)
shumate_map_source_set_next_source (priv->stack_bottom, next_source);
}
/**
* shumate_map_source_chain_push:
* @source_chain: a #ShumateMapSourceChain
* @map_source: the #ShumateMapSource to be pushed into the chain
*
* Pushes a map source into the chain.
*/
void
shumate_map_source_chain_push (ShumateMapSourceChain *source_chain,
ShumateMapSource *map_source)
{
ShumateMapSourceChainPrivate *priv = shumate_map_source_chain_get_instance_private (source_chain);
gboolean is_cache = FALSE;
g_return_if_fail (SHUMATE_IS_TILE_SOURCE (map_source));
g_object_ref_sink (map_source);
if (!priv->stack_top)
{
ShumateMapSource *chain_next_source = shumate_map_source_get_next_source (SHUMATE_MAP_SOURCE (source_chain));
/* tile source has to be last */
g_return_if_fail (!is_cache);
priv->stack_top = map_source;
priv->stack_bottom = map_source;
if (chain_next_source)
shumate_map_source_set_next_source (priv->stack_bottom, chain_next_source);
}
else
{
shumate_map_source_set_next_source (map_source, priv->stack_top);
priv->stack_top = map_source;
}
}
/**
* shumate_map_source_chain_pop:
* @source_chain: a #ShumateMapSourceChain
*
* Pops a map source from the top of the stack from the chain.
*/
void
shumate_map_source_chain_pop (ShumateMapSourceChain *source_chain)
{
ShumateMapSourceChainPrivate *priv = shumate_map_source_chain_get_instance_private (source_chain);
ShumateMapSource *old_stack_top = priv->stack_top;
ShumateMapSource *next_source = shumate_map_source_get_next_source (priv->stack_top);
g_return_if_fail (priv->stack_top);
if (next_source == shumate_map_source_get_next_source (SHUMATE_MAP_SOURCE (source_chain)))
{
priv->stack_top = NULL;
priv->stack_bottom = NULL;
}
else
priv->stack_top = next_source;
g_object_unref (old_stack_top);
}
/*
* Copyright (C) 2010-2013 Jiri Techet <techet@gmail.com>
* Copyright (C) 2019 Marcus Lundblad <ml@update.uu.se>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if !defined (__SHUMATE_SHUMATE_H_INSIDE__) && !defined (SHUMATE_COMPILATION)
#error "Only <shumate/shumate.h> can be included directly."
#endif
#ifndef _SHUMATE_MAP_SOURCE_CHAIN_H_
#define _SHUMATE_MAP_SOURCE_CHAIN_H_
#include <glib-object.h>
#include "shumate-map-source.h"
G_BEGIN_DECLS
#define SHUMATE_TYPE_MAP_SOURCE_CHAIN shumate_map_source_chain_get_type ()
G_DECLARE_DERIVABLE_TYPE (ShumateMapSourceChain, shumate_map_source_chain, SHUMATE, MAP_SOURCE_CHAIN, ShumateMapSource)
/**
* ShumateMapSourceChain:
*
* The #ShumateMapSourceChain structure contains only private data
* and should be accessed using the provided API
*/
struct _ShumateMapSourceChainClass
{
ShumateMapSourceClass parent_class;
};
ShumateMapSourceChain *shumate_map_source_chain_new (void);
void shumate_map_source_chain_push (ShumateMapSourceChain *source_chain,
ShumateMapSource *map_source);
void shumate_map_source_chain_pop (ShumateMapSourceChain *source_chain);
G_END_DECLS
#endif /* _SHUMATE_MAP_SOURCE_CHAIN_H_ */
......@@ -44,7 +44,6 @@
#include "shumate-enum-types.h"
#include "shumate-map-source.h"
#include "shumate-marshal.h"
#include "shumate-map-source-chain.h"
#include <glib.h>
#include <string.h>
......
......@@ -45,8 +45,6 @@
#include "shumate/shumate-map-source-factory.h"
#include "shumate/shumate-map-source-chain.h"
#include "shumate/shumate-network-tile-source.h"
#include "shumate/shumate-memory-cache.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment