oct-spparms.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2004-2012 David Bateman
00004 Copyright (C) 1998-2004 Andy Adler
00005 
00006 This file is part of Octave.
00007 
00008 Octave is free software; you can redistribute it and/or modify it
00009 under the terms of the GNU General Public License as published by the
00010 Free Software Foundation; either version 3 of the License, or (at your
00011 option) any later version.
00012 
00013 Octave is distributed in the hope that it will be useful, but WITHOUT
00014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00016 for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with Octave; see the file COPYING.  If not, see
00020 <http://www.gnu.org/licenses/>.
00021 
00022 */
00023 
00024 #if !defined (octave_oct_spparms_h)
00025 #define octave_oct_spparms_h 1
00026 
00027 #include <cassert>
00028 #include <cstddef>
00029 
00030 #include <iosfwd>
00031 
00032 #include "str-vec.h"
00033 #include "dColVector.h"
00034 #include "dNDArray.h"
00035 
00036 #define OCTAVE_SPARSE_CONTROLS_SIZE 13
00037 
00038 class
00039 OCTAVE_API
00040 octave_sparse_params
00041 {
00042 protected:
00043 
00044   octave_sparse_params (void)
00045     : params (OCTAVE_SPARSE_CONTROLS_SIZE),
00046       keys (OCTAVE_SPARSE_CONTROLS_SIZE)
00047   {
00048     init_keys ();
00049     do_defaults ();
00050   }
00051 
00052 public:
00053 
00054   octave_sparse_params (const octave_sparse_params& a)
00055     : params (a.params), keys (a.keys) { }
00056 
00057   octave_sparse_params& operator = (const octave_sparse_params& a)
00058   {
00059     if (&a != this)
00060       {
00061         params = a.params;
00062         keys = a.keys;
00063       }
00064 
00065     return *this;
00066   }
00067 
00068   ~octave_sparse_params (void) { }
00069 
00070   static bool instance_ok (void);
00071 
00072   static void defaults (void);
00073 
00074   static void tight (void);
00075 
00076   static string_vector get_keys (void);
00077 
00078   static ColumnVector get_vals (void);
00079 
00080   static bool set_vals (const NDArray& vals);
00081 
00082   static bool set_key (const std::string& key, const double& val);
00083 
00084   static double get_key (const std::string& key);
00085 
00086   static double get_bandden (void);
00087 
00088   static void print_info (std::ostream& os, const std::string& prefix);
00089 
00090 private:
00091 
00092   ColumnVector params;
00093 
00094   string_vector keys;
00095 
00096   static octave_sparse_params *instance;
00097 
00098   static void cleanup_instance (void) { delete instance; instance = 0; }
00099 
00100   void do_defaults (void);
00101 
00102   void do_tight (void);
00103 
00104   string_vector do_get_keys (void) const { return keys; }
00105 
00106   ColumnVector do_get_vals (void) const { return params; }
00107 
00108   bool do_set_vals (const NDArray& vals);
00109 
00110   bool do_set_key (const std::string& key, const double& val);
00111 
00112   double do_get_key (const std::string& key);
00113 
00114   double do_get_bandden (void);
00115 
00116   void do_print_info (std::ostream& os, const std::string& prefix) const;
00117 
00118   void init_keys (void);
00119 };
00120 
00121 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines