casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CCList.h
Go to the documentation of this file.
00001 //# CCList.h:
00002 //# Copyright (C) 1998,1999
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 //# $Id$
00028 
00029 #ifndef SYNTHESIS_CCLIST_H
00030 #define SYNTHESIS_CCLIST_H
00031 
00032 
00033 #include <casa/aips.h>
00034 #include <casa/Containers/Block.h>
00035 #include <casa/Arrays/IPosition.h>
00036 #include <casa/Exceptions/Error.h>
00037 #include <casa/Utilities/Assert.h>
00038 #include <casa/Utilities/GenSort.h>
00039 namespace casa { //# NAMESPACE CASA - BEGIN
00040 
00041 // <summary>
00042 // </summary>
00043 
00044 // <use visibility=local>   or   <use visibility=export>
00045 
00046 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00047 // </reviewed>
00048 
00049 // <prerequisite>
00050 //   <li> SomeClass
00051 //   <li> SomeOtherClass
00052 //   <li> some concept
00053 // </prerequisite>
00054 //
00055 // <etymology>
00056 // </etymology>
00057 //
00058 // <synopsis>
00059 // </synopsis>
00060 //
00061 // <example>
00062 // </example>
00063 //
00064 // <motivation>
00065 // </motivation>
00066 //
00067 // <templating arg=T>
00068 //    <li>
00069 //    <li>
00070 // </templating>
00071 //
00072 // <thrown>
00073 //    <li>
00074 //    <li>
00075 // </thrown>
00076 //
00077 // <todo asof="yyyy/mm/dd">
00078 //   <li> add this feature
00079 //   <li> fix this bug
00080 //   <li> start discussion of this possible extension
00081 // </todo>
00082 
00083 class CCList
00084 {
00085 public:
00086 
00087   // vanilla constructor (npol=1, nComp=0)
00088   CCList();
00089 
00090   // more controlling constructor:
00091   // How many Stokes per flux Block?
00092   // How many spatial dimensions per position?
00093   // How many total components to allocate for?
00094   CCList(const uInt nPol, const uInt nDim=2, const uInt nComp=0);
00095 
00096   // copy constructor
00097   CCList(const CCList & other);
00098 
00099   // destructor
00100   ~CCList();
00101 
00102   // operator=
00103   CCList & operator=(const CCList & other);
00104 
00105   // get pointer to the Block<Int> which holds the CC's positions in pixel 
00106   // coordinates.  Block[nDim()*i] holds ith x, Block[nDim()*i+1] holds ith y
00107   // <group>
00108   Int * positionPtr();
00109   const Int * positionPtr() const;
00110   // </group>
00111 
00112   // get pointer to the whichCC'th component's position
00113   Int * pixelPosition(const uInt whichCC);
00114 
00115   // Get a pointer into the Position Block for the next free
00116   // clean component.
00117   // <group>
00118   Int * freePositionPtr();
00119   const Int * freePositionPtr() const;
00120   // </group>
00121 
00122   // get pointer to the Block<Float> which holds the CC's Flux.
00123   // The flux itself is a Block, as it may be 1, 2, or 4 Stokes.
00124   // Block[nPol()*i + iPol] holds the ith component's iPol Stokes.
00125   // <group>
00126   Float * fluxPtr();
00127   const Float * fluxPtr() const;
00128   // </group>
00129 
00130   // get pointer to the whichCC'th component's flux
00131   Float * pixelFlux(const uInt whichCC);
00132 
00133   // Get a pointer into the Flux Block for the next free
00134   // clean component.
00135   // <group>
00136   Float * freeFluxPtr();
00137   const Float * freeFluxPtr() const;
00138   // </group>
00139 
00140   // How many polarizations?
00141   uInt nPol() const;
00142 
00143   // How many dimentions?
00144   uInt nDim() const;
00145 
00146   // How many components have been filled into the list?
00147   // <group>
00148   uInt nComp() const;
00149   uInt & nComp();
00150   // </group>
00151 
00152   // How many components have been allocated for this list?
00153   uInt maxComp() const;
00154 
00155   // We have free space for how many more components?
00156   uInt freeComp() const;
00157 
00158   // Make the list bigger or smaller
00159   void resize(const uInt nComp);
00160 
00161   // add a Component; if not enough space, resize the storage blocks
00162   // to 2*maxComp()+1
00163   void addComp(const Block<Float> & flux, const Block<Int> & position);
00164 
00165   // Sort components to be organized by tile number.
00166   // If the position and Flux blocks have free space at the end, it gets cut off.
00167   void tiledSort(const IPosition & tileShape);
00168 
00169   // ok() is called to check for an internally consistent state
00170   // by most everything, often behind the scenes;  sometimes, 
00171   // the internal state is in flux
00172   // after a partial operation, and ok() fails; to turn off ok() checking,
00173   // set  itsSuspendOKCheck = True and remember to reset it to False
00174   // when the state-changing operation is complete.
00175   Bool ok() const;
00176 private:
00177 
00178   // turn OFF error checking via "ok()"
00179   void suspendOKCheck();
00180 
00181   // turn ON error checking vua "ok()"
00182   void reactivateOKCheck();
00183 
00184   uInt itsPol;
00185   uInt itsDim;
00186   uInt itsComp; 
00187   Block<Float> itsFlux;
00188   Block<Int> itsPos;
00189   Bool itsSuspendOKCheck;
00190 };
00191 
00192 
00193 inline uInt CCList::nPol() const {
00194   DebugAssert(ok(), AipsError);
00195   return itsPol;
00196 };
00197 
00198 inline uInt CCList::nDim() const {
00199   DebugAssert(ok(), AipsError);
00200   return itsDim;
00201 };
00202 
00203 inline uInt CCList::nComp() const {
00204   DebugAssert(ok(), AipsError);
00205   return itsComp;
00206 };
00207 
00208 inline uInt & CCList::nComp() {
00209   DebugAssert(ok(), AipsError);
00210   return itsComp;
00211 };
00212 
00213 
00214 
00215 } //# NAMESPACE CASA - END
00216 
00217 #endif
00218 
00219