X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fstlplus%2Fpersistence%2Fpersistent_matrix.tpp;fp=src%2Fstlplus%2Fpersistence%2Fpersistent_matrix.tpp;h=ac81f857fbf06bba73da6bcaafd266d1c5bfd2f7;hb=6b0a0d0efafe34d48ab344fca3b479553bd4e62c;hp=0000000000000000000000000000000000000000;hpb=85783316365181491a3e3c0c63659972477cebba;p=chaz%2Fyoink diff --git a/src/stlplus/persistence/persistent_matrix.tpp b/src/stlplus/persistence/persistent_matrix.tpp new file mode 100644 index 0000000..ac81f85 --- /dev/null +++ b/src/stlplus/persistence/persistent_matrix.tpp @@ -0,0 +1,49 @@ +//////////////////////////////////////////////////////////////////////////////// + +// Author: Andy Rushton +// Copyright: (c) Southampton University 1999-2004 +// (c) Andy Rushton 2004-2009 +// License: BSD License, see ../docs/license.html + +//////////////////////////////////////////////////////////////////////////////// +#include "persistent_int.hpp" + +namespace stlplus +{ + + //////////////////////////////////////////////////////////////////////////////// + + template + void dump_matrix(dump_context& context, const matrix& data, + DT dump_fn) + throw(persistent_dump_failed) + { + unsigned rows = data.rows(); + unsigned cols = data.columns(); + dump_unsigned(context, rows); + dump_unsigned(context, cols); + for (unsigned r = 0; r < rows; r++) + for (unsigned c = 0; c < cols; c++) + dump_fn(context, data(r,c)); + } + + //////////////////////////////////////////////////////////////////////////////// + + template + void restore_matrix(restore_context& context, matrix& data, + RT restore_fn) + throw(persistent_restore_failed) + { + unsigned rows = 0; + restore_unsigned(context, rows); + unsigned cols = 0; + restore_unsigned(context, cols); + data.resize(rows,cols); + for (unsigned r = 0; r < rows; r++) + for (unsigned c = 0; c < cols; c++) + restore_fn(context, data(r,c)); + } + + //////////////////////////////////////////////////////////////////////////////// + +} // end namespace stlplus