FEI Version of the Day
fei_Param.cpp
00001 /*
00002 // @HEADER
00003 // ************************************************************************
00004 //             FEI: Finite Element Interface to Linear Solvers
00005 //                  Copyright (2005) Sandia Corporation.
00006 //
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the
00008 // U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Alan Williams (william@sandia.gov) 
00038 //
00039 // ************************************************************************
00040 // @HEADER
00041 */
00042 
00043 
00044 
00045 #include <fei_macros.hpp>
00046 
00047 #include <fei_Param.hpp>
00048 
00049 fei::Param::Param(const char* name,
00050       const char* value)
00051   : type_(STRING),
00052     name_(),
00053     string_value_(),
00054     double_value_(0.0),
00055     int_value_(0),
00056     bool_value_(false),
00057     void_value_(NULL)
00058 {
00059   if (name != 0) name_ = name;
00060   if (value != 0) string_value_ = value;
00061 }
00062 
00063 fei::Param::Param(const char* name,
00064       double value)
00065   : type_(DOUBLE),
00066     name_(),
00067     string_value_(),
00068     double_value_(value),
00069     int_value_(0),
00070     bool_value_(false),
00071     void_value_(NULL)
00072 {
00073   if (name != 0) name_ = name;
00074 }
00075 
00076 fei::Param::Param(const char* name,
00077       int value)
00078   : type_(INT),
00079     name_(),
00080     string_value_(),
00081     double_value_(0.0),
00082     int_value_(value),
00083     bool_value_(false),
00084     void_value_(NULL)
00085 {
00086   if (name != 0) name_ = name;
00087 }
00088 
00089 fei::Param::Param(const char* name,
00090       bool value)
00091   : type_(BOOL),
00092     name_(),
00093     string_value_(),
00094     double_value_(0.0),
00095     int_value_(0),
00096     bool_value_(value),
00097     void_value_(NULL)
00098 {
00099   if (name != 0) name_ = name;
00100 }
00101 
00102 fei::Param::Param(const char* name,
00103       const void* value)
00104   : type_(VOID),
00105     name_(),
00106     string_value_(),
00107     double_value_(0.0),
00108     int_value_(0),
00109     bool_value_(false),
00110     void_value_(value)
00111 {
00112   if (name != 0) name_ = name;
00113 }
00114 
00115 fei::Param::Param(const fei::Param& src)
00116   : type_(src.type_),
00117     name_(),
00118     string_value_(),
00119     double_value_(0.0),
00120     int_value_(0),
00121     void_value_(NULL)
00122 {
00123   *this = src;
00124 }
00125 
00126 fei::Param::~Param()
00127 {
00128 }
00129 
00130 fei::Param& fei::Param::operator=(const fei::Param& src)
00131 {
00132   name_ = src.name_;
00133   switch(type_) {
00134   case STRING:
00135     string_value_ = src.string_value_; break;
00136   case DOUBLE:
00137     double_value_ = src.double_value_; break;
00138   case INT:
00139     int_value_ = src.int_value_; break;
00140   case VOID:
00141     void_value_ = src.void_value_; break;
00142   case BOOL:
00143     bool_value_ = src.bool_value_; break;
00144   case BAD_TYPE:
00145     break;
00146   }
00147 
00148   return(*this);
00149 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends