Line data Source code
1 : /* 2 : * ALMA - Atacama Large Millimeter Array 3 : * (c) European Southern Observatory, 2002 4 : * (c) Associated Universities Inc., 2002 5 : * Copyright by ESO (in the framework of the ALMA collaboration), 6 : * Copyright by AUI (in the framework of the ALMA collaboration), 7 : * All rights reserved. 8 : * 9 : * This library is free software; you can redistribute it and/or 10 : * modify it under the terms of the GNU Lesser General Public 11 : * License as published by the Free software Foundation; either 12 : * version 2.1 of the License, or (at your option) any later version. 13 : * 14 : * This library is distributed in the hope that it will be useful, 15 : * but WITHOUT ANY WARRANTY, without even the implied warranty of 16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 : * Lesser General Public License for more details. 18 : * 19 : * You should have received a copy of the GNU Lesser General Public 20 : * License along with this library; if not, write to the Free Software 21 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 22 : * MA 02111-1307 USA 23 : * 24 : * File Temperature.cpp 25 : */ 26 : 27 : #include <alma/ASDM/Temperature.h> 28 : #include <alma/ASDM/DoubleWrapper.h> 29 : #include <alma/ASDM/NumberFormatException.h> 30 : 31 : using namespace std; 32 : 33 : namespace asdm { 34 : 35 11005744 : Temperature Temperature::getTemperature(StringTokenizer &t) { 36 11005744 : double value = Double::parseDouble(t.nextToken()); 37 11005744 : return Temperature (value); 38 : } 39 : 40 0 : bool Temperature::isZero() const { 41 0 : return value == 0.0; 42 : } 43 : 44 15061 : double Temperature::fromString(const string& s) { 45 15061 : return Double::parseDouble(s); 46 : } 47 : 48 0 : string Temperature::toString(double x) { 49 0 : return Double::toString(x); 50 : } 51 : 52 : 53 0 : void Temperature::toBin(EndianOSStream& eoss) { 54 0 : eoss.writeDouble( value); 55 0 : } 56 : 57 0 : void Temperature::toBin(const vector<Temperature>& temp, EndianOSStream& eoss) { 58 0 : eoss.writeInt((int) temp.size()); 59 0 : for (unsigned int i = 0; i < temp.size(); i++) 60 0 : eoss.writeDouble(temp.at(i).value); 61 0 : } 62 : 63 0 : void Temperature::toBin(const vector<vector<Temperature> >& temp, EndianOSStream& eoss) { 64 0 : eoss.writeInt((int) temp.size()); 65 0 : eoss.writeInt((int) temp.at(0).size()); 66 0 : for (unsigned int i = 0; i < temp.size(); i++) 67 0 : for (unsigned int j = 0; j < temp.at(0).size(); j++) 68 0 : eoss.writeDouble(temp.at(i).at(j).value); 69 0 : } 70 : 71 0 : void Temperature::toBin(const vector< vector<vector<Temperature> > >& temp, EndianOSStream& eoss) { 72 0 : eoss.writeInt((int) temp.size()); 73 0 : eoss.writeInt((int) temp.at(0).size()); 74 0 : eoss.writeInt((int) temp.at(0).at(0).size()); 75 0 : for (unsigned int i = 0; i < temp.size(); i++) 76 0 : for (unsigned int j = 0; j < temp.at(0).size(); j++) 77 0 : for (unsigned int k = 0; k < temp.at(0).at(0).size(); j++) 78 0 : eoss.writeDouble(temp.at(i).at(j).at(k).value); 79 0 : } 80 : 81 0 : Temperature Temperature::fromBin(EndianIStream & eis) { 82 0 : return Temperature(eis.readDouble()); 83 : } 84 : 85 0 : vector<Temperature> Temperature::from1DBin(EndianIStream & eis) { 86 0 : int dim1 = eis.readInt(); 87 0 : vector<Temperature> result; 88 0 : for (int i = 0; i < dim1; i++) 89 0 : result.push_back(Temperature(eis.readDouble())); 90 0 : return result; 91 : } 92 : 93 0 : vector<vector<Temperature > > Temperature::from2DBin(EndianIStream & eis) { 94 0 : int dim1 = eis.readInt(); 95 0 : int dim2 = eis.readInt(); 96 0 : vector< vector<Temperature> >result; 97 0 : vector <Temperature> aux; 98 0 : for (int i = 0; i < dim1; i++) { 99 0 : aux.clear(); 100 0 : for (int j = 0; j < dim2; j++) 101 0 : aux.push_back(Temperature(eis.readDouble())); 102 0 : result.push_back(aux); 103 : } 104 0 : return result; 105 : } 106 : 107 0 : vector<vector<vector<Temperature > > > Temperature::from3DBin(EndianIStream & eis) { 108 0 : int dim1 = eis.readInt(); 109 0 : int dim2 = eis.readInt(); 110 0 : int dim3 = eis.readInt(); 111 0 : vector<vector< vector<Temperature> > >result; 112 0 : vector < vector<Temperature> >aux1; 113 0 : vector <Temperature> aux2; 114 0 : for (int i = 0; i < dim1; i++) { 115 0 : aux1.clear(); 116 0 : for (int j = 0; j < dim2; j++) { 117 0 : aux2.clear(); 118 0 : for (int k = 0; k < dim3; k++) 119 0 : aux2.push_back(Temperature(eis.readDouble())); 120 0 : aux1.push_back(aux2); 121 : } 122 0 : result.push_back(aux1); 123 : } 124 0 : return result; 125 : } 126 : 127 : } // End namespace asdm