]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Make histogram class easily extendible.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 10 Mar 1999 12:18:40 +0000 (12:18 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 10 Mar 1999 12:18:40 +0000 (12:18 +0000)
git-svn-id: https://svn.dealii.org/trunk@984 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/numerics/histogram.h
deal.II/deal.II/source/numerics/histogram.cc

index 5d1ff781401c59137bf8913b7267b60ffe2ad6d0..14d9e46f40640f0a5631c34834b7521f700fc4e6 100644 (file)
@@ -8,7 +8,7 @@
 #include <base/exceptions.h>
 #include <lac/forward-declarations.h>
 #include <vector>
-
+#include <string>
 
 
 
  *    Negative and zero values are sorted into the leftmost interval.
  * \end{itemize}
  *
+ * To keep programs extendible, you can use the two functions
+ * #get_interval_spacing_names# and #parse_interval_spacing#, which always
+ * give you a complete list of spacing formats presently supported and are
+ * able to generate the respective value of the #enum#. If you use them,
+ * you can write your program in a way such that it only needs to be
+ * recompiled to take effect of newly added formats, without changing your
+ * code.
+ *
  *
  * \subsection{Output formats}
  *
@@ -117,6 +125,22 @@ class Histogram
                                      */
     void write_gnuplot (ostream &out) const;
 
+                                    /**
+                                     * Return allowed names for the interval
+                                     * spacing as string. At present this
+                                     * is "linear|logarithmic".
+                                     */
+    static string get_interval_spacing_names ();
+
+                                    /**
+                                     * Get a string containing one of the
+                                     * names returned by the above function
+                                     * and return the respective value of
+                                     * #IntervalSpacing#. Throw an error
+                                     * if the string is no valid one.
+                                     */
+    static IntervalSpacing parse_interval_spacing (const string &name);
+    
                                     /**
                                      * Exception.
                                      */
@@ -140,6 +164,13 @@ class Histogram
                    int, int,
                    << "The two array sizes " << arg1 << " and " << arg2
                    << " must match, but don't.");
+                                    /**
+                                     * Exception.
+                                     */
+    DeclException1 (ExcInvalidName,
+                   string,
+                   << "The given name <" << arg1
+                   << "> does not match any of the known formats.");
     
   private:
                                     /**
index 1862ec14d4540fe36f17d5e966a42250db0328f7..7e203a549e703b8508a824e68318a6ea84ce26af 100644 (file)
@@ -249,6 +249,31 @@ void Histogram::write_gnuplot (ostream &out) const
 
 
 
+string Histogram::get_interval_spacing_names () 
+{
+  return "linear|logarithmic";
+};
+
+
+
+Histogram::IntervalSpacing
+Histogram::parse_interval_spacing (const string &name)
+{
+  if (name=="linear")
+    return linear;
+  else
+    if (name=="logarithmic")
+      return logarithmic;
+    else
+      {
+       AssertThrow (false, ExcInvalidName(name));
+
+       return linear;
+      };
+};
+
+
+
 
 // explicit instantiations for float
 template

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.