[Bf-blender-cvs] [f0f29153d25] soc-2021-adaptive-cloth: msgpack: blender::generational_arena::Arena: packer implementation

ishbosamiya noreply at git.blender.org
Wed Aug 4 11:29:31 CEST 2021


Commit: f0f29153d252ad1183c5c1a8fab2817126e8a077
Author: ishbosamiya
Date:   Mon Jul 26 18:10:14 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rBf0f29153d252ad1183c5c1a8fab2817126e8a077

msgpack: blender::generational_arena::Arena: packer implementation

===================================================================

A	source/blender/blenlib/BLI_generational_arena_msgpack.hh
M	source/blender/blenlib/CMakeLists.txt

===================================================================

diff --git a/source/blender/blenlib/BLI_generational_arena_msgpack.hh b/source/blender/blenlib/BLI_generational_arena_msgpack.hh
new file mode 100644
index 00000000000..7e3e889be76
--- /dev/null
+++ b/source/blender/blenlib/BLI_generational_arena_msgpack.hh
@@ -0,0 +1,50 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+/** \file
+ * \ingroup bli
+ *
+ * msgpack implementation for `blender::generational_arena::Arena<T>`
+ */
+
+#include "BLI_generational_arena.hh"
+
+#include "msgpack.hpp"
+
+namespace msgpack {
+MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
+{
+  namespace adaptor {
+
+  template<typename T> struct pack<blender::generational_arena::Arena<T>> {
+    template<typename Stream>
+    msgpack::packer<Stream> &operator()(msgpack::packer<Stream> &o,
+                                        const blender::generational_arena::Arena<T> &v) const
+    {
+      uint32_t size = checked_get_container_size(v.size());
+      o.pack_array(size);
+      for (const auto &val : v) {
+        o.pack(val);
+      }
+      return o;
+    }
+  };
+
+  }  // namespace adaptor
+}  // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
+}  // namespace msgpack
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index c42623736bf..2516da92355 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -198,6 +198,7 @@ set(SRC
   BLI_fnmatch.h
   BLI_function_ref.hh
   BLI_generational_arena.hh
+  BLI_generational_arena_msgpack.hh
   BLI_ghash.h
   BLI_gsqueue.h
   BLI_hash.h



More information about the Bf-blender-cvs mailing list