From: bangerth Date: Tue, 18 Oct 2011 14:38:27 +0000 (+0000) Subject: Make serialization work again. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e426e7216d1d9f0c4b68acee87b84d004006da19;p=dealii-svn.git Make serialization work again. git-svn-id: https://svn.dealii.org/trunk@24633 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/base/table_handler.h b/deal.II/include/deal.II/base/table_handler.h index ebcbf754f7..e131d4b3ad 100644 --- a/deal.II/include/deal.II/base/table_handler.h +++ b/deal.II/include/deal.II/base/table_handler.h @@ -54,12 +54,17 @@ namespace internal struct TableEntry { public: + /** + * Default constructor. + */ + TableEntry (); + /** * Constructor. Initialize this table element with the value t. */ template TableEntry (const T &t); - + /** * Return the value stored by this object. The template type * T must be one of int,unsigned int,double,std::string @@ -94,7 +99,7 @@ namespace internal void load (Archive & ar, const unsigned int version); BOOST_SERIALIZATION_SPLIT_MEMBER() - + private: /** * Abbreviation for the data type stored by this object. @@ -105,7 +110,7 @@ namespace internal * Stored value. */ value_type value; - + friend class dealii::TableHandler; }; } @@ -179,7 +184,7 @@ namespace internal * same number of elements in it so that the result is in fact a table. This * assumes that in each of the iterations (time steps, nonlinear iterations, etc) * you fill every single column. On the other hand, this may not always be what - * you want to do. For example, it could be that the function that computes the + * you want to do. For example, it could be that the function that computes the * nonlinear residual is only called every few time steps; or, a function computing * statistics of the mesh is only called whenever the mesh is in fact refined. * In these cases, the add_value() function will be called less often for some @@ -189,7 +194,7 @@ namespace internal * An entirely different scenario is that the table is filled and at a later time * we use the data in there to compute the elements of other rows; the ConvergenceTable * class does something like this. - * + * * To support both scenarios, the TableHandler class has a property called * auto-fill mode. By default, auto-fill mode is off, but it can be * enabled by calling set_auto_fill_mode(). If auto-fill mode is enabled @@ -204,12 +209,12 @@ namespace internal * the number zero; if T is std::string, then * T() is the empty string "". * - Add the given value to this column. - * + * * Padding the column with default elements makes sure that after the addition the * column has as many entries as the longest other column. In other words, if * we have skipped previous invokations of add_value() for a given key, then the * padding will enter default values into this column. - * + * * The algorithm as described will fail if you try to skip adding values for a key * if adding an element for this key is the first thing you want to do for a given * iteration or time step, since we would then pad to the length of the longest @@ -217,7 +222,7 @@ namespace internal * adding to this column to a different spot in your program, after adding to * a column that will always be added to; or, you may want to start every iteration * by adding the number of the iteration to the table, for example in column 1. - * + * * * @ingroup textoutput * @author Ralf Hartmann, 1999; Wolfgang Bangerth, 2011 @@ -244,7 +249,7 @@ class TableHandler template void add_value (const std::string &key, const T value); - + /** * Switch auto-fill mode on or off. See the general documentation * of this class for a description of what auto-fill mode does. @@ -526,7 +531,7 @@ class TableHandler * fixed point notation. */ bool scientific; - + /** * Flag that may be used by * derived classes for @@ -631,12 +636,18 @@ class TableHandler // inline and template functions namespace internal { + inline + TableEntry::TableEntry () + {} + + template TableEntry::TableEntry (const T &t) : value (t) {} + template inline T TableEntry::get () const @@ -804,11 +815,11 @@ void TableHandler::add_value (const std::string &key, unsigned int n = 0; for (std::map< std::string, Column >::iterator p = columns.begin(); p != columns.end(); ++p) n = (n >= p->second.entries.size() ? n : p->second.entries.size()); - + while (columns[key].entries.size()+1 < n) columns[key].entries.push_back (internal::TableEntry(T())); } - + // now push the value given to this function columns[key].entries.push_back (internal::TableEntry(value)); } diff --git a/tests/serialization/table_handler/cmp/generic b/tests/serialization/table_handler/cmp/generic index 96c4d72426..225ad6e739 100644 --- a/tests/serialization/table_handler/cmp/generic +++ b/tests/serialization/table_handler/cmp/generic @@ -1,4 +1,4 @@ -DEAL::22 serialization::archive 9 0 0 0 0 4 0 4 key1 4 key2 4 key3 4 key4 0 0 4 0 0 0 4 key1 0 0 0 0 10 0 0 0 117 0 115 5 abc-1 117 99 100 1.7320508075688772 117 4 115 5 abc-5 117 103 100 2.6457513110645907 117 8 115 5 abc-9 4 key1 1 c 4 0 0 4 key2 10 0 100 0 117 1 115 5 abc-2 117 100 100 2 117 5 115 5 abc-6 117 104 100 2.8284271247461903 117 9 4 key2 1 c 4 0 0 4 key3 10 0 117 97 100 1 117 2 115 5 abc-3 117 101 100 2.2360679774997898 117 6 115 5 abc-7 117 105 100 3 4 key3 1 c 4 0 0 4 key4 10 0 115 5 abc-0 117 98 100 1.4142135623730951 117 3 115 5 abc-4 117 102 100 2.4494897427831779 117 7 115 5 abc-8 117 106 4 key4 1 c 4 0 0 0 0 0 0 0 0 0 0 44 This is a caption text with \LaTeX{} symbols 0 +DEAL::22 serialization::archive 9 0 0 0 0 4 0 4 key1 4 key2 4 key3 4 key4 0 0 4 0 0 0 4 key1 0 0 0 0 10 0 0 0 117 0 115 5 abc-1 117 99 100 1.7320508075688772 117 4 115 5 abc-5 117 103 100 2.6457513110645907 117 8 115 5 abc-9 4 key1 1 c 4 0 0 4 key2 10 0 100 0 117 1 115 5 abc-2 117 100 100 2 117 5 115 5 abc-6 117 104 100 2.8284271247461903 117 9 4 key2 1 c 4 0 0 4 key3 10 0 117 97 100 1 117 2 115 5 abc-3 117 101 100 2.2360679774997898 117 6 115 5 abc-7 117 105 100 3 4 key3 1 c 4 0 0 4 key4 10 0 115 5 abc-0 117 98 100 1.4142135623730951 117 3 115 5 abc-4 117 102 100 2.4494897427831779 117 7 115 5 abc-8 117 106 4 key4 1 c 4 0 0 0 0 0 0 0 0 0 0 44 This is a caption text with \LaTeX{} symbols 0 0 DEAL::OK