[libshumate] Remove ShumateTileCache



commit b3bfa3bff4b1604aa82dfe118ccd8490cadf2f45
Author: James Westman <james jwestman net>
Date:   Wed Mar 24 00:20:30 2021 -0500

    Remove ShumateTileCache
    
    Now that ShumateFileCache and ShumateMemoryCache have been moved, it no
    longer has any subclasses and can be removed.

 docs/reference/libshumate-docs.sgml    |   1 -
 docs/reference/libshumate-sections.txt |  20 ---
 docs/reference/libshumate.types        |   1 -
 shumate/meson.build                    |   2 -
 shumate/shumate-file-cache.h           |   2 +-
 shumate/shumate-map-source-chain.c     |  46 +------
 shumate/shumate-memory-cache.h         |   2 +-
 shumate/shumate-network-tile-source.c  |  39 ++----
 shumate/shumate-tile-cache.c           | 233 ---------------------------------
 shumate/shumate-tile-cache.h           |  66 ----------
 shumate/shumate-tile-source.c          |  90 +------------
 shumate/shumate-tile-source.h          |   5 -
 shumate/shumate.h                      |   1 -
 13 files changed, 12 insertions(+), 496 deletions(-)
---
diff --git a/docs/reference/libshumate-docs.sgml b/docs/reference/libshumate-docs.sgml
index 492b190..0e3b482 100644
--- a/docs/reference/libshumate-docs.sgml
+++ b/docs/reference/libshumate-docs.sgml
@@ -81,7 +81,6 @@
     </chapter>
     <chapter>
       <title>Tile Caches</title>
-      <xi:include href="xml/shumate-tile-cache.xml"/>
       <xi:include href="xml/shumate-file-cache.xml"/>
       <xi:include href="xml/shumate-memory-cache.xml"/>
     </chapter>
diff --git a/docs/reference/libshumate-sections.txt b/docs/reference/libshumate-sections.txt
index 39b5805..87f682b 100644
--- a/docs/reference/libshumate-sections.txt
+++ b/docs/reference/libshumate-sections.txt
@@ -360,26 +360,6 @@ ShumateScaleClass
 ShumateScalePrivate
 </SECTION>
 
-<SECTION>
-<FILE>shumate-tile-cache</FILE>
-<TITLE>ShumateTileCache</TITLE>
-ShumateTileCache
-shumate_tile_cache_store_tile
-shumate_tile_cache_refresh_tile_time
-shumate_tile_cache_on_tile_filled
-<SUBSECTION Standard>
-SHUMATE_TILE_CACHE
-SHUMATE_IS_TILE_CACHE
-SHUMATE_TYPE_TILE_CACHE
-shumate_tile_cache_get_type
-SHUMATE_TILE_CACHE_CLASS
-SHUMATE_IS_TILE_CACHE_CLASS
-SHUMATE_TILE_CACHE_GET_CLASS
-<SUBSECTION Private>
-ShumateTileCacheClass
-ShumateTileCachePrivate
-</SECTION>
-
 <SECTION>
 <FILE>shumate-map-source-factory</FILE>
 <TITLE>ShumateMapSourceFactory</TITLE>
diff --git a/docs/reference/libshumate.types b/docs/reference/libshumate.types
index d502b49..09ddd6e 100644
--- a/docs/reference/libshumate.types
+++ b/docs/reference/libshumate.types
@@ -16,7 +16,6 @@ shumate_network_tile_source_get_type
 shumate_path_layer_get_type
 shumate_point_get_type
 shumate_scale_get_type
-shumate_tile_cache_get_type
 shumate_tile_get_type
 shumate_tile_source_get_type
 shumate_view_get_type
diff --git a/shumate/meson.build b/shumate/meson.build
index 9a2f60c..9bec3f0 100644
--- a/shumate/meson.build
+++ b/shumate/meson.build
@@ -17,7 +17,6 @@ libshumate_public_h = [
   'shumate-path-layer.h',
   'shumate-point.h',
   'shumate-scale.h',
-  'shumate-tile-cache.h',
   'shumate-tile-source.h',
   'shumate-tile.h',
   'shumate-view.h',
@@ -52,7 +51,6 @@ libshumate_sources = [
   'shumate-path-layer.c',
   'shumate-point.c',
   'shumate-scale.c',
-  'shumate-tile-cache.c',
   'shumate-tile-source.c',
   'shumate-tile.c',
   'shumate-view.c',
diff --git a/shumate/shumate-file-cache.h b/shumate/shumate-file-cache.h
index 7f4624a..cab63b1 100644
--- a/shumate/shumate-file-cache.h
+++ b/shumate/shumate-file-cache.h
@@ -26,7 +26,7 @@
 #define _SHUMATE_FILE_CACHE_H_
 
 #include <glib-object.h>
-#include <shumate/shumate-tile-cache.h>
+#include <shumate/shumate-tile.h>
 
 G_BEGIN_DECLS
 
diff --git a/shumate/shumate-map-source-chain.c b/shumate/shumate-map-source-chain.c
index 6564dd2..2024aec 100644
--- a/shumate/shumate-map-source-chain.c
+++ b/shumate/shumate-map-source-chain.c
@@ -32,7 +32,6 @@
  */
 
 #include "shumate-map-source-chain.h"
-#include "shumate-tile-cache.h"
 #include "shumate-tile-source.h"
 
 typedef struct
@@ -236,28 +235,6 @@ on_set_next_source_cb (ShumateMapSourceChain *source_chain,
 }
 
 
-static void
-assign_cache_of_next_source_sequence (ShumateMapSourceChain *source_chain,
-    ShumateMapSource *start_map_source,
-    ShumateTileCache *tile_cache)
-{
-  ShumateMapSource *map_source = start_map_source;
-  ShumateMapSource *chain_next_source = shumate_map_source_get_next_source (SHUMATE_MAP_SOURCE 
(source_chain));
-
-  do
-    {
-      map_source = shumate_map_source_get_next_source (map_source);
-    }
-  while (SHUMATE_IS_TILE_CACHE (map_source));
-
-  while (SHUMATE_IS_TILE_SOURCE (map_source) && map_source != chain_next_source)
-    {
-      shumate_tile_source_set_cache (SHUMATE_TILE_SOURCE (map_source), tile_cache);
-      map_source = shumate_map_source_get_next_source (map_source);
-    }
-}
-
-
 /**
  * shumate_map_source_chain_push:
  * @source_chain: a #ShumateMapSourceChain
@@ -272,10 +249,7 @@ shumate_map_source_chain_push (ShumateMapSourceChain *source_chain,
   ShumateMapSourceChainPrivate *priv = shumate_map_source_chain_get_instance_private (source_chain);
   gboolean is_cache = FALSE;
 
-  if (SHUMATE_IS_TILE_CACHE (map_source))
-    is_cache = TRUE;
-  else
-    g_return_if_fail (SHUMATE_IS_TILE_SOURCE (map_source));
+  g_return_if_fail (SHUMATE_IS_TILE_SOURCE (map_source));
 
   g_object_ref_sink (map_source);
 
@@ -295,12 +269,6 @@ shumate_map_source_chain_push (ShumateMapSourceChain *source_chain,
     {
       shumate_map_source_set_next_source (map_source, priv->stack_top);
       priv->stack_top = map_source;
-
-      if (is_cache)
-        {
-          ShumateTileCache *tile_cache = SHUMATE_TILE_CACHE (map_source);
-          assign_cache_of_next_source_sequence (source_chain, priv->stack_top, tile_cache);
-        }
     }
 }
 
@@ -320,18 +288,6 @@ shumate_map_source_chain_pop (ShumateMapSourceChain *source_chain)
 
   g_return_if_fail (priv->stack_top);
 
-  if (SHUMATE_IS_TILE_CACHE (priv->stack_top))
-    {
-      ShumateTileCache *tile_cache = NULL;
-
-      if (SHUMATE_IS_TILE_CACHE (next_source))
-        tile_cache = SHUMATE_TILE_CACHE (next_source);
-
-      /* _push() guarantees that the last source is tile_source so we can be
-         sure that the next map source is still within the chain */
-      assign_cache_of_next_source_sequence (source_chain, priv->stack_top, tile_cache);
-    }
-
   if (next_source == shumate_map_source_get_next_source (SHUMATE_MAP_SOURCE (source_chain)))
     {
       priv->stack_top = NULL;
diff --git a/shumate/shumate-memory-cache.h b/shumate/shumate-memory-cache.h
index 8624212..3382023 100644
--- a/shumate/shumate-memory-cache.h
+++ b/shumate/shumate-memory-cache.h
@@ -25,7 +25,7 @@
 #define _SHUMATE_MEMORY_CACHE_H_
 
 #include <glib-object.h>
-#include <shumate/shumate-tile-cache.h>
+#include <shumate/shumate-tile.h>
 
 G_BEGIN_DECLS
 
diff --git a/shumate/shumate-network-tile-source.c b/shumate/shumate-network-tile-source.c
index 9377e8d..4519a6b 100644
--- a/shumate/shumate-network-tile-source.c
+++ b/shumate/shumate-network-tile-source.c
@@ -680,7 +680,6 @@ on_pixbuf_created (GObject      *source_object,
   g_autoptr(GdkPixbuf) pixbuf = NULL;
   g_autoptr(GdkTexture) texture = NULL;
   g_autofree char *etag = g_steal_pointer (&rendered_data->etag);
-  ShumateTileCache *tile_cache = shumate_tile_source_get_cache (SHUMATE_TILE_SOURCE (self));
 
   g_slice_free (TileRenderedData, rendered_data);
   g_signal_handlers_disconnect_by_func (tile, tile_state_notify, cancellable);
@@ -712,13 +711,7 @@ on_pixbuf_created (GObject      *source_object,
     g_warning ("Unable to export tile: %s", error->message);
   else
     {
-      g_autoptr(GBytes) bytes = NULL;
-
-      if (tile_cache)
-        shumate_tile_cache_store_tile (tile_cache, tile, buffer, buffer_size);
-
-      bytes = g_bytes_new_take (buffer, buffer_size);
-      buffer = NULL;
+      g_autoptr(GBytes) bytes = g_bytes_new_take (g_steal_pointer (&buffer), buffer_size);
       shumate_file_cache_store_tile_async (priv->file_cache, tile, bytes, etag, cancellable, NULL, NULL);
     }
 
@@ -760,8 +753,6 @@ on_message_sent (GObject *source_object,
   g_autoptr(GInputStream) input_stream = NULL;
   g_autoptr(GError) error = NULL;
   ShumateNetworkTileSourcePrivate *priv = shumate_network_tile_source_get_instance_private (self);
-  ShumateTileSource *tile_source = SHUMATE_TILE_SOURCE (self);
-  ShumateTileCache *tile_cache = shumate_tile_source_get_cache (tile_source);
   ShumateMapSource *next_source = shumate_map_source_get_next_source (SHUMATE_MAP_SOURCE (self));
   const char *etag;
   TileRenderedData *data;
@@ -787,9 +778,6 @@ on_message_sent (GObject *source_object,
     {
       g_autoptr(GInputStream) cache_stream = NULL;
 
-      if (tile_cache)
-        shumate_tile_cache_refresh_tile_time (tile_cache, tile);
-
       shumate_file_cache_mark_up_to_date (priv->file_cache, tile);
 
       cache_stream = g_memory_input_stream_new_from_bytes (cached_data);
@@ -919,26 +907,15 @@ on_file_cache_get_tile (GObject *source_object, GAsyncResult *res, gpointer user
 
   bytes = shumate_file_cache_get_tile_finish (SHUMATE_FILE_CACHE (source_object), &etag, res, NULL);
 
-  if (bytes)
+  if (bytes && etag == NULL)
     {
-      g_autoptr(GInputStream) input_stream = NULL;
-      ShumateTileCache *tile_cache = shumate_tile_source_get_cache (SHUMATE_TILE_SOURCE (data->self));
+      /* No need to fetch new data from the network (the file cache does not
+       * set the etag when the data is up to date). Just fill the tile directly
+       * from the cache. */
 
-      if (tile_cache)
-        {
-          gsize size;
-          gconstpointer buffer = g_bytes_get_data (bytes, &size);
-          shumate_tile_cache_store_tile (tile_cache, data->tile, buffer, size);
-        }
-
-      if (etag == NULL)
-        {
-          /* No need to fetch new data from the network. Just fill the tile
-           * directly from the cache. */
-          input_stream = g_memory_input_stream_new_from_bytes (bytes);
-          gdk_pixbuf_new_from_stream_async (input_stream, data->cancellable, on_pixbuf_created_from_cache, 
g_object_ref (data->tile));
-          return;
-        }
+      g_autoptr(GInputStream) input_stream = g_memory_input_stream_new_from_bytes (bytes);
+      gdk_pixbuf_new_from_stream_async (input_stream, data->cancellable, on_pixbuf_created_from_cache, 
g_object_ref (data->tile));
+      return;
     }
 
   uri = get_tile_uri (data->self,
diff --git a/shumate/shumate-tile-source.c b/shumate/shumate-tile-source.c
index 63f13d4..bf9750e 100644
--- a/shumate/shumate-tile-source.c
+++ b/shumate/shumate-tile-source.c
@@ -22,8 +22,7 @@
  * SECTION:shumate-tile-source
  * @short_description: A base class of tile sources
  *
- * This class defines properties common to all tile sources (that is, map
- * sources that are not caches).
+ * This class defines properties common to all tile sources.
  */
 
 #include "shumate-tile-source.h"
@@ -40,7 +39,6 @@ enum
   PROP_MAX_ZOOM_LEVEL,
   PROP_TILE_SIZE,
   PROP_MAP_PROJECTION,
-  PROP_CACHE
 };
 
 typedef struct
@@ -53,7 +51,6 @@ typedef struct
   guint max_zoom_level;
   guint tile_size;
   ShumateMapProjection map_projection;
-  ShumateTileCache *cache;
 } ShumateTileSourcePrivate;
 
 G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ShumateTileSource, shumate_tile_source, SHUMATE_TYPE_MAP_SOURCE);
@@ -110,10 +107,6 @@ shumate_tile_source_get_property (GObject *object,
       g_value_set_enum (value, priv->map_projection);
       break;
 
-    case PROP_CACHE:
-      g_value_set_object (value, priv->cache);
-      break;
-
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -169,29 +162,12 @@ shumate_tile_source_set_property (GObject *object,
           g_value_get_enum (value));
       break;
 
-    case PROP_CACHE:
-      shumate_tile_source_set_cache (tile_source,
-          g_value_get_object (value));
-      break;
-
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
 }
 
 
-static void
-shumate_tile_source_dispose (GObject *object)
-{
-  ShumateTileSource *tile_source = SHUMATE_TILE_SOURCE (object);
-  ShumateTileSourcePrivate *priv = shumate_tile_source_get_instance_private (tile_source);
-
-  g_clear_object (&priv->cache);
-
-  G_OBJECT_CLASS (shumate_tile_source_parent_class)->dispose (object);
-}
-
-
 static void
 shumate_tile_source_finalize (GObject *object)
 {
@@ -214,7 +190,6 @@ shumate_tile_source_class_init (ShumateTileSourceClass *klass)
   GParamSpec *pspec;
 
   object_class->finalize = shumate_tile_source_finalize;
-  object_class->dispose = shumate_tile_source_dispose;
   object_class->get_property = shumate_tile_source_get_property;
   object_class->set_property = shumate_tile_source_set_property;
 
@@ -331,18 +306,6 @@ shumate_tile_source_class_init (ShumateTileSourceClass *klass)
         SHUMATE_MAP_PROJECTION_MERCATOR,
         G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
   g_object_class_install_property (object_class, PROP_MAP_PROJECTION, pspec);
-
-  /**
-   * ShumateTileSource:cache:
-   *
-   * The cache used for tile storage
-   */
-  pspec = g_param_spec_object ("cache",
-        "Cache",
-        "Cache used for tile sorage",
-        SHUMATE_TYPE_TILE_CACHE,
-        G_PARAM_READWRITE);
-  g_object_class_install_property (object_class, PROP_CACHE, pspec);
 }
 
 
@@ -351,7 +314,6 @@ shumate_tile_source_init (ShumateTileSource *tile_source)
 {
   ShumateTileSourcePrivate *priv = shumate_tile_source_get_instance_private (tile_source);
 
-  priv->cache = NULL;
   priv->id = NULL;
   priv->name = NULL;
   priv->license = NULL;
@@ -363,56 +325,6 @@ shumate_tile_source_init (ShumateTileSource *tile_source)
 }
 
 
-/**
- * shumate_tile_source_get_cache:
- * @tile_source: a #ShumateTileSource
- *
- * Gets the cache used for storing tiles by this tile source.
- *
- * Returns: (transfer none): the cache
- */
-ShumateTileCache *
-shumate_tile_source_get_cache (ShumateTileSource *tile_source)
-{
-  ShumateTileSourcePrivate *priv = shumate_tile_source_get_instance_private (tile_source);
-
-  g_return_val_if_fail (SHUMATE_IS_TILE_SOURCE (tile_source), NULL);
-
-  return priv->cache;
-}
-
-
-/**
- * shumate_tile_source_set_cache:
- * @tile_source: a #ShumateTileSource
- * @cache: a #ShumateTileCache
- *
- * Sets the map source's cache used for storing tiles.
- */
-void
-shumate_tile_source_set_cache (ShumateTileSource *tile_source,
-    ShumateTileCache *cache)
-{
-  ShumateTileSourcePrivate *priv = shumate_tile_source_get_instance_private (tile_source);
-
-  g_return_if_fail (SHUMATE_IS_TILE_SOURCE (tile_source));
-
-  if (priv->cache != NULL)
-    g_object_unref (priv->cache);
-
-  if (cache)
-    {
-      g_return_if_fail (SHUMATE_IS_TILE_CACHE (cache));
-
-      g_object_ref_sink (cache);
-    }
-
-  priv->cache = cache;
-
-  g_object_notify (G_OBJECT (tile_source), "cache");
-}
-
-
 static const char *
 get_id (ShumateMapSource *map_source)
 {
diff --git a/shumate/shumate-tile-source.h b/shumate/shumate-tile-source.h
index 2c3c7e8..863fbe4 100644
--- a/shumate/shumate-tile-source.h
+++ b/shumate/shumate-tile-source.h
@@ -26,7 +26,6 @@
 #define _SHUMATE_TILE_SOURCE_H_
 
 #include <shumate/shumate-map-source.h>
-#include <shumate/shumate-tile-cache.h>
 
 G_BEGIN_DECLS
 
@@ -45,10 +44,6 @@ struct _ShumateTileSourceClass
   ShumateMapSourceClass parent_class;
 };
 
-ShumateTileCache *shumate_tile_source_get_cache (ShumateTileSource *tile_source);
-void shumate_tile_source_set_cache (ShumateTileSource *tile_source,
-    ShumateTileCache *cache);
-
 void shumate_tile_source_set_id (ShumateTileSource *tile_source,
     const char *id);
 void shumate_tile_source_set_name (ShumateTileSource *tile_source,
diff --git a/shumate/shumate.h b/shumate/shumate.h
index 5867abb..ad49089 100644
--- a/shumate/shumate.h
+++ b/shumate/shumate.h
@@ -42,7 +42,6 @@
 
 #include "shumate/shumate-map-source.h"
 #include "shumate/shumate-tile-source.h"
-#include "shumate/shumate-tile-cache.h"
 
 #include "shumate/shumate-map-source-factory.h"
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]