[libchamplainmm] MapSource: Cleanup



commit 3567d0ba82513c4809d2c14fc547892c6df4ac09
Author: Juan R. García Blanco <juanrgar gmail com>
Date:   Sat Mar 8 12:03:03 2014 +0100

    MapSource: Cleanup
    
        * Remove no longer existing properties.
        * Add vfuncs.
        * Reorder methods.

 champlain/src/champlain_vfuncs.defs |   50 +++++++++++++
 champlain/src/map-source.ccg        |   23 ++++++
 champlain/src/map-source.hg         |  138 ++++++++++++++++++++++------------
 3 files changed, 162 insertions(+), 49 deletions(-)
---
diff --git a/champlain/src/champlain_vfuncs.defs b/champlain/src/champlain_vfuncs.defs
index 7cf5a52..f5b2b87 100644
--- a/champlain/src/champlain_vfuncs.defs
+++ b/champlain/src/champlain_vfuncs.defs
@@ -38,6 +38,56 @@
   (return-type "ChamplainBoundingBox*")
 )
 
+; ChamplainMapSource
+
+(define-vfunc get_id
+  (of-object "ChamplainMapSource")
+  (return-type "const-gchar*")
+)
+
+(define-vfunc get_name
+  (of-object "ChamplainMapSource")
+  (return-type "const-gchar*")
+)
+
+(define-vfunc get_license
+  (of-object "ChamplainMapSource")
+  (return-type "const-gchar*")
+)
+
+(define-vfunc get_license_uri
+  (of-object "ChamplainMapSource")
+  (return-type "const-gchar*")
+)
+
+(define-vfunc get_min_zoom_level
+  (of-object "ChamplainMapSource")
+  (return-type "guint")
+)
+
+(define-vfunc get_max_zoom_level
+  (of-object "ChamplainMapSource")
+  (return-type "guint")
+)
+
+(define-vfunc get_tile_size
+  (of-object "ChamplainMapSource")
+  (return-type "guint")
+)
+
+(define-vfunc get_projection
+  (of-object "ChamplainMapSource")
+  (return-type "ChamplainMapProjection")
+)
+
+(define-vfunc fill_tile
+  (of-object "ChamplainMapSource")
+  (return-type "void")
+  (parameters
+    '("ChamplainTile*" "tile")
+  )
+)
+
 ; ChamplainRenderer
 
 (define-vfunc render
diff --git a/champlain/src/map-source.ccg b/champlain/src/map-source.ccg
index e69de29..98e7f82 100644
--- a/champlain/src/map-source.ccg
+++ b/champlain/src/map-source.ccg
@@ -0,0 +1,23 @@
+/* Copyright (c) 2014  Juan R. García Blanco <juanrgar gmail com>
+ *
+ * This file is part of libchamplainmm.
+ *
+ * libchamplainmm 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.
+ *
+ * libchamplainmm 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 program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <champlain/champlain.h>
+
+namespace Champlain
+{
+} // namespace Champlain
diff --git a/champlain/src/map-source.hg b/champlain/src/map-source.hg
index 0d4e121..39a4da3 100644
--- a/champlain/src/map-source.hg
+++ b/champlain/src/map-source.hg
@@ -16,70 +16,110 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <string>
-#include <glibmm.h>
+#include <glibmm/object.h>
+#include <champlainmm/tile.h>
+#include <champlainmm/renderer.h>
+// For ChamplainMapProjection
+#include <champlain/champlain.h>
 
 _DEFS(champlainmm,champlain)
-
-_CC_INCLUDE(champlain/champlain.h)
-_CC_INCLUDE(champlainmm/tile.h)
 _PINCLUDE(glibmm/private/object_p.h)
-_PINCLUDE(champlain/champlain.h)
 
 namespace Champlain
 {
 
 _WRAP_ENUM(MapProjection, ChamplainMapProjection)
 
-class Tile;
-
-class MapSource :
-    public Glib::Object
+class MapSource : public Glib::Object
 {
-  _CLASS_GOBJECT(MapSource, ChamplainMapSource, CHAMPLAIN_MAP_SOURCE,
-                 Glib::Object, GObject)
+
+/** A base class for map sources.
+ *
+ * Tile objects come from map sources which are represented by
+ * MapSource. This should be considered an abstract
+ * type as it does nothing of interest.
+ *
+ * When loading new tiles, View calls fill_tile()
+ * on the current MapSource passing it a Tile to be filled
+ * with the image.
+ *
+ * Apart from being a base class of all map sources, MapSource
+ * also supports cooperation of multiple map sources by arranging them into
+ * chains. Every map source has the MapSource::next-source property
+ * that determines the next map source in the chain. When a function of
+ * a MapSource object is invoked, the map source may decide to
+ * delegate the work to the next map source in the chain by invoking the
+ * same function on it.
+
+ * To understand the concept of chains, consider for instance a chain
+ * consisting of FileCache whose next source is
+ * NetworkTileSource whose next source is an error tile source
+ * created with MapSourceFactory::create_error_source().
+ * When fill_tile() is called on the first object of the
+ * chain, FileCache, the cache checks whether it contains the
+ * requested tile in its database. If it does, it returns the tile; otherwise,
+ * it calls fill_tile() on the next source in the chain
+ * (NetworkTileSource). The network tile source loads the tile
+ * from the network. When successful, it returns the tile; otherwise it requests
+ * the tile from the next source in the chain (error tile source).
+ * The error tile source always generates an error tile, no matter what
+ * its next source is.
+ *
+ * @newin{0,4}
+ */
+  _CLASS_GOBJECT(MapSource, ChamplainMapSource, CHAMPLAIN_MAP_SOURCE, Glib::Object, GObject)
+  _DERIVES_INITIALLY_UNOWNED()
 
 protected:
-  _CTOR_DEFAULT()
+  _WRAP_VFUNC(std::string get_id() const, get_id)
+//  _WRAP_VFUNC(Glib::ustring get_name() const, get_name)
+//  _WRAP_VFUNC(Glib::ustring get_license() const, get_license)
+//  _WRAP_VFUNC(Glib::ustring get_license_uri() const, get_license_uri)
+
+  _WRAP_VFUNC(guint get_min_zoom_level() const, get_min_zoom_level)
+  _WRAP_VFUNC(guint get_max_zoom_level() const, get_max_zoom_level)
+
+  _WRAP_VFUNC(guint get_tile_size() const, get_tile_size)
 
-  _WRAP_VFUNC(void fill_tile(const Glib::RefPtr<Tile> & tile), fill_tile)
+  _WRAP_VFUNC(MapProjection get_projection() const, get_projection)
+
+  _WRAP_VFUNC(void fill_tile(const Glib::RefPtr<Tile>& tile), fill_tile)
 
 public:
-  _WRAP_METHOD(void fill_tile(const Glib::RefPtr<Tile> & tile),
-               champlain_map_source_fill_tile)
-  _WRAP_METHOD(guint get_column_count(guint zoom_level),
-               champlain_map_source_get_column_count)
-  _WRAP_METHOD(std::string get_id(), champlain_map_source_get_id)
-  _WRAP_METHOD(double get_latitude(guint zoom_level, double y),
-               champlain_map_source_get_latitude)
-  _WRAP_METHOD(Glib::ustring get_license(), champlain_map_source_get_license)
-  _WRAP_METHOD(Glib::ustring get_license_uri(),
-               champlain_map_source_get_license_uri)
-  _WRAP_METHOD(double get_longitude(guint zoom_level, double x),
-               champlain_map_source_get_longitude)
-  _WRAP_METHOD(guint get_max_zoom_level(),
-               champlain_map_source_get_max_zoom_level)
-  _WRAP_METHOD(guint get_min_zoom_level(),
-               champlain_map_source_get_min_zoom_level)
-  _WRAP_METHOD(guint get_row_count(guint zoom_level),
-               champlain_map_source_get_row_count)
-  _WRAP_METHOD(Glib::ustring get_name(), champlain_map_source_get_name)
-  _WRAP_METHOD(MapProjection get_projection(),
-               champlain_map_source_get_projection)
-  _WRAP_METHOD(guint get_tile_size(), champlain_map_source_get_tile_size)
-  _WRAP_METHOD(double get_x(guint zoom_level, double longitude),
-               champlain_map_source_get_x)
-  _WRAP_METHOD(double get_y(guint zoom_level, double latitude),
-               champlain_map_source_get_y)
-
-  _WRAP_PROPERTY("id", std::string)
-  _WRAP_PROPERTY("name", Glib::ustring)
-  _WRAP_PROPERTY("license", Glib::ustring)
-  _WRAP_PROPERTY("license-uri", Glib::ustring)
-  _WRAP_PROPERTY("max-zoom-level", guint)
-  _WRAP_PROPERTY("min-zoom-level", guint)
-  _WRAP_PROPERTY("tile-size", guint)
-  _WRAP_PROPERTY("projection", MapProjection)
+  _WRAP_METHOD(Glib::RefPtr<MapSource> get_next_source(), champlain_map_source_get_next_source)
+  _WRAP_METHOD(Glib::RefPtr<const MapSource> get_next_source() const, champlain_map_source_get_next_source, 
constversion)
+  _WRAP_METHOD(void set_next_source(const Glib::RefPtr<MapSource>& next_source), 
champlain_map_source_set_next_source)
+
+  _WRAP_METHOD(Glib::RefPtr<Renderer> get_renderer(), champlain_map_source_get_renderer)
+  _WRAP_METHOD(Glib::RefPtr<const Renderer> get_renderer() const, champlain_map_source_get_renderer, 
constversion)
+  _WRAP_METHOD(void set_renderer(const Glib::RefPtr<Renderer>& renderer), champlain_map_source_set_renderer)
+
+  _WRAP_METHOD(std::string get_id() const, champlain_map_source_get_id)
+  _WRAP_METHOD(Glib::ustring get_name() const, champlain_map_source_get_name)
+  _WRAP_METHOD(Glib::ustring get_license() const, champlain_map_source_get_license)
+  _WRAP_METHOD(Glib::ustring get_license_uri() const, champlain_map_source_get_license_uri)
+
+  _WRAP_METHOD(guint get_min_zoom_level() const, champlain_map_source_get_min_zoom_level)
+  _WRAP_METHOD(guint get_max_zoom_level() const, champlain_map_source_get_max_zoom_level)
+
+  _WRAP_METHOD(guint get_tile_size() const, champlain_map_source_get_tile_size)
+
+  _WRAP_METHOD(MapProjection get_projection() const, champlain_map_source_get_projection)
+
+  _WRAP_METHOD(double get_x(guint zoom_level, double longitude) const, champlain_map_source_get_x)
+  _WRAP_METHOD(double get_y(guint zoom_level, double latitude) const, champlain_map_source_get_y)
+  _WRAP_METHOD(double get_longitude(guint zoom_level, double x) const, champlain_map_source_get_longitude)
+  _WRAP_METHOD(double get_latitude(guint zoom_level, double y) const, champlain_map_source_get_latitude)
+
+  _WRAP_METHOD(guint get_row_count(guint zoom_level) const, champlain_map_source_get_row_count)
+  _WRAP_METHOD(guint get_column_count(guint zoom_level) const, champlain_map_source_get_column_count)
+
+  _WRAP_METHOD(double get_meters_per_pixel(guint zoom_level, double latitude, double longitude) const, 
champlain_map_source_get_meters_per_pixel)
+
+  _WRAP_METHOD(void fill_tile(const Glib::RefPtr<Tile>& tile), champlain_map_source_fill_tile)
+
+  _WRAP_PROPERTY("next-source", Glib::RefPtr<MapSource>)
+  _WRAP_PROPERTY("renderer", Glib::RefPtr<Renderer>)
 };
 
 } // namespace Champlain


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