cgma
|
00001 // VariableArray.hpp - implementation of the class used to store various 00002 //- arrays of input information not directly used by cubit. Normally this is a set of doubles 00003 //- in pairs or triplets used to define a function for loadint (force and time) temperature 00004 //- dependence (ksi, strain%. temperature) etc. Can also be a set of integers if needed, but 00005 //- for now is not extensible to mixed types 00006 00007 // Written by Paul Wolfenbarger 00008 // Jan 13th, 2010 00009 00010 #ifndef VARIABLE_ARRAY_HPP 00011 #define VARIABLE_ARRAY_HPP 00012 #include <vector> 00013 #include <limits> 00014 #include <cstddef> 00015 00016 00017 template <class T> 00018 class VariableArray : public std::vector <std::vector <T> > 00019 { 00020 public : 00021 VariableArray (size_t rowWidth) : _rowWidth(rowWidth), 00022 mNan(std::numeric_limits<T>::quiet_NaN()) {} 00023 ~VariableArray() {} 00024 00025 T& getItem(size_t rowNumber, size_t columnNumber) 00026 { 00027 if (rowNumber < this->size() && columnNumber < _rowWidth) 00028 return (*this)[rowNumber][columnNumber] ; 00029 else 00030 return mNan ; 00031 } 00032 00033 void addRow(const std::vector <T>& newRow) 00034 { 00035 this->push_back(newRow) ; 00036 } 00037 00038 std::pair <int, int> getSize() // row, column 00039 { 00040 return std::make_pair(this->size(), _rowWidth) ; 00041 } 00042 00043 private: 00044 VariableArray() ; // not implemented 00045 VariableArray(VariableArray const&) ; // not implemented 00046 // VariableArray& operator=(VariableArray const&) ; // the default should work well 00047 00048 size_t _rowWidth ; 00049 T mNan ; 00050 } ; 00051 00052 00053 #define Def_Amplitude(Name) VariableArray <double> Name(2) ; 00054 00055 #endif //VARIABLE_ARRAY_HPP