LCOV - code coverage report
Current view: top level - synthesis/MeasurementEquations - CCList.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 12 12 100.0 %
Date: 2024-12-11 20:54:31 Functions: 4 4 100.0 %

          Line data    Source code
       1             : //# CCList.h:
       2             : //# Copyright (C) 1998,1999
       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             : //#
      27             : //# $Id$
      28             : 
      29             : #ifndef SYNTHESIS_CCLIST_H
      30             : #define SYNTHESIS_CCLIST_H
      31             : 
      32             : 
      33             : #include <casacore/casa/aips.h>
      34             : #include <casacore/casa/Containers/Block.h>
      35             : #include <casacore/casa/Arrays/IPosition.h>
      36             : #include <casacore/casa/Exceptions/Error.h>
      37             : #include <casacore/casa/Utilities/Assert.h>
      38             : #include <casacore/casa/Utilities/GenSort.h>
      39             : namespace casa { //# NAMESPACE CASA - BEGIN
      40             : 
      41             : // <summary>
      42             : // </summary>
      43             : 
      44             : // <use visibility=local>   or   <use visibility=export>
      45             : 
      46             : // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
      47             : // </reviewed>
      48             : 
      49             : // <prerequisite>
      50             : //   <li> SomeClass
      51             : //   <li> SomeOtherClass
      52             : //   <li> some concept
      53             : // </prerequisite>
      54             : //
      55             : // <etymology>
      56             : // </etymology>
      57             : //
      58             : // <synopsis>
      59             : // </synopsis>
      60             : //
      61             : // <example>
      62             : // </example>
      63             : //
      64             : // <motivation>
      65             : // </motivation>
      66             : //
      67             : // <templating arg=T>
      68             : //    <li>
      69             : //    <li>
      70             : // </templating>
      71             : //
      72             : // <thrown>
      73             : //    <li>
      74             : //    <li>
      75             : // </thrown>
      76             : //
      77             : // <todo asof="yyyy/mm/dd">
      78             : //   <li> add this feature
      79             : //   <li> fix this bug
      80             : //   <li> start discussion of this possible extension
      81             : // </todo>
      82             : 
      83             : class CCList
      84             : {
      85             : public:
      86             : 
      87             :   // vanilla constructor (npol=1, nComp=0)
      88             :   CCList();
      89             : 
      90             :   // more controlling constructor:
      91             :   // How many casacore::Stokes per flux casacore::Block?
      92             :   // How many spatial dimensions per position?
      93             :   // How many total components to allocate for?
      94             :   CCList(const casacore::uInt nPol, const casacore::uInt nDim=2, const casacore::uInt nComp=0);
      95             : 
      96             :   // copy constructor
      97             :   CCList(const CCList & other);
      98             : 
      99             :   // destructor
     100             :   ~CCList();
     101             : 
     102             :   // operator=
     103             :   CCList & operator=(const CCList & other);
     104             : 
     105             :   // get pointer to the casacore::Block<casacore::Int> which holds the CC's positions in pixel 
     106             :   // coordinates.  casacore::Block[nDim()*i] holds ith x, casacore::Block[nDim()*i+1] holds ith y
     107             :   // <group>
     108             :   casacore::Int * positionPtr();
     109             :   const casacore::Int * positionPtr() const;
     110             :   // </group>
     111             : 
     112             :   // get pointer to the whichCC'th component's position
     113             :   casacore::Int * pixelPosition(const casacore::uInt whichCC);
     114             : 
     115             :   // Get a pointer into the Position casacore::Block for the next free
     116             :   // clean component.
     117             :   // <group>
     118             :   casacore::Int * freePositionPtr();
     119             :   const casacore::Int * freePositionPtr() const;
     120             :   // </group>
     121             : 
     122             :   // get pointer to the casacore::Block<casacore::Float> which holds the CC's Flux.
     123             :   // The flux itself is a casacore::Block, as it may be 1, 2, or 4 Stokes.
     124             :   // casacore::Block[nPol()*i + iPol] holds the ith component's iPol Stokes.
     125             :   // <group>
     126             :   casacore::Float * fluxPtr();
     127             :   const casacore::Float * fluxPtr() const;
     128             :   // </group>
     129             : 
     130             :   // get pointer to the whichCC'th component's flux
     131             :   casacore::Float * pixelFlux(const casacore::uInt whichCC);
     132             : 
     133             :   // Get a pointer into the Flux casacore::Block for the next free
     134             :   // clean component.
     135             :   // <group>
     136             :   casacore::Float * freeFluxPtr();
     137             :   const casacore::Float * freeFluxPtr() const;
     138             :   // </group>
     139             : 
     140             :   // How many polarizations?
     141             :   casacore::uInt nPol() const;
     142             : 
     143             :   // How many dimentions?
     144             :   casacore::uInt nDim() const;
     145             : 
     146             :   // How many components have been filled into the list?
     147             :   // <group>
     148             :   casacore::uInt nComp() const;
     149             :   casacore::uInt & nComp();
     150             :   // </group>
     151             : 
     152             :   // How many components have been allocated for this list?
     153             :   casacore::uInt maxComp() const;
     154             : 
     155             :   // We have free space for how many more components?
     156             :   casacore::uInt freeComp() const;
     157             : 
     158             :   // Make the list bigger or smaller
     159             :   void resize(const casacore::uInt nComp);
     160             : 
     161             :   // add a Component; if not enough space, resize the storage blocks
     162             :   // to 2*maxComp()+1
     163             :   void addComp(const casacore::Block<casacore::Float> & flux, const casacore::Block<casacore::Int> & position);
     164             : 
     165             :   // casacore::Sort components to be organized by tile number.
     166             :   // If the position and Flux blocks have free space at the end, it gets cut off.
     167             :   void tiledSort(const casacore::IPosition & tileShape);
     168             : 
     169             :   // ok() is called to check for an internally consistent state
     170             :   // by most everything, often behind the scenes;  sometimes, 
     171             :   // the internal state is in flux
     172             :   // after a partial operation, and ok() fails; to turn off ok() checking,
     173             :   // set  itsSuspendOKCheck = true and remember to reset it to false
     174             :   // when the state-changing operation is complete.
     175             :   casacore::Bool ok() const;
     176             : private:
     177             : 
     178             :   // turn OFF error checking via "ok()"
     179             :   void suspendOKCheck();
     180             : 
     181             :   // turn ON error checking vua "ok()"
     182             :   void reactivateOKCheck();
     183             : 
     184             :   casacore::uInt itsPol;
     185             :   casacore::uInt itsDim;
     186             :   casacore::uInt itsComp; 
     187             :   casacore::Block<casacore::Float> itsFlux;
     188             :   casacore::Block<casacore::Int> itsPos;
     189             :   casacore::Bool itsSuspendOKCheck;
     190             : };
     191             : 
     192             : 
     193       27462 : inline casacore::uInt CCList::nPol() const {
     194       27462 :   DebugAssert(ok(), casacore::AipsError);
     195       27462 :   return itsPol;
     196             : };
     197             : 
     198     1053160 : inline casacore::uInt CCList::nDim() const {
     199     1053160 :   DebugAssert(ok(), casacore::AipsError);
     200     1053160 :   return itsDim;
     201             : };
     202             : 
     203        4100 : inline casacore::uInt CCList::nComp() const {
     204        4100 :   DebugAssert(ok(), casacore::AipsError);
     205        4100 :   return itsComp;
     206             : };
     207             : 
     208     2101181 : inline casacore::uInt & CCList::nComp() {
     209     2101181 :   DebugAssert(ok(), casacore::AipsError);
     210     2101181 :   return itsComp;
     211             : };
     212             : 
     213             : 
     214             : 
     215             : } //# NAMESPACE CASA - END
     216             : 
     217             : #endif
     218             : 
     219             : 

Generated by: LCOV version 1.16