]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
log-output of parameters
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 9 Nov 2000 17:59:24 +0000 (17:59 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 9 Nov 2000 17:59:24 +0000 (17:59 +0000)
git-svn-id: https://svn.dealii.org/trunk@3474 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/parameter_handler.h
deal.II/base/source/parameter_handler.cc

index 325b505bff9f8d52c913c4f651853a023834a945..a17c5291fd0404b684fcd8376ff1fa5ba4dd6af9 100644 (file)
@@ -26,7 +26,7 @@ class MultipleParameterLoop;
 
 class istream;
 class ostream;
-
+class LogStream;
 
 /**
  * List of possible output formats.
@@ -1098,6 +1098,23 @@ class ParameterHandler
                                   const OutputStyle Style,
                                   const unsigned int indent_level);
 
+                                  /**
+                                   * Print parameters to a logstream.
+                                   * This function allows to print
+                                   * all parameters into a log-file.
+                                   * Sections will be indented in the
+                                   * usual log-file style.
+                                   */
+    void log_parameters (LogStream& out);
+
+                                  /**
+                                   * Log parameters in
+                                   * subsection. The subsection is
+                                   * determined by the
+                                   * @p{subsection_path} member *
+                                   * variable.
+                                   */
+  void log_parameters_section (LogStream& out);
 
                                     /**
                                      * Exception
index b35ecae774b1f37649dcecc8e389b9f6cefe3102..94286d487f41d1f856db43840cd68a644e1f1106 100644 (file)
@@ -13,6 +13,7 @@
 
 
 #include <base/parameter_handler.h>
+#include <base/logstream.h>
 #include <fstream>
 #include <iomanip>
 #include <strstream>
@@ -627,6 +628,17 @@ ostream & ParameterHandler::print_parameters (ostream &out, OutputStyle style)
 };
 
 
+void
+ParameterHandler::log_parameters (LogStream &out)
+{
+  out.push("parameters");
+                                  // dive recursively into the subsections
+  log_parameters_section (out);
+
+  out.pop();
+};
+
+
 
 void ParameterHandler::print_parameters_section (ostream           &out,
                                                 const OutputStyle  style,
@@ -755,6 +767,45 @@ void ParameterHandler::print_parameters_section (ostream           &out,
 
 
 
+void ParameterHandler::log_parameters_section (LogStream           &out)
+{
+  Section *pd = get_present_defaults_subsection ();
+  Section *pc = get_present_changed_subsection ();
+
+                                  // traverse entry list
+  Section::EntryType::const_iterator ptr;
+
+                                  // first find out the longest entry name
+  unsigned int longest_entry = 0;
+  for (ptr = pd->entries.begin(); ptr != pd->entries.end(); ++ptr)
+    if (ptr->first.length() > longest_entry)
+      longest_entry = ptr->first.length();
+
+                                  // print entries one by one
+  for (ptr = pd->entries.begin(); ptr != pd->entries.end(); ++ptr)
+    {
+                                      // check whether this entry is listed
+                                      // in the Changed tree and actually
+                                      // differs from the default value
+      out << ptr->first << setw(longest_entry-ptr->first.length()+2) << "= "
+         << ptr->second.first << endl;
+    };
+
+
+                                  // now transverse subsections tree
+  map<string, Section*>::const_iterator ptrss;
+  for (ptrss = pd->subsections.begin(); ptrss != pd->subsections.end(); ++ptrss)
+    {
+      out.push(ptrss->first);
+      enter_subsection (ptrss->first);
+      log_parameters_section (out);
+      leave_subsection ();
+      out.pop();
+    };
+};
+
+
+
 bool ParameterHandler::scan_line (string line,
                                  const unsigned int lineno)
 {

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.