Line data Source code
1 : //# ClassFileName.cc: this defines ClassName, which ... 2 : //# Copyright (C) 1998,1999,2000 3 : //# Associated Universities, Inc. Washington DC, USA. 4 : //# 5 : //# This library is free software; you can redistribute it and/or modify it 6 : //# under the terms of the GNU Library General Public License as published by 7 : //# the Free Software Foundation; either version 2 of the License, or (at your 8 : //# option) any later version. 9 : //# 10 : //# This library is distributed in the hope that it will be useful, but WITHOUT 11 : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 : //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 13 : //# License for more details. 14 : //# 15 : //# You should have received a copy of the GNU Library General Public License 16 : //# along with this library; if not, write to the Free Software Foundation, 17 : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 18 : //# 19 : //# Correspondence concerning AIPS++ should be addressed as follows: 20 : //# Internet email: casa-feedback@nrao.edu. 21 : //# Postal address: AIPS++ Project Office 22 : //# National Radio Astronomy Observatory 23 : //# 520 Edgemont Road 24 : //# Charlottesville, VA 22903-2475 USA 25 : //# 26 : //# $Id$ 27 : 28 : //# Includes 29 : 30 : #include <synthesis/Parallel/SerialTransport.h> 31 : #include <casacore/casa/Containers/Record.h> 32 : 33 : using namespace casacore; 34 : namespace casa { //# NAMESPACE CASA - BEGIN 35 : 36 : // OK this is all pretty straight forward. Just assign the pointers. 37 : // On the gets check it's nonzero first. Probably should throw an 38 : // exception. 39 : 40 1 : SerialTransport::SerialTransport(): PTransport(), inQue(0), outQue(0), lastInQue(0) 41 : { 42 1 : if (debug_p) { 43 0 : cerr << "constructing SerialTransport" << std::endl; 44 : } 45 1 : _data.resize(20); 46 1 : } 47 : 48 13052 : Int SerialTransport::add2Queue(void *item){ 49 13052 : if (debug_p) { 50 0 : cerr << ">add2Queue: " << item << ", " << inQue << ", " << outQue << ", " << 51 0 : lastInQue << ", " << _data.nelements() << "\n"; 52 : } 53 : 54 13052 : _data[inQue] = item; 55 13052 : ++inQue; 56 : // This was here from ancient times. It looks wrong. Applicator/algorithm for example 57 : // won't work at all. 58 : // outQue = 0; // eh? only strict put... get sequence supported? 59 : 60 13052 : if(inQue >= _data.nelements()) 61 10 : _data.resize(inQue*2, false, true); 62 13052 : lastInQue = inQue; 63 : 64 : 65 13052 : return(0); 66 : } 67 13052 : void *SerialTransport::getFromQueue(){ 68 13052 : void *ptr2data(nullptr); 69 13052 : if (debug_p) { 70 0 : cerr << ">getFromQueue: " << _data[outQue] << ", " << inQue << ", " << 71 0 : outQue << ", " << lastInQue << "\n"; 72 : } 73 13052 : if(outQue < lastInQue){ 74 13052 : ptr2data = _data[outQue]; 75 13052 : ++outQue; 76 : } 77 : else { 78 0 : cerr << "**** inconsistency in SerialTransport::getFromQueue" << std::endl; 79 : } 80 13052 : return(ptr2data); 81 : } 82 : 83 1354 : Int SerialTransport::put(const Array<Int> &af){ 84 : //cerr << "put array " << Vector<Int>(af) << endl; 85 1354 : return add2Queue((void *)&af); 86 : } 87 0 : Int SerialTransport::put(const Array<Float> &af){ 88 0 : return add2Queue((void *)&af); 89 : } 90 0 : Int SerialTransport::put(const Array<Double> &af){ 91 0 : return add2Queue((void *)&af); 92 : } 93 : 94 0 : Int SerialTransport::put(const Array<Complex> &af){ 95 0 : return add2Queue((void *)&af); 96 : } 97 : 98 0 : Int SerialTransport::put(const Array<DComplex> &af){ 99 0 : return add2Queue((void *)&af); 100 : } 101 : 102 : 103 263 : Int SerialTransport::put(const Float &f){ 104 263 : return add2Queue((void *)&f); 105 : } 106 0 : Int SerialTransport::put(const DComplex &f){ 107 0 : return add2Queue((void *)&f); 108 : } 109 0 : Int SerialTransport::put(const Complex &f){ 110 0 : return add2Queue((void *)&f); 111 : } 112 : 113 0 : Int SerialTransport::put(const Double &d){ 114 0 : return add2Queue((void *)&d); 115 : } 116 2183 : Int SerialTransport::put(const Int &i){ 117 2183 : return add2Queue((void *)&i); 118 : } 119 1316 : Int SerialTransport::put(const String &s){ 120 1316 : return add2Queue((void *)&s); 121 : } 122 1655 : Int SerialTransport::put(const Bool &b){ 123 1655 : return add2Queue((void *)&b); 124 : } 125 6281 : Int SerialTransport::put(const Record &r){ 126 6281 : return add2Queue((void *)&r); 127 : } 128 : 129 : 130 0 : Int SerialTransport::get(Array<Float> &af){ 131 0 : Int r_status(1); 132 0 : af = *((Array<Float> *)getFromQueue()); 133 : 134 0 : return(r_status); 135 : } 136 : 137 0 : Int SerialTransport::get(Array<Double> &af){ 138 0 : Int r_status(1); 139 0 : af = *((Array<Double> *)getFromQueue()); 140 0 : return(r_status); 141 : } 142 : 143 0 : Int SerialTransport::get(Array<Complex> &af){ 144 0 : Int r_status(1); 145 0 : af = *((Array<Complex> *)getFromQueue()); 146 0 : return(r_status); 147 : } 148 : 149 0 : Int SerialTransport::get(Array<DComplex> &af){ 150 0 : Int r_status(1); 151 0 : af = *((Array<DComplex> *)getFromQueue()); 152 0 : return(r_status); 153 : } 154 : 155 1354 : Int SerialTransport::get(Array<Int> &af){ 156 1354 : Int r_status(1); 157 1354 : af = *((Array<Int> *)getFromQueue()); 158 : //cerr << "get array " << Vector<Int>(af) << endl; 159 1354 : return(r_status); 160 : } 161 : 162 0 : Int SerialTransport::get(Complex &f){ 163 0 : Int r_status(1); 164 0 : f = *((Complex *)getFromQueue()); 165 0 : return(r_status); 166 : } 167 : 168 0 : Int SerialTransport::get(DComplex &f){ 169 0 : Int r_status(1); 170 0 : f = *((DComplex *)getFromQueue()); 171 0 : return(r_status); 172 : } 173 : 174 263 : Int SerialTransport::get(Float &f){ 175 263 : Int r_status(1); 176 263 : f = *((Float *)getFromQueue()); 177 263 : return(r_status); 178 : } 179 0 : Int SerialTransport::get(Double &d){ 180 0 : Int r_status(1); 181 0 : d = *((Double *)getFromQueue()); 182 0 : return(r_status); 183 : } 184 : 185 2183 : Int SerialTransport::get(Int &i){ 186 2183 : Int r_status(0); 187 2183 : i = *((Int *)getFromQueue()); 188 2183 : return(r_status); 189 : } 190 : 191 1316 : Int SerialTransport::get(String &s){ 192 1316 : Int r_status(1); 193 1316 : String * val = (String *)getFromQueue(); 194 1316 : if (val) 195 1316 : s = *val; 196 1316 : return(r_status); 197 : } 198 : 199 6281 : Int SerialTransport::get(Record &r){ 200 6281 : Int r_status(1); 201 6281 : r = *((Record *)getFromQueue()); 202 6281 : return(r_status); 203 : } 204 : 205 1655 : Int SerialTransport::get(Bool &b){ 206 1655 : Int r_status(1); 207 1655 : b = *((Bool *)getFromQueue()); 208 1655 : return(r_status); 209 : } 210 : 211 : } //# NAMESPACE CASA - END 212 :