[libchamplainmm] Wrap ChamplainMemoryCache



commit 159cdef82b050b9dc3fb0a080be544cc12c45f27
Author: Juan R. García Blanco <juanrgar gmail com>
Date:   Fri Aug 1 22:53:05 2014 +0200

    Wrap ChamplainMemoryCache
    
        * champlain/champlainmm.h: Add memory-cache.h.
        * champlain/champlainmm/.gitignore: Ignore memory-cache.*.
        * champlain/src/champlain_signals.defs: Add ChamplainMemoryCache
        "size-limit" property.
        * champlain/src/filelist.am: Add memory-cache.hg.
        * champlain/src/memory-cache.[ccg|hg]: New files.
        * tools/extradefs/generate_extra_defs_libchamplain.cc: Add
        CHAMPLAIN_TYPE_MEMORY_CACHE.

 champlain/champlainmm.h                            |    1 +
 champlain/champlainmm/.gitignore                   |    1 +
 champlain/src/champlain_signals.defs               |   11 ++++
 champlain/src/filelist.am                          |    1 +
 champlain/src/memory-cache.ccg                     |   23 ++++++++
 champlain/src/memory-cache.hg                      |   55 ++++++++++++++++++++
 .../extradefs/generate_extra_defs_libchamplain.cc  |    1 +
 7 files changed, 93 insertions(+), 0 deletions(-)
---
diff --git a/champlain/champlainmm.h b/champlain/champlainmm.h
index 8ab52b2..b0f2d8a 100644
--- a/champlain/champlainmm.h
+++ b/champlain/champlainmm.h
@@ -35,6 +35,7 @@
 #include <champlainmm/map-source-factory.h>
 #include <champlainmm/map-source.h>
 #include <champlainmm/marker.h>
+#include <champlainmm/memory-cache.h>
 #include <champlainmm/network-map-source.h>
 #include <champlainmm/point.h>
 #include <champlainmm/polygon.h>
diff --git a/champlain/champlainmm/.gitignore b/champlain/champlainmm/.gitignore
index 0b761d8..935bc71 100644
--- a/champlain/champlainmm/.gitignore
+++ b/champlain/champlainmm/.gitignore
@@ -12,6 +12,7 @@ map-source-factory.*
 map-source.*
 marker-layer.*
 marker.*
+memory-cache.*
 path-layer.*
 point.*
 renderer.*
diff --git a/champlain/src/champlain_signals.defs b/champlain/src/champlain_signals.defs
index a8e2fba..9bf74a0 100644
--- a/champlain/src/champlain_signals.defs
+++ b/champlain/src/champlain_signals.defs
@@ -375,6 +375,17 @@
   (construct-only #f)
 )
 
+;; From ChamplainMemoryCache
+
+(define-property size-limit
+  (of-object "ChamplainMemoryCache")
+  (prop-type "GParamUInt")
+  (docs "Maximal number of stored tiles")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
 ;; From ChamplainPathLayer
 
 (define-property closed
diff --git a/champlain/src/filelist.am b/champlain/src/filelist.am
index bd99432..3079eee 100644
--- a/champlain/src/filelist.am
+++ b/champlain/src/filelist.am
@@ -22,6 +22,7 @@ files_hg  =                                   \
        map-source-desc.hg                      \
        map-source-factory.hg                   \
        map-source.hg                           \
+       memory-cache.hg                         \
        label.hg                                \
        point.hg                                \
        path-layer.hg                           \
diff --git a/champlain/src/memory-cache.ccg b/champlain/src/memory-cache.ccg
new file mode 100644
index 0000000..98e7f82
--- /dev/null
+++ b/champlain/src/memory-cache.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/memory-cache.hg b/champlain/src/memory-cache.hg
new file mode 100644
index 0000000..89e6bbd
--- /dev/null
+++ b/champlain/src/memory-cache.hg
@@ -0,0 +1,55 @@
+/* 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 <champlainmm/renderer.h>
+#include <champlainmm/tile-cache.h>
+
+_DEFS(champlainmm,champlain)
+_PINCLUDE(champlainmm/private/tile-cache_p.h)
+
+namespace Champlain
+{
+
+/** Stores and loads cached tiles from the memory.
+ *
+ * MemoryCache is a cache that stores and retrieves tiles from the
+ * memory. The cache contents is not preserved between application restarts
+ * so this cache serves mostly as a quick access temporary cache to the
+ * most recently used tiles.
+ *
+ * @newin{0,8}
+ */
+class MemoryCache : public TileCache
+{
+  _CLASS_GOBJECT(MemoryCache, ChamplainMemoryCache, CHAMPLAIN_MEMORY_CACHE, TileCache, ChamplainTileCache)
+
+protected:
+  _WRAP_CTOR(MemoryCache(guint size_limit, const Glib::RefPtr<Renderer>& renderer), 
champlain_memory_cache_new_full)
+
+public:
+  _WRAP_CREATE(guint size_limit, const Glib::RefPtr<Renderer>& renderer)
+
+  _WRAP_METHOD(guint get_size_limit() const, champlain_memory_cache_get_size_limit)
+  _WRAP_METHOD(void set_size_limit(guint size_limit), champlain_memory_cache_set_size_limit)
+
+  _WRAP_METHOD(void clean(), champlain_memory_cache_clean)
+
+  _WRAP_PROPERTY("size-limit", guint)
+};
+
+} // namespace Champlain
diff --git a/tools/extradefs/generate_extra_defs_libchamplain.cc 
b/tools/extradefs/generate_extra_defs_libchamplain.cc
index 22c2a0f..0dfa0c4 100644
--- a/tools/extradefs/generate_extra_defs_libchamplain.cc
+++ b/tools/extradefs/generate_extra_defs_libchamplain.cc
@@ -38,6 +38,7 @@ main(int argc, char *argv[])
             << get_defs(CHAMPLAIN_TYPE_MAP_SOURCE_DESC)
             << get_defs(CHAMPLAIN_TYPE_MARKER_LAYER)
             << get_defs(CHAMPLAIN_TYPE_MARKER)
+            << get_defs(CHAMPLAIN_TYPE_MEMORY_CACHE)
             << get_defs(CHAMPLAIN_TYPE_PATH_LAYER)
             << get_defs(CHAMPLAIN_TYPE_POINT)
             << get_defs(CHAMPLAIN_TYPE_RENDERER)


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