casacore
ArrayColumn.h
Go to the documentation of this file.
1 //# ArrayColumn.h: access to an array table column with arbitrary data type
2 //# Copyright (C) 1994,1995,1996,1997,1998,2001
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: ArrayColumn.h 21521 2014-12-10 08:06:42Z gervandiepen $
27 
28 #ifndef TABLES_ARRAYCOLUMN_H
29 #define TABLES_ARRAYCOLUMN_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/casa/Arrays/Vector.h>
35 #include <casacore/tables/Tables/TableColumn.h>
36 #include <casacore/tables/Tables/TableError.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 class RefRows;
42 template<class T> class Array;
43 template<class T> class BaseSlicesFunctor;
44 class IPosition;
45 class Slice;
46 class Slicer;
47 class ColumnSlicer;
48 class String;
49 
50 
51 // <summary>
52 // Read and write access to an array table column with arbitrary data type
53 // </summary>
54 
55 // <use visibility=export>
56 
57 // <reviewed reviewer="dschieb" date="1994/08/10" tests="none">
58 // </reviewed>
59 
60 // <prerequisite>
61 // <li> Table
62 // <li> TableColumn
63 // </prerequisite>
64 
65 // <etymology>
66 // ArrayColumn<T> gives read and write access to an column in a table
67 // containing an array with data type T.
68 // </etymology>
69 
70 // <synopsis>
71 // The class ArrayColumn allows readonly access to a column
72 // containing arrays with an arbitrary data type. It can handle direct
73 // as well as indirect arrays.
74 // It is possible to get the data in an individual cell (i.e. table row);
75 // either the whole array or a slice of the array can be accessed.
76 // It is also possible to get the column as a whole if the arrays
77 // in all cells of the column have the same shape (which is always true
78 // for direct arrays). As in the case of individual cells it is possible
79 // to get the entire arrays or a slice of the arrays.
80 //
81 // A default constructor is defined to allow construction of an array
82 // of ArrayColumn objects. However, this constructs an object not
83 // referencing a column. Functions like get, etc. will fail (i.e. result
84 // in a segmentation fault) when used on such objects. The functions
85 // isNull and throwIfNull can be used to test on this.
86 // The functions attach and reference can fill in the object.
87 //
88 // The assignment operator is not defined for this class, because it was
89 // felt it would be too confusing. Instead the function reference can
90 // be used to do assignment with reference semantics. An assignment
91 // with copy semantics makes no sense for a readonly column.
92 // </synopsis>
93 
94 // <templating arg=T>
95 // <li> Default constructor
96 // <li> Copy constructor
97 // <li> Assignment operator
98 // </templating>
99 
100 // <example>
101 // See module <linkto module="Tables#open">Tables</linkto>.
102 // </example>
103 
104 
105 template<class T>
106 class ArrayColumn : public TableColumn
107 {
108 public:
109 
110  // The default constructor creates a null object, i.e. it
111  // does not reference a table column.
112  // The sole purpose of this constructor is to allow construction
113  // of an array of ArrayColumn objects.
114  // The functions reference and attach can be used to make a null object
115  // reference a column.
116  // Note that get functions, etc. will cause a segmentation fault
117  // when operating on a null object. It was felt it was too expensive
118  // to test on null over and over again. The user should use the isNull
119  // or throwIfNull function in case of doubt.
120  ArrayColumn();
121 
122  // Construct for the given column in the given table.
123  ArrayColumn (const Table&, const String& columnName);
124 
125  // Construct from the given table column.
126  // This constructor is useful if first a table column was constructed,
127  // its type is determined and thereafter used to construct the
128  // correct column object.
129  explicit ArrayColumn (const TableColumn&);
130 
131  // Copy constructor (reference semantics).
132  ArrayColumn (const ArrayColumn<T>&);
133 
134  ~ArrayColumn();
135 
136  // Clone the object.
137  virtual TableColumn* clone() const;
138 
139  // Assignment uses reference semantics, thus works the same
140  // as function reference.
142 
143  // Change the reference to another column.
144  // This is in fact an assignment operator with reference semantics.
145  // It removes the reference to the current column and creates
146  // a reference to the column referenced in the other object.
147  // It will handle null objects correctly.
148  void reference (const ArrayColumn<T>&);
149 
150  // Attach a column to the object.
151  // This is in fact only a shorthand for
152  // <br><src> reference (ArrayColumn<T> (table, columnName)); </src>
153  void attach (const Table& table, const String& columnName)
154  { reference (ArrayColumn<T> (table, columnName)); }
155 
156  // Get the #dimensions of an array in a particular cell.
157  // If the cell does not contain an array, 0 is returned.
158  // Use the function isDefined to test if the cell contains an array.
159  uInt ndim (uInt rownr) const
160  { TABLECOLUMNCHECKROW(rownr); return baseColPtr_p->ndim (rownr); }
161 
162  // Get the shape of an array in a particular cell.
163  // If the cell does not contain an array, a 0-dim shape is returned.
164  // Use the function isDefined to test if the cell contains an array.
165  IPosition shape (uInt rownr) const
166  { TABLECOLUMNCHECKROW(rownr); return baseColPtr_p->shape (rownr); }
167 
168  // Get the array value in a particular cell (i.e. table row).
169  // The row numbers count from 0 until #rows-1.
170  // <group>
171  // According to the assignment rules of class Array, the destination
172  // array must be empty or its shape must conform the table array shape.
173  // However, if the resize flag is set the destination array will be
174  // resized if not conforming.
175  void get (uInt rownr, Array<T>& array, Bool resize = False) const;
176  Array<T> get (uInt rownr) const;
177  Array<T> operator() (uInt rownr) const;
178  // </group>
179 
180  // Get a slice of an N-dimensional array in a particular cell
181  // (i.e. table row).
182  // The row numbers count from 0 until #rows-1.
183  // The dimensionality of the slice must match the dimensionality
184  // of the table array and the slice definition should not exceed
185  // the shape of the table array.
186  // <group>
187  // According to the assignment rules of class Array, the destination
188  // array must be empty or its shape must conform the shape of the
189  // table array slice.
190  // However, if the resize flag is set the destination array will be
191  // resized if not conforming.
192  void getSlice (uInt rownr, const Slicer& arraySection, Array<T>& array,
193  Bool resize = False) const;
194  Array<T> getSlice (uInt rownr, const Slicer& arraySection) const;
195  // </group>
196 
197  // Get an irregular slice of an N-dimensional array in a particular cell
198  // (i.e. table row) as given by the vectors of Slice objects.
199  // The outer vector represents the array axes.
200  // A missing or empty axis means the entire axis.
201  // The inner vector represents the slices to take for each axis.
202  // For example, to get slices from 2-dim arrays:
203  // <srcblock>
204  // Vector<Vector<Slice> > slices(2); // 2-dim
205  // slices[1].resize (3); // 3 slices in 2nd dim
206  // slices[1][0] = Slice(100,20);
207  // slices[1][1] = Slice(200,18);
208  // slices[1][2] = Slice(538,30,2);
209  // // Get data. Vector of first axis is empty, thus entire axis is read.
210  // Array<Complex> data = dataCol.getColumn (slices);
211  // </srcblock>
212  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
213  // with the last dimension representing the number of rows and the
214  // other dimensions representing the shape of the slice.
215  // The arrays in the column must have the same shape in all cells.
216  // <group>
217  // According to the assignment rules of class Array, the destination
218  // array must be empty or its shape must conform the resulting (n+1)-dim
219  // array.
220  // However, if the resize flag is set the destination array will be
221  // resized if not conforming.
222  void getSlice (uInt rownr,
223  const Vector<Vector<Slice> >& arraySlices,
224  Array<T>& arr, Bool resize = False) const;
225  Array<T> getSlice (uInt rownr,
226  const Vector<Vector<Slice> >& arraySlices) const;
227  // </group>
228 
229  // Get the array of all values in a column.
230  // If the column contains n-dim arrays, the resulting array is (n+1)-dim
231  // with the last dimension representing the number of rows.
232  // The arrays in the column must have the same shape in all cells.
233  // <group>
234  // According to the assignment rules of class Array, the destination
235  // array must be empty or its shape must conform the resulting (n+1)-dim
236  // array.
237  // However, if the resize flag is set the destination array will be
238  // resized if not conforming.
239  void getColumn (Array<T>& array, Bool resize = False) const;
240  Array<T> getColumn() const;
241  // </group>
242 
243  // Get regular slices from all arrays in the column.
244  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
245  // with the last dimension representing the number of rows and the
246  // other dimensions representing the shape of the slice.
247  // The arrays in the column must have the same shape in all cells.
248  // <group>
249  // According to the assignment rules of class Array, the destination
250  // array must be empty or its shape must conform the resulting (n+1)-dim
251  // array.
252  // However, if the resize flag is set the destination array will be
253  // resized if not conforming.
254  void getColumn (const Slicer& arraySection, Array<T>& array,
255  Bool resize = False) const;
256  Array<T> getColumn (const Slicer& arraySection) const;
257  // </group>
258 
259  // Get irregular slices from all arrays in the column as given by the
260  // vectors of Slice objects. The outer vector represents the array axes.
261  // A missing or empty axis means the entire axis.
262  // The inner vector represents the slices to take for each axis.
263  // For example, to get slices from 2-dim arrays:
264  // <srcblock>
265  // Vector<Vector<Slice> > slices(2); // 2-dim
266  // slices[1].resize (3); // 3 slices in 2nd dim
267  // slices[1][0] = Slice(100,20);
268  // slices[1][1] = Slice(200,18);
269  // slices[1][2] = Slice(538,30,2);
270  // // Get data. Vector of first axis is empty, thus entire axis is read.
271  // Array<Complex> data = dataCol.getColumn (slices);
272  // </srcblock>
273  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
274  // with the last dimension representing the number of rows and the
275  // other dimensions representing the shape of the slice.
276  // The arrays in the column must have the same shape in all cells.
277  // <group>
278  // According to the assignment rules of class Array, the destination
279  // array must be empty or its shape must conform the resulting (n+1)-dim
280  // array.
281  // However, if the resize flag is set the destination array will be
282  // resized if not conforming.
283  void getColumn (const Vector<Vector<Slice> >& arraySection, Array<T>& array,
284  Bool resize = False) const;
285  Array<T> getColumn (const Vector<Vector<Slice> >& arraySection) const;
286  // </group>
287 
288  // Get the array of some values in a column.
289  // The Slicer object can be used to specify start, end (or length),
290  // and stride of the rows to get.
291  // If the column contains n-dim arrays, the resulting array is (n+1)-dim
292  // with the last dimension representing the number of rows in the slicer.
293  // The arrays in the column must have the same shape in all those cells.
294  // According to the assignment rules of class Array, the destination
295  // array must be empty or its shape must conform the resulting (n+1)-dim
296  // array.
297  // However, if the resize flag is set the destination array will be
298  // resized if not conforming.
299  // <group>
300  void getColumnRange (const Slicer& rowRange, Array<T>& arr,
301  Bool resize = False) const;
302  Array<T> getColumnRange (const Slicer& rowRange) const;
303  void getColumnCells (const RefRows& rownrs, Array<T>& arr,
304  Bool resize = False) const;
305  Array<T> getColumnCells (const RefRows& rownrs) const;
306  // </group>
307 
308  // Get slices from some arrays in a column.
309  // The first Slicer object can be used to specify start, end (or length),
310  // and stride of the rows to get. The second Slicer object can be
311  // used to specify the slice to take from each array.
312  // If the column contains n-dim arrays, the resulting array is (n+1)-dim
313  // with the last dimension representing the number of rows in the slicer.
314  // The arrays in the column must have the same shape in all those cells.
315  // According to the assignment rules of class Array, the destination
316  // array must be empty or its shape must conform the resulting (n+1)-dim
317  // array.
318  // However, if the resize flag is set the destination array will be
319  // resized if not conforming.
320  // <group>
321  void getColumnRange (const Slicer& rowRange,
322  const Slicer& arraySection, Array<T>& arr,
323  Bool resize = False) const;
324  Array<T> getColumnRange (const Slicer& rowRange,
325  const Slicer& arraySection) const;
326  void getColumnCells (const RefRows& rownrs,
327  const Slicer& arraySection, Array<T>& arr,
328  Bool resize = False) const;
329  Array<T> getColumnCells (const RefRows& rownrs,
330  const Slicer& arraySection) const;
331  // </group>
332 
333  // Similar to getColumn (arraySlices, arr, resize) except it
334  // gets the slices for the given rows instead of all rows.
335  void getColumnCells (const RefRows& rows,
336  const ColumnSlicer & slicerSet,
337  Array<T>& destination,
338  Bool resize = False) const;
339 
340  // The get() function like above which does not check shapes, etc.
341  // It is faster and can be used for performance reasons if one
342  // knows for sure that the arguments are correct.
343  // E.g. it is used internally in virtual column engines.
344  void baseGet (uInt rownr, Array<T>& array) const
345  { baseColPtr_p->get (rownr, &array); }
346 
347  // Set the shape of the array in the given row.
348  // Setting the shape is needed if the array is put in slices,
349  // otherwise the table system would not know the shape.
350  // <group>
351  void setShape (uInt rownr, const IPosition& shape);
352 
353  // Try to store the array in a tiled way using the given tile shape.
354  void setShape (uInt rownr, const IPosition& shape,
355  const IPosition& tileShape);
356  // </group>
357 
358  // Put the array in a particular cell (i.e. table row).
359  // The row numbers count from 0 until #rows-1.
360  // If the shape of the table array in that cell has not already been
361  // defined, it will be defined implicitly.
362  void put (uInt rownr, const Array<T>& array);
363 
364  // Copy the value of a cell of that column to a cell of this column.
365  // The data types of both columns must be the same, otherwise an
366  // exception is thrown.
367  // <group>
368  // Use the same row numbers for both cells.
369  void put (uInt rownr, const ArrayColumn<T>& that)
370  { put (rownr, that, rownr); }
371  // Use possibly different row numbers for that (i.e. input) and
372  // and this (i.e. output) cell.
373  void put (uInt thisRownr, const ArrayColumn<T>& that, uInt thatRownr);
374  // </group>
375 
376  // Copy the value of a cell of that column to a cell of this column.
377  // This function uses a generic TableColumn object as input.
378  // The data types of both columns must be the same, otherwise an
379  // exception is thrown.
380  // <group>
381  // Use the same row numbers for both cells.
382  void put (uInt rownr, const TableColumn& that)
383  { put (rownr, that, rownr); }
384  // Use possibly different row numbers for that (i.e. input) and
385  // and this (i.e. output) cell.
386  void put (uInt thisRownr, const TableColumn& that, uInt thatRownr);
387  // </group>
388 
389  // Put into a slice of an N-dimensional array in a particular cell.
390  // The row numbers count from 0 until #rows-1.
391  // The shape of the table array must have been defined.
392  // The dimensionality of the slice must match the dimensionality
393  // of the table array and the slice definition should not exceed
394  // the shape of the table array.
395  void putSlice (uInt rownr, const Slicer& arraySection,
396  const Array<T>& array);
397 
398  void putSlice (uInt rownr, const Vector<Vector<Slice> >& arraySlices,
399  const Array<T>& arr);
400 
401  // Put the array of all values in the column.
402  // If the column contains n-dim arrays, the source array must be (n+1)-dim
403  // with the last dimension representing the number of rows.
404  void putColumn (const Array<T>& array);
405 
406  // Put into subsections of the table arrays in the entire column.
407  // If the column contains n-dim arrays, the source array is (n+1)-dim
408  // with the last dimension representing the number of rows and
409  // other dimensions representing the shape of the slice.
410  // The dimensionality of the slice must match the dimensionality
411  // of the table array, thus must be n-dim. Also the slice definition
412  // should not exceed the shape of the table arrays.
413  void putColumn (const Slicer& arraySection, const Array<T>& array);
414 
415  void putColumn (const Vector<Vector<Slice> >& arraySlices,
416  const Array<T>& arr);
417 
418  // Put the array of some values in the column.
419  // The Slicer object can be used to specify start, end (or length),
420  // and stride of the rows to put.
421  // If the column contains n-dim arrays, the source array must be (n+1)-dim
422  // with the last dimension representing the number of rows in the slicer.
423  // <group>
424  void putColumnRange (const Slicer& rowRange, const Array<T>& arr);
425  void putColumnCells (const RefRows& rownrs, const Array<T>& arr);
426  // </group>
427 
428  // Put into subsection of the table arrays in some rows of the column.
429  // The first Slicer object can be used to specify start, end (or length),
430  // and stride of the rows to put. The second Slicer object can be
431  // used to specify the slice to take from each array.
432  // If the column contains n-dim arrays, the source array must be (n+1)-dim
433  // with the last dimension representing the number of rows in the slicer.
434  // <group>
435  void putColumnRange (const Slicer& rowRange,
436  const Slicer& arraySection, const Array<T>& arr);
437  void putColumnCells (const RefRows& rownrs,
438  const Slicer& arraySection, const Array<T>& arr);
439  // </group>
440 
441  // Same as putColumn(arraySlices, arr) except that it puts for the given
442  // rows instead of all rows.
443  // <group>
444  void putColumnCells (const RefRows& rows,
445  const Vector<Vector<Slice> >& arraySlices,
446  const Array<T>& arr);
447  void putSliceFromRows (const RefRows& rows,
448  const Vector<Vector<Slice> >& arraySlices,
449  const Array<T>& source)
450  { putColumnCells (rows, arraySlices, source); }
451  void putColumnCells (const RefRows& rows,
452  const ColumnSlicer & columnSlicer,
453  const Array<T>& source);
454  // </group>
455 
456  // Put the same value in all cells of the column.
457  void fillColumn (const Array<T>& value);
458 
459  // Put the contents of a column with the same data type into this column.
460  // To put the contents of a column with a different data type into
461  // this column, the function TableColumn::putColumn can be used
462  // (provided the data type promotion is possible).
463  // In fact, this function is an assignment operator with copy semantics.
464  void putColumn (const ArrayColumn<T>& that);
465 
466  // The put() function like above which does not check shapes, etc.
467  // It is faster and can be used for performance reasons if one
468  // knows for sure that the arguments are correct.
469  // E.g. it is used internally in virtual column engines.
470  void basePut (uInt rownr, const Array<T>& array)
471  { baseColPtr_p->put (rownr, &array); }
472 
473 private:
474  // Check if the data type matches the column data type.
475  void checkDataType() const;
476 
477  // Check the shape of the array. If the array is empty or if
478  // <src>resize=True</src>, the array is resized if needed.
479  // An exception is thrown if not conforming.
480  void checkShape (const IPosition& shp,
481  Array<T>& arr, Bool resize,
482  const String& where) const;
483 
484 protected:
485  // A common function used by all functions that can get or put irregular
486  // array slices. The functor performs the get or put operation.
487  void handleSlices (const Vector<Vector<Slice> >& slices,
488  BaseSlicesFunctor<T>& functor,
489  const Slicer& slicer,
490  IPosition& arrEnd,
491  Array<T>& array) const;
492 
493  // Keep switches to determine if a slice or an entire column can
494  // be accessed or the change of an array can be changed.
495  // True = yes; False = no.
499  // Keep switches to know if access knowledge is permanent or has
500  // to be asked again the next time.
504 };
505 
507 
508 public:
509 
510  // Create a ColumnSlicer for use in one of the overloads of ArrayColumn::getColumnCells. That method
511  // takes a potentially complex select of data out of a column cell (e.g., multiple slices along each
512  // axis) and then puts them into a selection of a destination array. This is most easily represnted
513  // as a set of source,destination slicers where one is applied to the cell and the other to the
514  // destination array.
515  //
516  // The shape paramter is the shape of the destination excluding the row axis.
517  //
518  //
519  //
520  // The Slicer objects provided (by pointer) will be owned by the ColumnSlicer object which will
521  // delete them in its destructor.
522 
523 
524  ColumnSlicer (const IPosition & shape, Vector<Slicer *> dataSlicers, Vector<Slicer *> destinationSlicers)
525  : dataSlicers_p (dataSlicers),
526  destinationSlicers_p (destinationSlicers),
527  shape_p (shape)
528  {
529  String message = validateParameters ();
530  if (! message.empty()){
531 
532  freeSlicers(); // Call gave them to us; set them free.
533 
534  throw AipsError (String ("ColumnSlicer (ctor):: ") + message);
535  }
536  }
537 
538  // Kill off the Slicer objects.
539 
541 
542  freeSlicers();
543  }
544 
545  // Accessor that returns the dataSlicers.
546 
548  {
549  return dataSlicers_p;
550  }
551 
552  // Accessor that returns the desintation slicers
553 
555  {
556  return destinationSlicers_p;
557  }
558 
559  // Accessor that returns the shape.
560 
561  const IPosition & shape () const
562  {
563  return shape_p;
564  }
565 
566 private:
567 
568  void freeSlicers ()
569  {
570  // The two Vectors contain pointers to objects so they need to be freed.
571  // They should have the same length normally, but during validation it's
572  // possible that they have different lengths.
573 
574  for (uInt i = 0; i < dataSlicers_p.size(); i++){
575  delete dataSlicers_p [i];
576  }
577 
578  for (uInt i = 0; i < destinationSlicers_p.size(); i++){
579  delete destinationSlicers_p [i];
580  }
581  }
582 
584  {
585  // Validate the contruction parameters to see if they are consistent.
586 
587  if (dataSlicers_p.size() != destinationSlicers_p.size()){
588  return String::format ("Number of data slicers (%d) and destination slicers (%d) "
589  "must match", dataSlicers_p.size(), destinationSlicers_p.size());
590  }
591 
592  if (dataSlicers_p.size() == 0){
593  return String::format ("At least one destination and one data slicer required.");
594  }
595 
596  for (uInt i = 0; i < dataSlicers_p.size(); i++){
597 
598  if (dataSlicers_p[i]->length() != destinationSlicers_p[i]->length()){
599 
600  return String::format ("Length of data slicer[%d] (%s) and "
601  "destination slicer [%d] (%s) must be equal",
602  i, dataSlicers_p[i]->length().toString().c_str(),
603  i, destinationSlicers_p[i]->length().toString().c_str());
604  }
605  }
606 
607  return String();
608  }
609 
613 };
614 
615 
616 //# Explicitly instantiate these templates in ArrayColumn_tmpl.cc
617 #ifdef AIPS_CXX11
618  extern template class ArrayColumn<Bool>;
619  extern template class ArrayColumn<Char>;
620  extern template class ArrayColumn<Short>;
621  extern template class ArrayColumn<uShort>;
622  extern template class ArrayColumn<Int>;
623  extern template class ArrayColumn<uInt>;
624  extern template class ArrayColumn<Float>;
625  extern template class ArrayColumn<Double>;
626  extern template class ArrayColumn<Complex>;
627  extern template class ArrayColumn<DComplex>;
628  extern template class ArrayColumn<String>;
629 #endif
630 
631 
632 } //# NAMESPACE CASACORE - END
633 
634 
635 //# Make old name ROArrayColumn still available.
636 #define ROArrayColumn ArrayColumn
637 
638 
639 #ifndef CASACORE_NO_AUTO_TEMPLATES
640 #include <casacore/tables/Tables/ArrayColumn.tcc>
641 #endif //# CASACORE_NO_AUTO_TEMPLATES
642 #endif
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
virtual IPosition shape(uInt rownr) const
Get the shape of an array in a particular cell.
void getSlice(uInt rownr, const Slicer &arraySection, Array< T > &array, Bool resize=False) const
Get a slice of an N-dimensional array in a particular cell (i.e.
A 1-D Specialization of the Array class.
Definition: ArrayIO.h:45
#define TABLECOLUMNCHECKROW(ROWNR)
Definition: TableColumn.h:51
const Vector< Slicer * > & getDestinationSlicers() const
Accessor that returns the desintation slicers.
Definition: ArrayColumn.h:554
ArrayColumn< T > & operator=(const ArrayColumn< T > &)
Assignment uses reference semantics, thus works the same as function reference.
Array< T > getColumn() const
Main interface class to a read/write table.
Definition: Table.h:149
void put(uInt rownr, const TableColumn &that)
Copy the value of a cell of that column to a cell of this column.
Definition: ArrayColumn.h:382
ColumnSlicer(const IPosition &shape, Vector< Slicer * > dataSlicers, Vector< Slicer * > destinationSlicers)
Create a ColumnSlicer for use in one of the overloads of ArrayColumn::getColumnCells.
Definition: ArrayColumn.h:524
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition: ExprNode.h:1986
void checkDataType() const
Check if the data type matches the column data type.
Vector< Slicer * > dataSlicers_p
Definition: ArrayColumn.h:610
void put(uInt rownr, const Array< T > &array)
Put the array in a particular cell (i.e.
IPosition shape(uInt rownr) const
Get the shape of an array in a particular cell.
Definition: ArrayColumn.h:165
void reference(const ArrayColumn< T > &)
Change the reference to another column.
void baseGet(uInt rownr, Array< T > &array) const
The get() function like above which does not check shapes, etc.
Definition: ArrayColumn.h:344
void putColumn(const Array< T > &array)
Put the array of all values in the column.
Bool canAccessSlice_p
Keep switches to determine if a slice or an entire column can be accessed or the change of an array c...
Definition: ArrayColumn.h:496
const Vector< Slicer * > & getDataSlicers() const
Accessor that returns the dataSlicers.
Definition: ArrayColumn.h:547
BaseColumn * baseColPtr_p
Definition: TableColumn.h:378
Vector< Slicer * > destinationSlicers_p
Definition: ArrayColumn.h:611
Table table() const
Get the Table object this column belongs to.
uInt ndim(uInt rownr) const
Get the #dimensions of an array in a particular cell.
Definition: ArrayColumn.h:159
Array< T > operator()(uInt rownr) const
~ColumnSlicer()
Kill off the Slicer objects.
Definition: ArrayColumn.h:540
define a (start,length,increment) along an axis
Definition: Slice.h:93
ArrayColumn()
The default constructor creates a null object, i.e.
void putSliceFromRows(const RefRows &rows, const Vector< Vector< Slice > > &arraySlices, const Array< T > &source)
Definition: ArrayColumn.h:447
Bool reaskAccessSlice_p
Keep switches to know if access knowledge is permanent or has to be asked again the next time...
Definition: ArrayColumn.h:501
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
Class holding the row numbers in a RefTable.
Definition: RefRows.h:85
void handleSlices(const Vector< Vector< Slice > > &slices, BaseSlicesFunctor< T > &functor, const Slicer &slicer, IPosition &arrEnd, Array< T > &array) const
A common function used by all functions that can get or put irregular array slices.
String toString(const SubScanKey &subScanKey)
void putSlice(uInt rownr, const Slicer &arraySection, const Array< T > &array)
Put into a slice of an N-dimensional array in a particular cell.
void putColumnRange(const Slicer &rowRange, const Array< T > &arr)
Put the array of some values in the column.
void fillColumn(const Array< T > &value)
Put the same value in all cells of the column.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
void attach(const Table &table, const String &columnName)
Attach a column to the object.
Definition: ArrayColumn.h:153
Read and write access to an array table column with arbitrary data type.
Definition: CopyRecord.h:48
Read/write access to a table column.
Definition: TableColumn.h:98
static String format(const char *picture,...)
Create a formatted string using the given printf format string.
void basePut(uInt rownr, const Array< T > &array)
The put() function like above which does not check shapes, etc.
Definition: ArrayColumn.h:470
void setShape(uInt rownr, const IPosition &shape)
Set the shape of the array in the given row.
const Bool False
Definition: aipstype.h:41
friend LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
template <class T, class U> class vector;
Definition: Array.h:169
void put(uInt rownr, const ArrayColumn< T > &that)
Copy the value of a cell of that column to a cell of this column.
Definition: ArrayColumn.h:369
void putColumnCells(const RefRows &rownrs, const Array< T > &arr)
void getColumnCells(const RefRows &rownrs, Array< T > &arr, Bool resize=False) const
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:275
Base class for all Casacore library errors.
Definition: Error.h:135
virtual void get(uInt rownr, void *dataPtr) const =0
Get the value from a particular cell.
void getColumnRange(const Slicer &rowRange, Array< T > &arr, Bool resize=False) const
Get the array of some values in a column.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual TableColumn * clone() const
Clone the object.
Abstract baseclass for slices functors.
Definition: ArrayColumn.h:43
const IPosition & shape() const
Accessor that returns the shape.
Definition: ArrayColumn.h:561
void checkShape(const IPosition &shp, Array< T > &arr, Bool resize, const String &where) const
Check the shape of the array.
virtual void put(uInt rownr, const void *dataPtr)=0
Put the value in a particular cell.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
unsigned int uInt
Definition: aipstype.h:48
Bool empty() const
Test for empty.
Definition: String.h:375
virtual uInt ndim(uInt rownr) const
Get the #dimensions of an array in a particular cell.