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: aips2-request@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 12759 : Int SerialTransport::add2Queue(void *item){ 49 12759 : if (debug_p) { 50 0 : cerr << ">add2Queue: " << item << ", " << inQue << ", " << outQue << ", " << 51 0 : lastInQue << ", " << _data.nelements() << "\n"; 52 : } 53 : 54 12759 : _data[inQue] = item; 55 12759 : ++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 12759 : if(inQue >= _data.nelements()) 61 10 : _data.resize(inQue*2, false, true); 62 12759 : lastInQue = inQue; 63 : 64 : 65 12759 : return(0); 66 : } 67 12759 : void *SerialTransport::getFromQueue(){ 68 12759 : void *ptr2data(nullptr); 69 12759 : if (debug_p) { 70 0 : cerr << ">getFromQueue: " << _data[outQue] << ", " << inQue << ", " << 71 0 : outQue << ", " << lastInQue << "\n"; 72 : } 73 12759 : if(outQue < lastInQue){ 74 12759 : ptr2data = _data[outQue]; 75 12759 : ++outQue; 76 : } 77 : else { 78 0 : cerr << "**** inconsistency in SerialTransport::getFromQueue" << std::endl; 79 : } 80 12759 : return(ptr2data); 81 : } 82 : 83 1328 : Int SerialTransport::put(const Array<Int> &af){ 84 : //cerr << "put array " << Vector<Int>(af) << endl; 85 1328 : 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 264 : Int SerialTransport::put(const Float &f){ 104 264 : 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 2129 : Int SerialTransport::put(const Int &i){ 117 2129 : return add2Queue((void *)&i); 118 : } 119 1321 : Int SerialTransport::put(const String &s){ 120 1321 : return add2Queue((void *)&s); 121 : } 122 1599 : Int SerialTransport::put(const Bool &b){ 123 1599 : return add2Queue((void *)&b); 124 : } 125 6118 : Int SerialTransport::put(const Record &r){ 126 6118 : 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 1328 : Int SerialTransport::get(Array<Int> &af){ 156 1328 : Int r_status(1); 157 1328 : af = *((Array<Int> *)getFromQueue()); 158 : //cerr << "get array " << Vector<Int>(af) << endl; 159 1328 : 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 264 : Int SerialTransport::get(Float &f){ 175 264 : Int r_status(1); 176 264 : f = *((Float *)getFromQueue()); 177 264 : 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 2129 : Int SerialTransport::get(Int &i){ 186 2129 : Int r_status(0); 187 2129 : i = *((Int *)getFromQueue()); 188 2129 : return(r_status); 189 : } 190 : 191 1321 : Int SerialTransport::get(String &s){ 192 1321 : Int r_status(1); 193 1321 : String * val = (String *)getFromQueue(); 194 1321 : if (val) 195 1321 : s = *val; 196 1321 : return(r_status); 197 : } 198 : 199 6118 : Int SerialTransport::get(Record &r){ 200 6118 : Int r_status(1); 201 6118 : r = *((Record *)getFromQueue()); 202 6118 : return(r_status); 203 : } 204 : 205 1599 : Int SerialTransport::get(Bool &b){ 206 1599 : Int r_status(1); 207 1599 : b = *((Bool *)getFromQueue()); 208 1599 : return(r_status); 209 : } 210 : 211 : } //# NAMESPACE CASA - END 212 :