fei_ParameterSet.cpp

00001 /*--------------------------------------------------------------------*/
00002 /*    Copyright 2005 Sandia Corporation.                              */
00003 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00004 /*    non-exclusive license for use of this work by or on behalf      */
00005 /*    of the U.S. Government.  Export of this program may require     */
00006 /*    a license from the United States Government.                    */
00007 /*--------------------------------------------------------------------*/
00008 
00009 #include <fei_macros.hpp>
00010 #include <fei_ParameterSet.hpp>
00011 
00012 fei::ParameterSet::ParameterSet()
00013   : params_(NULL)
00014 {
00015   params_ = new std::vector<const Param*>;
00016 }
00017 
00018 fei::ParameterSet::~ParameterSet()
00019 {
00020   const_iterator iter = begin(), iter_end = end();
00021   for(; iter != iter_end; ++iter) {
00022     delete &(*iter);
00023   }
00024 
00025   delete params_; params_ = NULL;
00026 }
00027 
00028 int fei::ParameterSet::getIntParamValue(const char* name,
00029           int& paramValue) const
00030 {
00031   const fei::Param* param = get(name);
00032   if (param == NULL) return(-1);
00033 
00034   if (param->getType() != fei::Param::INT) return(-1);
00035 
00036   paramValue = param->getIntValue();
00037   return(0);
00038 }
00039 
00040 int fei::ParameterSet::getDoubleParamValue(const char* name,
00041              double& paramValue) const
00042 {
00043   const fei::Param* param = get(name);
00044   if (param == NULL) return(-1);
00045 
00046   if (param->getType() == fei::Param::INT) {
00047     paramValue = param->getIntValue();
00048   }
00049   else if (param->getType() == fei::Param::DOUBLE) {
00050     paramValue = param->getDoubleValue();
00051   }
00052   else return(-1);
00053 
00054   return(0);
00055 }
00056 
00057 int fei::ParameterSet::getStringParamValue(const char* name,
00058              std::string& paramValue) const
00059 {
00060   const fei::Param* param = get(name);
00061   if (param == NULL) return(-1);
00062 
00063   if (param->getType() != fei::Param::STRING) return(-1);
00064 
00065   paramValue = param->getStringValue();
00066   return(0);
00067 }
00068 
00069 int fei::ParameterSet::getBoolParamValue(const char* name,
00070            bool& paramValue) const
00071 {
00072   const fei::Param* param = get(name);
00073   if (param == NULL) return(-1);
00074 
00075   if (param->getType() != fei::Param::BOOL) return(-1);
00076 
00077   paramValue = param->getBoolValue();
00078   return(0);
00079 }
00080 
00081 int fei::ParameterSet::getVoidParamValue(const char* name,
00082            const void*& paramValue) const
00083 {
00084   const fei::Param* param = get(name);
00085   if (param == NULL) return(-1);
00086 
00087   if (param->getType() != fei::Param::VOID) return(-1);
00088 
00089   paramValue = param->getVoidValue();
00090   return(0);
00091 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends
Generated on Wed Apr 13 10:08:24 2011 for FEI by  doxygen 1.6.3