]> Dogcows Code - chaz/yoink/blobdiff - src/stlplus/persistence/persistent_matrix.tpp
testing new non-autotools build system
[chaz/yoink] / src / stlplus / persistence / persistent_matrix.tpp
diff --git a/src/stlplus/persistence/persistent_matrix.tpp b/src/stlplus/persistence/persistent_matrix.tpp
new file mode 100644 (file)
index 0000000..ac81f85
--- /dev/null
@@ -0,0 +1,49 @@
+////////////////////////////////////////////////////////////////////////////////\r
+\r
+//   Author:    Andy Rushton\r
+//   Copyright: (c) Southampton University 1999-2004\r
+//              (c) Andy Rushton           2004-2009\r
+//   License:   BSD License, see ../docs/license.html\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+#include "persistent_int.hpp"\r
+\r
+namespace stlplus\r
+{\r
+\r
+  ////////////////////////////////////////////////////////////////////////////////\r
+\r
+  template<typename T, typename DT>\r
+  void dump_matrix(dump_context& context, const matrix<T>& data,\r
+                   DT dump_fn)\r
+    throw(persistent_dump_failed)\r
+  {\r
+    unsigned rows = data.rows();\r
+    unsigned cols = data.columns();\r
+    dump_unsigned(context, rows);\r
+    dump_unsigned(context, cols);\r
+    for (unsigned r = 0; r < rows; r++)\r
+      for (unsigned c = 0; c < cols; c++)\r
+        dump_fn(context, data(r,c));\r
+  }\r
+\r
+  ////////////////////////////////////////////////////////////////////////////////\r
+\r
+  template<typename T, typename RT>\r
+  void restore_matrix(restore_context& context, matrix<T>& data,\r
+                      RT restore_fn)\r
+    throw(persistent_restore_failed)\r
+  {\r
+    unsigned rows = 0;\r
+    restore_unsigned(context, rows);\r
+    unsigned cols = 0;\r
+    restore_unsigned(context, cols);\r
+    data.resize(rows,cols);\r
+    for (unsigned r = 0; r < rows; r++)\r
+      for (unsigned c = 0; c < cols; c++)\r
+        restore_fn(context, data(r,c));\r
+  }\r
+\r
+  ////////////////////////////////////////////////////////////////////////////////\r
+\r
+} // end namespace stlplus\r
This page took 0.024357 seconds and 4 git commands to generate.