LCOV - code coverage report
Current view: top level - synthesis/Parallel - SerialTransport.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 105 0.0 %
Date: 2024-10-29 13:38:20 Functions: 0 29 0.0 %

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

Generated by: LCOV version 1.16