From 98cd331cf0bafc8c68801a1509a8311e59635bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Tue, 6 Oct 2026 10:40:09 +0200 Subject: [PATCH 1/4] Make compatible with casacore 3.8.2 --- CMakeLists.txt | 2 +- include/LofarStMan/LofarColumn.h | 86 ++++----- include/LofarStMan/LofarStMan.h | 99 +++++----- src/LofarColumn.cc | 210 ++++++++++---------- src/LofarStMan.cc | 146 +++++++------- test/tIOPerf.cc | 322 +++++++++++++++---------------- test/tLofarStMan.cc | 242 +++++++++++------------ test/tfix.cc | 6 +- 8 files changed, 557 insertions(+), 556 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e085f13..d0b1e00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # $Id: CMakeLists.txt 14280 2009-10-16 13:48:46Z loose $ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.10) project(LofarStMan VERSION 1.0.2) diff --git a/include/LofarStMan/LofarColumn.h b/include/LofarStMan/LofarColumn.h index 024890a..61bf08b 100644 --- a/include/LofarStMan/LofarColumn.h +++ b/include/LofarStMan/LofarColumn.h @@ -64,11 +64,11 @@ class LofarColumn : public casacore::StManColumn : StManColumn (dtype), itsParent (parent) {} - virtual ~LofarColumn(); + ~LofarColumn() override; // Most columns are not writable (only DATA is writable). - virtual casacore::Bool isWritable() const; + bool isWritable() const override; // Set column shape of fixed shape columns; it does nothing. - virtual void setShapeColumn (const casacore::IPosition& shape); + void setShapeColumn (const casacore::IPosition& shape) final override; // Prepare the column. By default it does nothing. virtual void prepareCol(); protected: @@ -77,50 +77,50 @@ class LofarColumn : public casacore::StManColumn // ANTENNA1 column in the LOFAR Storage Manager. // -class Ant1Column : public LofarColumn +class Ant1Column final : public LofarColumn { public: explicit Ant1Column (LofarStMan* parent, int dtype) : LofarColumn(parent, dtype) {} - virtual ~Ant1Column(); - virtual void getIntV (casacore::uInt rowNr, casacore::Int* dataPtr); + ~Ant1Column() override; + void getIntV (unsigned int rowNr, int* dataPtr) override; }; // ANTENNA2 column in the LOFAR Storage Manager. // -class Ant2Column : public LofarColumn +class Ant2Column final : public LofarColumn { public: explicit Ant2Column (LofarStMan* parent, int dtype) : LofarColumn(parent, dtype) {} - virtual ~Ant2Column(); - virtual void getIntV (casacore::uInt rowNr, casacore::Int* dataPtr); + ~Ant2Column() override; + void getIntV (unsigned int rowNr, int* dataPtr) override; }; // TIME and TIME_CENTROID column in the LOFAR Storage Manager. // -class TimeColumn : public LofarColumn +class TimeColumn final : public LofarColumn { public: explicit TimeColumn (LofarStMan* parent, int dtype) : LofarColumn(parent, dtype) {} - virtual ~TimeColumn(); - virtual void getdoubleV (casacore::uInt rowNr, casacore::Double* dataPtr); + ~TimeColumn() override; + void getdoubleV (unsigned int rowNr, double* dataPtr) override; private: - casacore::Double itsValue; + double itsValue; }; // INTERVAL and EXPOSURE column in the LOFAR Storage Manager. // -class IntervalColumn : public LofarColumn +class IntervalColumn final : public LofarColumn { public: explicit IntervalColumn (LofarStMan* parent, int dtype) : LofarColumn(parent, dtype) {} - virtual ~IntervalColumn(); - virtual void getdoubleV (casacore::uInt rowNr, casacore::Double* dataPtr); + ~IntervalColumn() override; + void getdoubleV (unsigned int rowNr, double* dataPtr) override; private: - casacore::Double itsValue; + double itsValue; }; // All columns in the LOFAR Storage Manager with value 0. @@ -131,12 +131,12 @@ class ZeroColumn : public LofarColumn explicit ZeroColumn (LofarStMan* parent, int dtype) : LofarColumn(parent, dtype) {} virtual ~ZeroColumn(); - virtual void getIntV (casacore::uInt rowNr, casacore::Int* dataPtr); + virtual void getIntV (unsigned int rowNr, int* dataPtr); private: - casacore::Int itsValue; + int itsValue; }; -// All columns in the LOFAR Storage Manager with value False. +// All columns in the LOFAR Storage Manager with value false. // class FalseColumn : public LofarColumn { @@ -144,9 +144,9 @@ class FalseColumn : public LofarColumn explicit FalseColumn (LofarStMan* parent, int dtype) : LofarColumn(parent, dtype) {} virtual ~FalseColumn(); - virtual void getBoolV (casacore::uInt rowNr, casacore::Bool* dataPtr); + virtual void getBoolV (unsigned int rowNr, bool* dataPtr); private: - casacore::Bool itsValue; + bool itsValue; }; // UVW column in the LOFAR Storage Manager. @@ -157,9 +157,9 @@ class UvwColumn : public LofarColumn explicit UvwColumn (LofarStMan* parent, int dtype) : LofarColumn(parent, dtype) {} virtual ~UvwColumn(); - virtual casacore::IPosition shape (casacore::uInt rownr); - virtual void getArraydoubleV (casacore::uInt rowNr, - casacore::Array* dataPtr); + virtual casacore::IPosition shape (unsigned int rownr); + virtual void getArraydoubleV (unsigned int rowNr, + casacore::Array* dataPtr); virtual void prepareCol(); private: casacore::MDirection itsPhaseDir; //# could be SUN, etc. @@ -180,11 +180,11 @@ class DataColumn : public LofarColumn explicit DataColumn (LofarStMan* parent, int dtype) : LofarColumn(parent, dtype) {} virtual ~DataColumn(); - virtual casacore::Bool isWritable() const; - virtual casacore::IPosition shape (casacore::uInt rownr); - virtual void getArrayComplexV (casacore::uInt rowNr, + virtual bool isWritable() const; + virtual casacore::IPosition shape (unsigned int rownr); + virtual void getArrayComplexV (unsigned int rowNr, casacore::Array* dataPtr); - virtual void putArrayComplexV (casacore::uInt rowNr, + virtual void putArrayComplexV (unsigned int rowNr, const casacore::Array* dataPtr); }; @@ -196,9 +196,9 @@ class FlagColumn : public LofarColumn explicit FlagColumn (LofarStMan* parent, int dtype) : LofarColumn(parent, dtype) {} virtual ~FlagColumn(); - virtual casacore::IPosition shape (casacore::uInt rownr); - virtual void getArrayBoolV (casacore::uInt rowNr, - casacore::Array* dataPtr); + virtual casacore::IPosition shape (unsigned int rownr); + virtual void getArrayBoolV (unsigned int rowNr, + casacore::Array* dataPtr); }; // WEIGHT column in the LOFAR Storage Manager. @@ -209,9 +209,9 @@ class WeightColumn : public LofarColumn explicit WeightColumn (LofarStMan* parent, int dtype) : LofarColumn(parent, dtype) {} virtual ~WeightColumn(); - virtual casacore::IPosition shape (casacore::uInt rownr); - virtual void getArrayfloatV (casacore::uInt rowNr, - casacore::Array* dataPtr); + virtual casacore::IPosition shape (unsigned int rownr); + virtual void getArrayfloatV (unsigned int rowNr, + casacore::Array* dataPtr); }; // SIGMA column in the LOFAR Storage Manager. @@ -222,9 +222,9 @@ class SigmaColumn : public LofarColumn explicit SigmaColumn (LofarStMan* parent, int dtype) : LofarColumn(parent, dtype) {} virtual ~SigmaColumn(); - virtual casacore::IPosition shape (casacore::uInt rownr); - virtual void getArrayfloatV (casacore::uInt rowNr, - casacore::Array* dataPtr); + virtual casacore::IPosition shape (unsigned int rownr); + virtual void getArrayfloatV (unsigned int rowNr, + casacore::Array* dataPtr); }; // WEIGHT_SPECTRUM column in the LOFAR Storage Manager. @@ -235,9 +235,9 @@ class WSpectrumColumn : public LofarColumn explicit WSpectrumColumn (LofarStMan* parent, int dtype) : LofarColumn(parent, dtype) {} virtual ~WSpectrumColumn(); - virtual casacore::IPosition shape (casacore::uInt rownr); - virtual void getArrayfloatV (casacore::uInt rowNr, - casacore::Array* dataPtr); + virtual casacore::IPosition shape (unsigned int rownr); + virtual void getArrayfloatV (unsigned int rowNr, + casacore::Array* dataPtr); }; // FLAG_CATEGORY column in the LOFAR Storage Manager. @@ -248,8 +248,8 @@ class FlagCatColumn : public LofarColumn explicit FlagCatColumn (LofarStMan* parent, int dtype) : LofarColumn(parent, dtype) {} virtual ~FlagCatColumn(); - virtual casacore::Bool isShapeDefined (casacore::uInt rownr); - virtual casacore::IPosition shape (casacore::uInt rownr); + virtual bool isShapeDefined (unsigned int rownr); + virtual casacore::IPosition shape (unsigned int rownr); }; diff --git a/include/LofarStMan/LofarStMan.h b/include/LofarStMan/LofarStMan.h index 321176d..91c47b1 100644 --- a/include/LofarStMan/LofarStMan.h +++ b/include/LofarStMan/LofarStMan.h @@ -29,6 +29,7 @@ #include #include +#include #include namespace LOFAR { @@ -113,7 +114,7 @@ class LofarColumn; //# -class LofarStMan : public casacore::DataManager +class LofarStMan final : public casacore::DataManager { public: // Create a Lofar storage manager with the given name. @@ -127,35 +128,35 @@ class LofarStMan : public casacore::DataManager ~LofarStMan(); // Clone this object. - virtual casacore::DataManager* clone() const; + virtual casacore::DataManager* clone() const override; // Get the type name of the data manager (i.e. LofarStMan). - virtual casacore::String dataManagerType() const; + virtual casacore::String dataManagerType() const override; // Get the name given to the storage manager (in the constructor). - virtual casacore::String dataManagerName() const; + virtual casacore::String dataManagerName() const override; // Record a record containing data manager specifications. - virtual casacore::Record dataManagerSpec() const; + virtual casacore::Record dataManagerSpec() const override; // Get the number of rows in this storage manager. unsigned int getNRow() const { return itsNrRows; } // The storage manager is not a regular one. - virtual casacore::Bool isRegular() const; + bool isRegular() const override; // The storage manager cannot add rows. - virtual casacore::Bool canAddRow() const; + bool canAddRow() const override; // The storage manager cannot delete rows. - virtual casacore::Bool canRemoveRow() const; + bool canRemoveRow() const override; // The storage manager can add columns, which does not really do something. - virtual casacore::Bool canAddColumn() const; + bool canAddColumn() const override; // Columns can be removed, but it does not do anything at all. - virtual casacore::Bool canRemoveColumn() const; + bool canRemoveColumn() const override; // Make the object from the type name string. // This function gets registered in the DataManager "constructor" map. @@ -186,9 +187,9 @@ class LofarStMan : public casacore::DataManager void getData (unsigned int rownr, casacore::Complex* buf); void putData (unsigned int rownr, const casacore::Complex* buf); - const casacore::uChar* getNSample1 (unsigned int rownr, bool swapIfNeeded); - const casacore::uShort* getNSample2 (unsigned int rownr, bool swapIfNeeded); - const casacore::uInt* getNSample4 (unsigned int rownr, bool swapIfNeeded); + const unsigned char* getNSample1 (unsigned int rownr, bool swapIfNeeded); + const unsigned short* getNSample2 (unsigned int rownr, bool swapIfNeeded); + const unsigned int* getNSample4 (unsigned int rownr, bool swapIfNeeded); // unsigned int getLofarStManVersion() const @@ -205,70 +206,70 @@ class LofarStMan : public casacore::DataManager LofarStMan& operator= (const LofarStMan& that); // Flush and optionally fsync the data. - // It does nothing, and returns False. - virtual casacore::Bool flush (casacore::AipsIO&, casacore::Bool doFsync); + // It does nothing, and returns false. + bool flush (casacore::AipsIO&, bool doFsync) override; // Let the storage manager create files as needed for a new table. // This allows a column with an indirect array to create its file. - virtual void create (casacore::uInt nrrow); + void create (unsigned int nrrow) override; // Open the storage manager file for an existing table. // Return the number of rows in the data file. // - virtual void open (casacore::uInt nrrow, casacore::AipsIO&); //# should never be called - virtual casacore::uInt open1 (casacore::uInt nrrow, casacore::AipsIO&); + void open (unsigned int nrrow, casacore::AipsIO&) override; //# should never be called + unsigned int open1 (unsigned int nrrow, casacore::AipsIO&) override; // // Prepare the columns (needed for UvwColumn). - virtual void prepare(); + void prepare() override; // Resync the storage manager with the new file contents. // It does nothing. // - virtual void resync (casacore::uInt nrrow); //# should never be called - virtual casacore::uInt resync1 (casacore::uInt nrrow); + void resync (unsigned int nrrow) override; //# should never be called + unsigned int resync1 (unsigned int nrrow) override; // // Reopen the storage manager files for read/write. // It does nothing. - virtual void reopenRW(); + void reopenRW() override; // The data manager will be deleted (because all its columns are // requested to be deleted). // So clean up the things needed (e.g. delete files). - virtual void deleteManager(); + void deleteManager() override; // Add rows to the storage manager. // It cannot do it, so throws an exception. - virtual void addRow (casacore::uInt nrrow); + void addRow (unsigned int nrrow) override; // Delete a row from all columns. // It cannot do it, so throws an exception. - virtual void removeRow (casacore::uInt rowNr); + void removeRow (unsigned int rowNr) override; // Do the final addition of a column. // It won't do anything. - virtual void addColumn (casacore::DataManagerColumn*); + void addColumn (casacore::DataManagerColumn*) override; // Remove a column from the data file. // It won't do anything. - virtual void removeColumn (casacore::DataManagerColumn*); + void removeColumn (casacore::DataManagerColumn*) override; // Create a column in the storage manager on behalf of a table column. // The caller has to delete the newly created object. // // Create a scalar column. - virtual casacore::DataManagerColumn* makeScalarColumn (const casacore::String& aName, + casacore::DataManagerColumn* makeScalarColumn (const casacore::String& aName, int aDataType, - const casacore::String& aDataTypeID); + const casacore::String& aDataTypeID) override; // Create a direct array column. - virtual casacore::DataManagerColumn* makeDirArrColumn (const casacore::String& aName, + casacore::DataManagerColumn* makeDirArrColumn (const casacore::String& aName, int aDataType, - const casacore::String& aDataTypeID); + const casacore::String& aDataTypeID) override; // Create an indirect array column. - virtual casacore::DataManagerColumn* makeIndArrColumn (const casacore::String& aName, + casacore::DataManagerColumn* makeIndArrColumn (const casacore::String& aName, int aDataType, - const casacore::String& aDataTypeID); + const casacore::String& aDataTypeID) override; // // Initialize by reading the header info. @@ -287,29 +288,29 @@ class LofarStMan : public casacore::DataManager void closeFiles(); // Get a pointer to data to be read. - const void* getReadPointer (casacore::uInt blocknr, casacore::uInt offset, - casacore::uInt size) + const void* getReadPointer (unsigned int blocknr, unsigned int offset, + unsigned int size) { return readFile (blocknr, offset, size); } // Get a pointer where data can be written. - void* getWritePointer (casacore::uInt /*blocknr*/, casacore::uInt /*offset*/, - casacore::uInt size) + void* getWritePointer (unsigned int /*blocknr*/, unsigned int /*offset*/, + unsigned int size) { return getBuffer (size); } // Write the data. It is a no-op if mmap is used. - void writeData (casacore::uInt blocknr, casacore::uInt offset, casacore::uInt size) + void writeData (unsigned int blocknr, unsigned int offset, unsigned int size) { writeFile (blocknr, offset, size); } // Read or write the data for regular files. - void* readFile (casacore::uInt blocknr, casacore::uInt offset, casacore::uInt size); - void* getBuffer (casacore::uInt size); - void writeFile (casacore::uInt blocknr, casacore::uInt offset, casacore::uInt size); + void* readFile (unsigned int blocknr, unsigned int offset, unsigned int size); + void* getBuffer (unsigned int size); + void writeFile (unsigned int blocknr, unsigned int offset, unsigned int size); //# Declare member variables. @@ -334,15 +335,15 @@ class LofarStMan : public casacore::DataManager casacore::Block itsBuffer; //# buffer of size itsBLDataSize for regular IO // The seqnr file (if present) is always memory-mapped because it is small. casacore::MMapIO* itsSeqFile; - bool itsDoSwap; //# True = byte-swapping is needed - long long itsBlockSize; //# size of a block containing a seqnr - long long itsBLDataSize; //# data size of a single baseline - long long itsDataStart; //# start of data in a block - long long itsSampStart; //# start of nsamples in a block + bool itsDoSwap; //# true = byte-swapping is needed + int64_t itsBlockSize; //# size of a block containing a seqnr + int64_t itsBLDataSize; //# data size of a single baseline + int64_t itsDataStart; //# start of data in a block + int64_t itsSampStart; //# start of nsamples in a block //# Buffer to hold nsample values. - casacore::Block itsNSampleBuf1; - casacore::Block itsNSampleBuf2; - casacore::Block itsNSampleBuf4; + casacore::Block itsNSampleBuf1; + casacore::Block itsNSampleBuf2; + casacore::Block itsNSampleBuf4; double itsMaxNrSample; //# weight = nsample / itsMaxNrSample; casacore::Record itsSpec; diff --git a/src/LofarColumn.cc b/src/LofarColumn.cc index 3b523f9..2592a8e 100644 --- a/src/LofarColumn.cc +++ b/src/LofarColumn.cc @@ -47,9 +47,9 @@ namespace LOFAR { LofarColumn::~LofarColumn() {} - Bool LofarColumn::isWritable() const + bool LofarColumn::isWritable() const { - return False; + return false; } void LofarColumn::setShapeColumn (const IPosition&) {} @@ -58,12 +58,12 @@ namespace LOFAR { Ant1Column::~Ant1Column() {} - void Ant1Column::getIntV (uInt rownr, Int* dataPtr) + void Ant1Column::getIntV (unsigned int rownr, int* dataPtr) { // Fill ColumnCache object. - const Block& ants = itsParent->ant1(); + const Block& ants = itsParent->ant1(); columnCache().setIncrement (1); - uInt strow = rownr / ants.size() * ants.size(); + unsigned int strow = rownr / ants.size() * ants.size(); columnCache().setIncrement (1); columnCache().set (strow, strow + ants.size() - 1, ants.storage()); *dataPtr = ants[rownr-strow]; @@ -71,11 +71,11 @@ namespace LOFAR { Ant2Column::~Ant2Column() {} - void Ant2Column::getIntV (uInt rownr, Int* dataPtr) + void Ant2Column::getIntV (unsigned int rownr, int* dataPtr) { // Fill ColumnCache object. - const Block& ants = itsParent->ant2(); - uInt strow = rownr / ants.size() * ants.size(); + const Block& ants = itsParent->ant2(); + unsigned int strow = rownr / ants.size() * ants.size(); columnCache().setIncrement (1); columnCache().set (strow, strow + ants.size() - 1, ants.storage()); *dataPtr = ants[rownr-strow]; @@ -83,14 +83,14 @@ namespace LOFAR { TimeColumn::~TimeColumn() {} - void TimeColumn::getdoubleV (uInt rownr, Double* dataPtr) + void TimeColumn::getdoubleV (unsigned int rownr, double* dataPtr) { // Get time of the block containing this row. - uInt nrbasel = itsParent->ant1().size(); - uInt blnr = rownr / nrbasel; + unsigned int nrbasel = itsParent->ant1().size(); + unsigned int blnr = rownr / nrbasel; itsValue = itsParent->time (blnr); // Fill ColumnCache object. - uInt strow = blnr * nrbasel; + unsigned int strow = blnr * nrbasel; columnCache().setIncrement (0); columnCache().set (strow, strow + nrbasel - 1, &itsValue); *dataPtr = itsValue; @@ -98,7 +98,7 @@ namespace LOFAR { IntervalColumn::~IntervalColumn() {} - void IntervalColumn::getdoubleV (uInt, Double* dataPtr) + void IntervalColumn::getdoubleV (unsigned int, double* dataPtr) { itsValue = itsParent->interval(); columnCache().setIncrement (0); @@ -108,7 +108,7 @@ namespace LOFAR { ZeroColumn::~ZeroColumn() {} - void ZeroColumn::getIntV (uInt, Int* dataPtr) + void ZeroColumn::getIntV (unsigned int, int* dataPtr) { itsValue = 0; columnCache().setIncrement (0); @@ -118,9 +118,9 @@ namespace LOFAR { FalseColumn::~FalseColumn() {} - void FalseColumn::getBoolV (uInt, Bool* dataPtr) + void FalseColumn::getBoolV (unsigned int, bool* dataPtr) { - itsValue = False; + itsValue = false; columnCache().setIncrement (0); columnCache().set (0, itsParent->getNRow()-1, &itsValue); *dataPtr = 0; @@ -140,7 +140,7 @@ namespace LOFAR { int nrant = anttab.nrow(); ROScalarMeasColumn antcol (anttab, "POSITION"); MPosition arrayPos; - Vector pos0; + Vector pos0; for (int i=0; i pos = mpos.getValue().getVector(); + Vector pos = mpos.getValue().getVector(); MVPosition mvpos((pos[0] - pos0[0]), (pos[1] - pos0[1]), (pos[2] - pos0[2])); @@ -174,11 +174,11 @@ namespace LOFAR { itsUvwFilled = false; } } - IPosition UvwColumn::shape (uInt) + IPosition UvwColumn::shape (unsigned int) { return IPosition(1,3); } - void UvwColumn::getArraydoubleV (uInt rownr, Array* dataPtr) + void UvwColumn::getArraydoubleV (unsigned int rownr, Array* dataPtr) { if (!itsCanCalc) { *dataPtr = 0.; @@ -192,7 +192,7 @@ namespace LOFAR { // If a different block (i.e. time), we have to calculate the UVWs. if (blnr != itsLastBlNr) { itsLastBlNr = blnr; - Quantum tm(itsParent->time(blnr), "s"); + Quantum tm(itsParent->time(blnr), "s"); itsFrame.set (MEpoch(MVEpoch(tm.get("d").getValue()), MEpoch::UTC)); itsJ2000Dir = MDirection::Convert (itsPhaseDir, MDirection::Ref(MDirection::J2000, @@ -221,24 +221,24 @@ namespace LOFAR { DataColumn::~DataColumn() {} - Bool DataColumn::isWritable() const + bool DataColumn::isWritable() const { - return True; + return true; } - IPosition DataColumn::shape (uInt) + IPosition DataColumn::shape (unsigned int) { return IPosition(2, itsParent->npol(), itsParent->nchan()); } - void DataColumn::getArrayComplexV (uInt rownr, Array* dataPtr) + void DataColumn::getArrayComplexV (unsigned int rownr, Array* dataPtr) { - Bool deleteIt; + bool deleteIt; Complex* data = dataPtr->getStorage(deleteIt); itsParent->getData (rownr, data); dataPtr->putStorage (data, deleteIt); } - void DataColumn::putArrayComplexV (uInt rownr, const Array* dataPtr) + void DataColumn::putArrayComplexV (unsigned int rownr, const Array* dataPtr) { - Bool deleteIt; + bool deleteIt; const Complex* data = dataPtr->getStorage(deleteIt); itsParent->putData (rownr, data); dataPtr->freeStorage (data, deleteIt); @@ -246,32 +246,32 @@ namespace LOFAR { FlagColumn::~FlagColumn() {} - IPosition FlagColumn::shape (uInt) + IPosition FlagColumn::shape (unsigned int) { return IPosition(2, itsParent->npol(), itsParent->nchan()); } - void FlagColumn::getArrayBoolV (uInt rownr, Array* dataPtr) + void FlagColumn::getArrayBoolV (unsigned int rownr, Array* dataPtr) { - uInt npol = itsParent->npol(); + unsigned int npol = itsParent->npol(); switch(itsParent->getLofarStManVersion()) { case 1: { - const uShort* data = itsParent->getNSample2 (rownr, False); - const uShort* dataEnd = data + itsParent->nchan(); + const unsigned short* data = itsParent->getNSample2 (rownr, false); + const unsigned short* dataEnd = data + itsParent->nchan(); if (dataPtr->contiguousStorage()) { - for (Array::contiter iter=dataPtr->cbegin(); data::contiter iter=dataPtr->cbegin(); data::iterator iter=dataPtr->begin(); + for (Array::iterator iter=dataPtr->begin(); datagetNSample1 (rownr, False); - const uChar* dataEnd = data + itsParent->nchan(); + const unsigned char* data = itsParent->getNSample1 (rownr, false); + const unsigned char* dataEnd = data + itsParent->nchan(); if (dataPtr->contiguousStorage()) { - for (Array::contiter iter=dataPtr->cbegin(); data::contiter iter=dataPtr->cbegin(); data::iterator iter=dataPtr->begin(); + for (Array::iterator iter=dataPtr->begin(); datagetNSample2 (rownr, False); - const uShort* dataEnd = data + itsParent->nchan(); + const unsigned short* data = itsParent->getNSample2 (rownr, false); + const unsigned short* dataEnd = data + itsParent->nchan(); if (dataPtr->contiguousStorage()) { - for (Array::contiter iter=dataPtr->cbegin(); data::contiter iter=dataPtr->cbegin(); data::iterator iter=dataPtr->begin(); + for (Array::iterator iter=dataPtr->begin(); datagetNSample4 (rownr, False); - const uInt* dataEnd = data + itsParent->nchan(); + const unsigned int* data = itsParent->getNSample4 (rownr, false); + const unsigned int* dataEnd = data + itsParent->nchan(); if (dataPtr->contiguousStorage()) { - for (Array::contiter iter=dataPtr->cbegin(); data::contiter iter=dataPtr->cbegin(); data::iterator iter=dataPtr->begin(); + for (Array::iterator iter=dataPtr->begin(); datanpol()); } - void WeightColumn::getArrayfloatV (uInt, Array* dataPtr) + void WeightColumn::getArrayfloatV (unsigned int, Array* dataPtr) { *dataPtr = float(1); } SigmaColumn::~SigmaColumn() {} - IPosition SigmaColumn::shape (uInt) + IPosition SigmaColumn::shape (unsigned int) { return IPosition(1, itsParent->npol()); } - void SigmaColumn::getArrayfloatV (uInt, Array* dataPtr) + void SigmaColumn::getArrayfloatV (unsigned int, Array* dataPtr) { *dataPtr = float(1); } WSpectrumColumn::~WSpectrumColumn() {} - IPosition WSpectrumColumn::shape (uInt) + IPosition WSpectrumColumn::shape (unsigned int) { return IPosition(2, itsParent->npol(), itsParent->nchan()); } - void WSpectrumColumn::getArrayfloatV (uInt rownr, Array* dataPtr) + void WSpectrumColumn::getArrayfloatV (unsigned int rownr, Array* dataPtr) { double maxn = itsParent->maxnSample(); - uInt npol = itsParent->npol(); + unsigned int npol = itsParent->npol(); switch (itsParent->getLofarStManVersion()) { case 1: { - const uShort* data = itsParent->getNSample2 (rownr, True); - const uShort* dataEnd = data + itsParent->nchan(); + const unsigned short* data = itsParent->getNSample2 (rownr, true); + const unsigned short* dataEnd = data + itsParent->nchan(); if (dataPtr->contiguousStorage()) { - for (Array::contiter iter=dataPtr->cbegin(); + for (Array::contiter iter=dataPtr->cbegin(); data::iterator iter=dataPtr->begin(); + for (Array::iterator iter=dataPtr->begin(); datagetNrBytesPerNrValidSamples()) { case 1: { - const uChar* data = itsParent->getNSample1(rownr, True); - const uChar* dataEnd = data + itsParent->nchan(); + const unsigned char* data = itsParent->getNSample1(rownr, true); + const unsigned char* dataEnd = data + itsParent->nchan(); if (dataPtr->contiguousStorage()) { - for (Array::contiter iter=dataPtr->cbegin(); + for (Array::contiter iter=dataPtr->cbegin(); data::iterator iter=dataPtr->begin(); + for (Array::iterator iter=dataPtr->begin(); datagetNSample2(rownr, True); - const uShort* dataEnd = data + itsParent->nchan(); + const unsigned short* data = itsParent->getNSample2(rownr, true); + const unsigned short* dataEnd = data + itsParent->nchan(); if (dataPtr->contiguousStorage()) { - for (Array::contiter iter=dataPtr->cbegin(); + for (Array::contiter iter=dataPtr->cbegin(); data::iterator iter=dataPtr->begin(); + for (Array::iterator iter=dataPtr->begin(); datagetNSample4(rownr, True); - const uInt* dataEnd = data + itsParent->nchan(); + const unsigned int* data = itsParent->getNSample4(rownr, true); + const unsigned int* dataEnd = data + itsParent->nchan(); if (dataPtr->contiguousStorage()) { - for (Array::contiter iter=dataPtr->cbegin(); + for (Array::contiter iter=dataPtr->cbegin(); data::iterator iter=dataPtr->begin(); + for (Array::iterator iter=dataPtr->begin(); dataprepareCol(); } } @@ -252,7 +252,7 @@ void LofarStMan::mapSeqFile() // Check the size of the sequencenumber file, close file if it doesn't match. // It should contain the nr of time slots. if (itsSeqFile && (itsSeqFile->getFileSize() != - Int64(itsNrRows / itsAnt1.size() * sizeof(uInt)))) { + static_cast(itsNrRows / itsAnt1.size() * sizeof(unsigned int)))) { delete itsSeqFile; itsSeqFile = 0; } @@ -270,13 +270,13 @@ void LofarStMan::closeFiles() itsSeqFile = 0; } -void LofarStMan::resync (uInt) +void LofarStMan::resync (unsigned int) { throw DataManError ("LofarStMan::resync should never be called"); } -uInt LofarStMan::resync1 (uInt) +unsigned int LofarStMan::resync1 (unsigned int) { - uInt nrows = itsRegFile->length() / itsBlockSize * itsAnt1.size(); + unsigned int nrows = itsRegFile->length() / itsBlockSize * itsAnt1.size(); // Reopen file if different nr of rows. if (nrows != itsNrRows) { openFiles (table().isWritable()); @@ -292,9 +292,9 @@ void LofarStMan::reopenRW() void LofarStMan::deleteManager() { closeFiles(); - DOos::remove (fileName()+"meta", False, False); - DOos::remove (fileName()+"data", False, False); - DOos::remove (fileName()+"seqnr", False, False); + DOos::remove (fileName()+"meta", false, false); + DOos::remove (fileName()+"data", false, false); + DOos::remove (fileName()+"seqnr", false, false); } void LofarStMan::init() @@ -304,8 +304,8 @@ void LofarStMan::init() if (itsVersion > 3) { throw DataManError ("LofarStMan can only handle up to version 3"); } - Bool asBigEndian; - uInt alignment; + bool asBigEndian; + unsigned int alignment; if (itsVersion == 2) { // In version 2 antenna1 and antenna2 were swapped. aio >> itsAnt2 >> itsAnt1; @@ -323,9 +323,9 @@ void LofarStMan::init() // Set start time to middle of first time slot. itsStartTime += itsTimeIntv*0.5; AlwaysAssert (itsAnt1.size() == itsAnt2.size(), AipsError); - uInt nrbl = itsAnt1.size(); + unsigned int nrbl = itsAnt1.size(); itsDoSwap = (asBigEndian != HostInfo::bigEndian()); - // A block contains a possibly uInt magic value, uInt seqnr, Complex data per + // A block contains a possibly unsigned int magic value, unsigned int seqnr, Complex data per // baseline,chan,pol and nsample per baseline,chan. Align it as needed. itsBLDataSize = itsNChan * itsNPol * 8; // #bytes/baseline if (alignment <= 1) { @@ -360,45 +360,45 @@ void LofarStMan::init() itsSpec.define ("nrBytesPerNrValidSamples", itsNrBytesPerNrValidSamples); itsSpec.define ("startTime", itsStartTime); itsSpec.define ("timeInterval", itsTimeIntv); - itsSpec.define ("nbaseline", Int(itsAnt1.size())); + itsSpec.define ("nbaseline", int(itsAnt1.size())); } -Double LofarStMan::time (uInt blocknr) +double LofarStMan::time (unsigned int blocknr) { - uInt seqnr; + unsigned int seqnr; const void* ptr; if (itsSeqFile) { - ptr = itsSeqFile->getReadPointer(blocknr * sizeof(uInt)); + ptr = itsSeqFile->getReadPointer(blocknr * sizeof(unsigned int)); } else { - ptr = getReadPointer (blocknr, 0, sizeof(uInt)); + ptr = getReadPointer (blocknr, 0, sizeof(unsigned int)); // Version 2 and later have a magic value before the seqnr. if (itsVersion >= 2) { if (itsDoSwap) { CanonicalConversion::reverse4 (&seqnr, ptr); } else { - seqnr = *static_cast(ptr); + seqnr = *static_cast(ptr); } if (seqnr != 0x00000da7a) { throw DataManError ("Magic number mismatch in block " + - String::toString(blocknr) + - " of LofarStMan data file " + itsRegFile->fileName()); + std::to_string(blocknr) + + " of LofarStMan data file " + std::string(itsRegFile->fileName())); } - ptr = getReadPointer (blocknr, sizeof(uInt), sizeof(uInt)); + ptr = getReadPointer (blocknr, sizeof(unsigned int), sizeof(unsigned int)); } } if (itsDoSwap) { CanonicalConversion::reverse4 (&seqnr, ptr); } else { - seqnr = *static_cast(ptr); + seqnr = *static_cast(ptr); } return itsStartTime + seqnr*itsTimeIntv; } -void LofarStMan::getData (uInt rownr, Complex* buf) +void LofarStMan::getData (unsigned int rownr, Complex* buf) { - uInt blocknr = rownr / itsAnt1.size(); - uInt baseline = rownr - blocknr*itsAnt1.size(); - uInt offset = itsDataStart + baseline * itsBLDataSize; + unsigned int blocknr = rownr / itsAnt1.size(); + unsigned int baseline = rownr - blocknr*itsAnt1.size(); + unsigned int offset = itsDataStart + baseline * itsBLDataSize; const void* ptr = getReadPointer (blocknr, offset, itsBLDataSize); if (itsDoSwap) { const char* from = (const char*)ptr; @@ -420,11 +420,11 @@ void LofarStMan::getData (uInt rownr, Complex* buf) } } -void LofarStMan::putData (uInt rownr, const Complex* buf) +void LofarStMan::putData (unsigned int rownr, const Complex* buf) { - uInt blocknr = rownr / itsAnt1.size(); - uInt baseline = rownr - blocknr*itsAnt1.size(); - uInt offset = itsDataStart + baseline * itsBLDataSize; + unsigned int blocknr = rownr / itsAnt1.size(); + unsigned int baseline = rownr - blocknr*itsAnt1.size(); + unsigned int offset = itsDataStart + baseline * itsBLDataSize; void* ptr = getWritePointer (blocknr, offset, itsBLDataSize); // The first RTCP versions generated conjugate data. if (itsVersion < 3) { @@ -464,15 +464,15 @@ void LofarStMan::putData (uInt rownr, const Complex* buf) // be > nominal_nsamples (they were set to -1, thus max_unsigned_int). // We fix that setting them to 0. -const uChar* LofarStMan::getNSample1 (uInt rownr, Bool) +const unsigned char* LofarStMan::getNSample1 (unsigned int rownr, bool) { - uInt blocknr = rownr / itsAnt1.size(); - uInt baseline = rownr - blocknr*itsAnt1.size(); - uInt offset = itsSampStart + baseline * itsNChan*itsNrBytesPerNrValidSamples; + unsigned int blocknr = rownr / itsAnt1.size(); + unsigned int baseline = rownr - blocknr*itsAnt1.size(); + unsigned int offset = itsSampStart + baseline * itsNChan*itsNrBytesPerNrValidSamples; const void* ptr = getReadPointer (blocknr, offset, itsNChan*itsNrBytesPerNrValidSamples); - uChar* to = itsNSampleBuf1.storage(); + unsigned char* to = itsNSampleBuf1.storage(); memcpy (to, ptr, itsNChan); - for (uInt i=0; i itsMaxNrSample) { to[i] = 0; } @@ -480,20 +480,20 @@ const uChar* LofarStMan::getNSample1 (uInt rownr, Bool) return to; } -const uShort* LofarStMan::getNSample2 (uInt rownr, Bool) +const unsigned short* LofarStMan::getNSample2 (unsigned int rownr, bool) { - uInt blocknr = rownr / itsAnt1.size(); - uInt baseline = rownr - blocknr*itsAnt1.size(); - uInt offset = itsSampStart + baseline * itsNChan*itsNrBytesPerNrValidSamples; + unsigned int blocknr = rownr / itsAnt1.size(); + unsigned int baseline = rownr - blocknr*itsAnt1.size(); + unsigned int offset = itsSampStart + baseline * itsNChan*itsNrBytesPerNrValidSamples; const void* ptr = getReadPointer (blocknr, offset, itsNChan*itsNrBytesPerNrValidSamples); - const uShort* from = (const uShort*)ptr; - uShort* to = itsNSampleBuf2.storage(); + const unsigned short* from = (const unsigned short*)ptr; + unsigned short* to = itsNSampleBuf2.storage(); if (!itsDoSwap) { - for (uInt i=0; i itsMaxNrSample ? 0 : from[i]); } } else { - for (uInt i=0; i itsMaxNrSample) { to[i] = 0; @@ -503,20 +503,20 @@ const uShort* LofarStMan::getNSample2 (uInt rownr, Bool) return to; } -const uInt* LofarStMan::getNSample4 (uInt rownr, Bool) +const unsigned int* LofarStMan::getNSample4 (unsigned int rownr, bool) { - uInt blocknr = rownr / itsAnt1.size(); - uInt baseline = rownr - blocknr*itsAnt1.size(); - uInt offset = itsSampStart + baseline * itsNChan*itsNrBytesPerNrValidSamples; + unsigned int blocknr = rownr / itsAnt1.size(); + unsigned int baseline = rownr - blocknr*itsAnt1.size(); + unsigned int offset = itsSampStart + baseline * itsNChan*itsNrBytesPerNrValidSamples; const void* ptr = getReadPointer (blocknr, offset, itsNChan*itsNrBytesPerNrValidSamples); - const uInt* from = (const uInt*)ptr; - uInt* to = itsNSampleBuf4.storage(); + const unsigned int* from = (const unsigned int*)ptr; + unsigned int* to = itsNSampleBuf4.storage(); if (!itsDoSwap) { - for (uInt i=0; i itsMaxNrSample ? 0 : from[i]); } } else { - for (uInt i=0; i itsMaxNrSample) { to[i] = 0; @@ -527,7 +527,7 @@ const uInt* LofarStMan::getNSample4 (uInt rownr, Bool) } -void* LofarStMan::readFile (uInt blocknr, uInt offset, uInt size) +void* LofarStMan::readFile (unsigned int blocknr, unsigned int offset, unsigned int size) { AlwaysAssert (size <= itsBuffer.size(), AipsError); itsRegFile->seek (blocknr*itsBlockSize + offset); @@ -535,13 +535,13 @@ void* LofarStMan::readFile (uInt blocknr, uInt offset, uInt size) return itsBuffer.storage(); } -void* LofarStMan::getBuffer (uInt size) +void* LofarStMan::getBuffer (unsigned int size) { AlwaysAssert (size <= itsBuffer.size(), AipsError); return itsBuffer.storage(); } -void LofarStMan::writeFile (uInt blocknr, uInt offset, uInt size) +void LofarStMan::writeFile (unsigned int blocknr, unsigned int offset, unsigned int size) { AlwaysAssert (size <= itsBuffer.size(), AipsError); itsRegFile->seek (blocknr*itsBlockSize + offset); diff --git a/test/tIOPerf.cc b/test/tIOPerf.cc index ac78096..807b234 100644 --- a/test/tIOPerf.cc +++ b/test/tIOPerf.cc @@ -57,26 +57,26 @@ using namespace std; // 16=read in baseline order (cache (nant+1)/2 baselines) // 9. file extension; name is tIOPerf_tmp.data -uInt nalign (uInt size, uInt alignment) +unsigned int nalign (unsigned int size, unsigned int alignment) { return (size + alignment-1) / alignment * alignment; } -void writeData (uInt nseq, uInt nant, uInt nchan, uInt npol, - uInt alignment, const String& ext) +void writeData (unsigned int nseq, unsigned int nant, unsigned int nchan, unsigned int npol, + unsigned int alignment, const String& ext) { - uInt nrbl = nant*(nant+1)/2; + unsigned int nrbl = nant*(nant+1)/2; // Create and initialize blocks for data, seqnr, and nsample. - Block data(nalign(npol*nchan*nrbl*8, alignment), 0); - Block seqnr(nalign(4, alignment), 0); - Block samples(nalign(nchan*npol*nrbl*2, alignment), 0); + Block data(nalign(npol*nchan*nrbl*8, alignment), 0); + Block seqnr(nalign(4, alignment), 0); + Block samples(nalign(nchan*npol*nrbl*2, alignment), 0); // Open the file. - int fd = open (("tIOPerf_tmp.dat"+ext).chars(), + int fd = open (("tIOPerf_tmp.dat"+ext).c_str(), O_RDWR | O_CREAT | O_TRUNC, 0644); // Write all data. - Int64 leng=0; + int64_t leng=0; Timer timer; - for (uInt i=0; i data(nalign(npol*nchan*nrbl*8, alignment), 0); - Block seqnr(nalign(4, alignment), 0); - Block samples(nalign(nchan*npol*nrbl*2, alignment), 0); + Block data(nalign(npol*nchan*nrbl*8, alignment), 0); + Block seqnr(nalign(4, alignment), 0); + Block samples(nalign(nchan*npol*nrbl*2, alignment), 0); // Open the files. - uInt nfiles = (nrbl + nblperfile - 1)/ nblperfile; + unsigned int nfiles = (nrbl + nblperfile - 1)/ nblperfile; Block fds(nfiles); - for (uInt i=0; i data(nalign(npol*nchan*nrbl*nseqperbl*8, alignment), 0); - Block seqnr(nalign(nseqperbl*4, alignment), 0); - Block samples(nalign(nchan*npol*nrbl*nseqperbl*2, alignment), 0); + Block data(nalign(npol*nchan*nrbl*nseqperbl*8, alignment), 0); + Block seqnr(nalign(nseqperbl*4, alignment), 0); + Block samples(nalign(nchan*npol*nrbl*nseqperbl*2, alignment), 0); // Open the file. - int fd = open (("tIOPerf_tmp.dat"+ext).chars(), + int fd = open (("tIOPerf_tmp.dat"+ext).c_str(), O_RDWR | O_CREAT | O_TRUNC, 0644); // Write all data. - Int64 leng=0; + int64_t leng=0; Timer timer; - for (uInt i=0; i data(npol*nchan*nrbl*8, 0); - Block seqnr(4, 0); - Block samples(nchan*npol*nrbl*2, 0); - uInt naldata = nalign (data.size(), alignment) - data.size(); - uInt nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); - uInt nalsamp = nalign (samples.size(), alignment - samples.size()); - Int64 offset = seqnr.size() + nalseq; + Block data(npol*nchan*nrbl*8, 0); + Block seqnr(4, 0); + Block samples(nchan*npol*nrbl*2, 0); + unsigned int naldata = nalign (data.size(), alignment) - data.size(); + unsigned int nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); + unsigned int nalsamp = nalign (samples.size(), alignment - samples.size()); + int64_t offset = seqnr.size() + nalseq; // Open the file. - int fd = open (("tIOPerf_tmp.dat"+ext).chars(), O_RDONLY); + int fd = open (("tIOPerf_tmp.dat"+ext).c_str(), O_RDONLY); // Read all data. - Int64 leng = 0; + int64_t leng = 0; Timer timer; - for (uInt i=0; i data(npol*nchan*nrbl*8, 0); - Block seqnr(4, 0); - Block samples(nchan*npol*nrbl*2, 0); - //uInt naldata = nalign (data.size(), alignment) - data.size(); - uInt nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); - //uInt nalsamp = nalign (samples.size(), alignment - samples.size()); + Block data(npol*nchan*nrbl*8, 0); + Block seqnr(4, 0); + Block samples(nchan*npol*nrbl*2, 0); + //unsigned int naldata = nalign (data.size(), alignment) - data.size(); + unsigned int nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); + //unsigned int nalsamp = nalign (samples.size(), alignment - samples.size()); // Open the files. - uInt nfiles = (nrbl + nblperfile - 1)/ nblperfile; + unsigned int nfiles = (nrbl + nblperfile - 1)/ nblperfile; Block fds(nfiles); - Block offsets(nfiles); - for (uInt i=0; i offsets(nfiles); + for (unsigned int i=0; i data(npol*nchan*nrbl*nseqperbl*8, 0); - Block seqnr(nseqperbl*4, 0); - Block samples(nchan*npol*nrbl*nseqperbl*2, 0); - uInt naldata = nalign (data.size(), alignment) - data.size(); - uInt nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); - uInt nalsamp = nalign (samples.size(), alignment - samples.size()); - Int64 offset = seqnr.size() + nalseq; + Block data(npol*nchan*nrbl*nseqperbl*8, 0); + Block seqnr(nseqperbl*4, 0); + Block samples(nchan*npol*nrbl*nseqperbl*2, 0); + unsigned int naldata = nalign (data.size(), alignment) - data.size(); + unsigned int nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); + unsigned int nalsamp = nalign (samples.size(), alignment - samples.size()); + int64_t offset = seqnr.size() + nalseq; // Open the file. - int fd = open (("tIOPerf_tmp.dat"+ext).chars(), O_RDONLY); + int fd = open (("tIOPerf_tmp.dat"+ext).c_str(), O_RDONLY); // Read all data. - Int64 leng = 0; + int64_t leng = 0; Timer timer; - for (uInt i=0; i data(npol*nchan*nrbl*nseqperbl*8, 0); - Block seqnr(nseqperbl*4, 0); - Block samples(nchan*npol*nrbl*nseqperbl*2, 0); - uInt naldata = nalign (data.size(), alignment) - data.size(); - uInt nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); - uInt nalsamp = nalign (samples.size(), alignment - samples.size()); - Int64 offset = seqnr.size() + nalseq; + Block data(npol*nchan*nrbl*nseqperbl*8, 0); + Block seqnr(nseqperbl*4, 0); + Block samples(nchan*npol*nrbl*nseqperbl*2, 0); + unsigned int naldata = nalign (data.size(), alignment) - data.size(); + unsigned int nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); + unsigned int nalsamp = nalign (samples.size(), alignment - samples.size()); + int64_t offset = seqnr.size() + nalseq; // Open the file. - int fd = open (("tIOPerf_tmp.dat"+ext).chars(), O_RDONLY); + int fd = open (("tIOPerf_tmp.dat"+ext).c_str(), O_RDONLY); // Read all data. - Int64 leng = 0; + int64_t leng = 0; Timer timer; - for (uInt i=0; i data(npol*nchan*8, 0); - Block seqnr(4, 0); - Block samples(nchan*npol*nrbl*2, 0); - uInt naldata = nalign (data.size(), alignment) - data.size(); - uInt nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); - uInt nalsamp = nalign (samples.size(), alignment - samples.size()); + Block data(npol*nchan*8, 0); + Block seqnr(4, 0); + Block samples(nchan*npol*nrbl*2, 0); + unsigned int naldata = nalign (data.size(), alignment) - data.size(); + unsigned int nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); + unsigned int nalsamp = nalign (samples.size(), alignment - samples.size()); // Open the file. - int fd = open (("tIOPerf_tmp.dat"+ext).chars(), O_RDONLY); + int fd = open (("tIOPerf_tmp.dat"+ext).c_str(), O_RDONLY); // Read all data. - Int64 leng = 0; + int64_t leng = 0; Timer timer; - for (uInt j=0; j data(npol*nchan*8, 0); - Block seqnr(4, 0); - Block samples(nchan*npol*nrbl*2, 0); - //uInt naldata = nalign (data.size(), alignment) - data.size(); - uInt nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); - //uInt nalsamp = nalign (samples.size(), alignment - samples.size()); + Block data(npol*nchan*8, 0); + Block seqnr(4, 0); + Block samples(nchan*npol*nrbl*2, 0); + //unsigned int naldata = nalign (data.size(), alignment) - data.size(); + unsigned int nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); + //unsigned int nalsamp = nalign (samples.size(), alignment - samples.size()); // Open the files. - uInt nfiles = (nrbl + nblperfile - 1)/ nblperfile; + unsigned int nfiles = (nrbl + nblperfile - 1)/ nblperfile; Block fds(nfiles); - for (uInt i=0; i data(npol*nchan*nrbl*nseqperbl*8, 0); - Block seqnr(nseqperbl*4, 0); - Block samples(nchan*npol*nrbl*nseqperbl*2, 0); - uInt naldata = nalign (data.size(), alignment) - data.size(); - uInt nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); - uInt nalsamp = nalign (samples.size(), alignment - samples.size()); - //uInt npart = nseq/nseqperbl; + Block data(npol*nchan*nrbl*nseqperbl*8, 0); + Block seqnr(nseqperbl*4, 0); + Block samples(nchan*npol*nrbl*nseqperbl*2, 0); + unsigned int naldata = nalign (data.size(), alignment) - data.size(); + unsigned int nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); + unsigned int nalsamp = nalign (samples.size(), alignment - samples.size()); + //unsigned int npart = nseq/nseqperbl; // Open the file. - int fd = open (("tIOPerf_tmp.dat"+ext).chars(), O_RDONLY); + int fd = open (("tIOPerf_tmp.dat"+ext).c_str(), O_RDONLY); // Read all data. - Int64 leng = 0; + int64_t leng = 0; Timer timer; - for (uInt j=0; j 1) { istringstream istr(argv[1]); istr >> nseq; @@ -428,17 +428,17 @@ int main (int argc, char* argv[]) istringstream istr(argv[5]); istr >> align; } - uInt nblperfile = (nant+1)/2; + unsigned int nblperfile = (nant+1)/2; if (argc > 6) { istringstream istr(argv[6]); istr >> nblperfile; } - uInt type = 0; + unsigned int type = 0; if (argc > 7) { istringstream istr(argv[7]); istr >> type; } - uInt subtype = 1+2+4+8+16+32+64+128; + unsigned int subtype = 1+2+4+8+16+32+64+128; if (argc > 8) { istringstream istr(argv[8]); istr >> subtype; diff --git a/test/tLofarStMan.cc b/test/tLofarStMan.cc index eb5c9f6..7f1c0dc 100644 --- a/test/tLofarStMan.cc +++ b/test/tLofarStMan.cc @@ -67,7 +67,7 @@ void createField (Table& mainTable) { // Build the table description. TableDesc td; - td.addColumn (ArrayColumnDesc("PHASE_DIR")); + td.addColumn (ArrayColumnDesc("PHASE_DIR")); TableMeasRefDesc measRef(MDirection::J2000); TableMeasValueDesc measVal(td, "PHASE_DIR"); TableMeasDesc measCol(measVal, measRef); @@ -84,11 +84,11 @@ void createField (Table& mainTable) mainTable.rwKeywordSet().defineTable ("FIELD", tab); } -void createAntenna (Table& mainTable, uInt nant) +void createAntenna (Table& mainTable, unsigned int nant) { // Build the table description. TableDesc td; - td.addColumn (ArrayColumnDesc("POSITION")); + td.addColumn (ArrayColumnDesc("POSITION")); TableMeasRefDesc measRef(MPosition::ITRF); TableMeasValueDesc measVal(td, "POSITION"); TableMeasDesc measCol(measVal, measRef); @@ -113,43 +113,43 @@ void createAntenna (Table& mainTable, uInt nant) MPosition::ITRF)); // Write the remaining columns with the same position. // They are not used in the UVW check. - for (uInt i=4; i >(vals,"m"), MPosition::ITRF)); } mainTable.rwKeywordSet().defineTable ("ANTENNA", tab); } -void createTable (uInt nant) +void createTable (unsigned int nant) { // Build the table description. // Add all mandatory columns of the MS main table. TableDesc td("", "1", TableDesc::Scratch); td.comment() = "A test of class Table"; - td.addColumn (ScalarColumnDesc("TIME")); - td.addColumn (ScalarColumnDesc("ANTENNA1")); - td.addColumn (ScalarColumnDesc("ANTENNA2")); - td.addColumn (ScalarColumnDesc("FEED1")); - td.addColumn (ScalarColumnDesc("FEED2")); - td.addColumn (ScalarColumnDesc("DATA_DESC_ID")); - td.addColumn (ScalarColumnDesc("PROCESSOR_ID")); - td.addColumn (ScalarColumnDesc("FIELD_ID")); - td.addColumn (ScalarColumnDesc("ARRAY_ID")); - td.addColumn (ScalarColumnDesc("OBSERVATION_ID")); - td.addColumn (ScalarColumnDesc("STATE_ID")); - td.addColumn (ScalarColumnDesc("SCAN_NUMBER")); - td.addColumn (ScalarColumnDesc("INTERVAL")); - td.addColumn (ScalarColumnDesc("EXPOSURE")); - td.addColumn (ScalarColumnDesc("TIME_CENTROID")); - td.addColumn (ScalarColumnDesc("FLAG_ROW")); - td.addColumn (ArrayColumnDesc("UVW",IPosition(1,3), + td.addColumn (ScalarColumnDesc("TIME")); + td.addColumn (ScalarColumnDesc("ANTENNA1")); + td.addColumn (ScalarColumnDesc("ANTENNA2")); + td.addColumn (ScalarColumnDesc("FEED1")); + td.addColumn (ScalarColumnDesc("FEED2")); + td.addColumn (ScalarColumnDesc("DATA_DESC_ID")); + td.addColumn (ScalarColumnDesc("PROCESSOR_ID")); + td.addColumn (ScalarColumnDesc("FIELD_ID")); + td.addColumn (ScalarColumnDesc("ARRAY_ID")); + td.addColumn (ScalarColumnDesc("OBSERVATION_ID")); + td.addColumn (ScalarColumnDesc("STATE_ID")); + td.addColumn (ScalarColumnDesc("SCAN_NUMBER")); + td.addColumn (ScalarColumnDesc("INTERVAL")); + td.addColumn (ScalarColumnDesc("EXPOSURE")); + td.addColumn (ScalarColumnDesc("TIME_CENTROID")); + td.addColumn (ScalarColumnDesc("FLAG_ROW")); + td.addColumn (ArrayColumnDesc("UVW",IPosition(1,3), ColumnDesc::Direct)); td.addColumn (ArrayColumnDesc("DATA")); - td.addColumn (ArrayColumnDesc("SIGMA")); - td.addColumn (ArrayColumnDesc("WEIGHT")); - td.addColumn (ArrayColumnDesc("WEIGHT_SPECTRUM")); - td.addColumn (ArrayColumnDesc("FLAG")); - td.addColumn (ArrayColumnDesc("FLAG_CATEGORY")); + td.addColumn (ArrayColumnDesc("SIGMA")); + td.addColumn (ArrayColumnDesc("WEIGHT")); + td.addColumn (ArrayColumnDesc("WEIGHT_SPECTRUM")); + td.addColumn (ArrayColumnDesc("FLAG")); + td.addColumn (ArrayColumnDesc("FLAG_CATEGORY")); // Now create a new table from the description. SetupNewTable newtab("tLofarStMan_tmp.data", td, Table::New); // Create the storage manager and bind all columns to it. @@ -162,24 +162,24 @@ void createTable (uInt nant) createAntenna (tab, nant); } -uInt nalign (uInt size, uInt alignment) +unsigned int nalign (unsigned int size, unsigned int alignment) { return (size + alignment-1) / alignment * alignment - size; } -void createData (uInt nseq, uInt nant, uInt nchan, uInt npol, - Double startTime, Double interval, const Complex& startValue, - uInt alignment, Bool bigEndian, uInt myStManVersion, - uInt myNrBytesPerValidSamples, bool useSeqFile) +void createData (unsigned int nseq, unsigned int nant, unsigned int nchan, unsigned int npol, + double startTime, double interval, const Complex& startValue, + unsigned int alignment, bool bigEndian, unsigned int myStManVersion, + unsigned int myNrBytesPerValidSamples, bool useSeqFile) { AlwaysAssertExit(myStManVersion <= 3); // Create the baseline vectors. - uInt nrbl = nant*nant; - Block ant1(nrbl); - Block ant2(nrbl); - uInt inx=0; - for (uInt i=0; i ant1(nrbl); + Block ant2(nrbl); + unsigned int inx=0; + for (unsigned int i=0; i data(IPosition(2,npol,nchan)); indgen (data, startValue, Complex(0.01, 0.01)); - Array nsample1(IPosition(1, nchan)); - Array nsample2(IPosition(1, nchan)); - Array nsample4(IPosition(1, nchan)); + Array nsample1(IPosition(1, nchan)); + Array nsample2(IPosition(1, nchan)); + Array nsample4(IPosition(1, nchan)); indgen (nsample1); indgen (nsample2); indgen (nsample4); @@ -255,18 +255,18 @@ void createData (uInt nseq, uInt nant, uInt nchan, uInt npol, if (alignment < 1) { alignment = 1; } - uInt seqSize = (myStManVersion==1 ? 4:8); - Block align1(nalign(seqSize, alignment), 0); - Block align2(nalign(nrbl*8*data.size(), alignment), 0); + unsigned int seqSize = (myStManVersion==1 ? 4:8); + Block align1(nalign(seqSize, alignment), 0); + Block align2(nalign(nrbl*8*data.size(), alignment), 0); - uInt nsamplesSize = nrbl*myNrBytesPerValidSamples*nsample2.size(); - Block align3(nalign(nsamplesSize, alignment), 0); + unsigned int nsamplesSize = nrbl*myNrBytesPerValidSamples*nsample2.size(); + Block align3(nalign(nsamplesSize, alignment), 0); // Write the data as nseq blocks. - for (uInt i=0; i 1) { // From version 2 on RTCP writes a magic value before the seqnr. - uInt magicVal = 0x0000da7a; + unsigned int magicVal = 0x0000da7a; cfile->write (1, &magicVal); } cfile->write (1, &i); @@ -274,7 +274,7 @@ void createData (uInt nseq, uInt nant, uInt nchan, uInt npol, cfile->write (align1.size(), align1.storage()); } - for (uInt j=0; j cdata = conj(data); @@ -289,27 +289,27 @@ void createData (uInt nseq, uInt nant, uInt nchan, uInt npol, } if (myStManVersion < 2) { - for (uInt j=0; jwrite (nsample2.size(), nsample2.data()); - nsample2 += uShort(1); + nsample2 += static_cast(1); } } else { - for (uInt j=0; jwrite(nsample1.size(), nsample1.data()); - nsample1 += uChar(1); + nsample1 += static_cast(1); } break; case 2: { cfile->write(nsample2.size(), nsample2.data()); - nsample2 += uShort(1); + nsample2 += static_cast(1); } break; case 4: { cfile->write(nsample4.size(), nsample4.data()); - nsample4 += uInt(1); + nsample4 += 1u; } break; } } @@ -341,7 +341,7 @@ void createData (uInt nseq, uInt nant, uInt nchan, uInt npol, sfile = new RawIO(file); } #endif - for (uInt i=0; iwrite (1, &i); } delete sfile; @@ -353,7 +353,7 @@ void createData (uInt nseq, uInt nant, uInt nchan, uInt npol, } -void checkUVW (uInt row, uInt nant, Vector uvw) +void checkUVW (unsigned int row, unsigned int nant, Vector uvw) { // Expected outcome of UVW for antenna 0-3 and seqnr 0-1 static double uvwVals[] = { @@ -390,11 +390,11 @@ void checkUVW (uInt row, uInt nant, Vector uvw) 0.254812, 127.271, -67.1421, 0, 0, 0 }; - uInt nrbl = nant*nant; - uInt seqnr = row / nrbl; - uInt bl = row % nrbl; - uInt ant1 = bl % nant; - uInt ant2 = bl / nant; + unsigned int nrbl = nant*nant; + unsigned int seqnr = row / nrbl; + unsigned int bl = row % nrbl; + unsigned int ant1 = bl % nant; + unsigned int ant2 = bl / nant; // Only check first two time stamps and first four antennae. if (seqnr < 2 && ant1 < 4 && ant2 < 4) { AlwaysAssertExit (near(uvw[0], @@ -405,56 +405,56 @@ void checkUVW (uInt row, uInt nant, Vector uvw) // maxWeight tells maximum weight before it wraps // (when nbytesPerSample is small). -void readTable (uInt nseq, uInt nant, uInt nchan, uInt npol, - Double startTime, Double interval, const Complex& startValue, - Float maxWeight) +void readTable (unsigned int nseq, unsigned int nant, unsigned int nchan, unsigned int npol, + double startTime, double interval, const Complex& startValue, + float maxWeight) { - uInt nbasel = nant*nant; + unsigned int nbasel = nant*nant; // Open the table and check if #rows is as expected. Table tab("tLofarStMan_tmp.data"); - uInt nrow = tab.nrow(); + unsigned int nrow = tab.nrow(); AlwaysAssertExit (nrow == nseq*nbasel); AlwaysAssertExit (!tab.canAddRow()); AlwaysAssertExit (!tab.canRemoveRow()); AlwaysAssertExit (tab.canRemoveColumn(Vector(1, "DATA"))); // Create objects for all mandatory MS columns. - ROArrayColumn dataCol(tab, "DATA"); - ROArrayColumn weightCol(tab, "WEIGHT"); - ROArrayColumn wspecCol(tab, "WEIGHT_SPECTRUM"); - ROArrayColumn sigmaCol(tab, "SIGMA"); - ROArrayColumn uvwCol(tab, "UVW"); - ROArrayColumn flagCol(tab, "FLAG"); - ROArrayColumn flagcatCol(tab, "FLAG_CATEGORY"); - ROScalarColumn timeCol(tab, "TIME"); - ROScalarColumn centCol(tab, "TIME_CENTROID"); - ROScalarColumn intvCol(tab, "INTERVAL"); - ROScalarColumn expoCol(tab, "EXPOSURE"); - ROScalarColumn ant1Col(tab, "ANTENNA1"); - ROScalarColumn ant2Col(tab, "ANTENNA2"); - ROScalarColumn feed1Col(tab, "FEED1"); - ROScalarColumn feed2Col(tab, "FEED2"); - ROScalarColumn ddidCol(tab, "DATA_DESC_ID"); - ROScalarColumn pridCol(tab, "PROCESSOR_ID"); - ROScalarColumn fldidCol(tab, "FIELD_ID"); - ROScalarColumn arridCol(tab, "ARRAY_ID"); - ROScalarColumn obsidCol(tab, "OBSERVATION_ID"); - ROScalarColumn stidCol(tab, "STATE_ID"); - ROScalarColumn scnrCol(tab, "SCAN_NUMBER"); - ROScalarColumn flagrowCol(tab, "FLAG_ROW"); + ArrayColumn dataCol(tab, "DATA"); + ArrayColumn weightCol(tab, "WEIGHT"); + ArrayColumn wspecCol(tab, "WEIGHT_SPECTRUM"); + ArrayColumn sigmaCol(tab, "SIGMA"); + ArrayColumn uvwCol(tab, "UVW"); + ArrayColumn flagCol(tab, "FLAG"); + ArrayColumn flagcatCol(tab, "FLAG_CATEGORY"); + ScalarColumn timeCol(tab, "TIME"); + ScalarColumn centCol(tab, "TIME_CENTROID"); + ScalarColumn intvCol(tab, "INTERVAL"); + ScalarColumn expoCol(tab, "EXPOSURE"); + ScalarColumn ant1Col(tab, "ANTENNA1"); + ScalarColumn ant2Col(tab, "ANTENNA2"); + ScalarColumn feed1Col(tab, "FEED1"); + ScalarColumn feed2Col(tab, "FEED2"); + ScalarColumn ddidCol(tab, "DATA_DESC_ID"); + ScalarColumn pridCol(tab, "PROCESSOR_ID"); + ScalarColumn fldidCol(tab, "FIELD_ID"); + ScalarColumn arridCol(tab, "ARRAY_ID"); + ScalarColumn obsidCol(tab, "OBSERVATION_ID"); + ScalarColumn stidCol(tab, "STATE_ID"); + ScalarColumn scnrCol(tab, "SCAN_NUMBER"); + ScalarColumn flagrowCol(tab, "FLAG_ROW"); // Create and initialize expected data and weight. Array dataExp(IPosition(2,npol,nchan)); indgen (dataExp, startValue, Complex(0.01, 0.01)); - Array weightExp(IPosition(2,1,nchan)); + Array weightExp(IPosition(2,1,nchan)); indgen (weightExp); // Loop through all rows in the table and check the data. - uInt row=0; - for (uInt i=0; i= maxWeight) { weightExp.data()[i] -= maxWeight; } @@ -472,25 +472,25 @@ void readTable (uInt nseq, uInt nant, uInt nchan, uInt npol, // Check data, weight, sigma, weight_spectrum, flag AlwaysAssertExit (allNear (dataCol(row), dataExp, 1e-7)); AlwaysAssertExit (weightCol.shape(row) == IPosition(1,npol)); - AlwaysAssertExit (allEQ (weightCol(row), Float(1))); + AlwaysAssertExit (allEQ (weightCol(row), float(1))); AlwaysAssertExit (sigmaCol.shape(row) == IPosition(1,npol)); - AlwaysAssertExit (allEQ (sigmaCol(row), Float(1))); - Array weights = wspecCol(row); + AlwaysAssertExit (allEQ (sigmaCol(row), float(1))); + Array weights = wspecCol(row); AlwaysAssertExit (weights.shape() == IPosition(2,npol,nchan)); - for (uInt p=0; p flagExp (weights == Float(0)); + Array flagExp (weights == float(0)); AlwaysAssertExit (allEQ (flagCol(row), flagExp)); // Check ANTENNA1 and ANTENNA2 @@ -498,18 +498,18 @@ void readTable (uInt nseq, uInt nant, uInt nchan, uInt npol, AlwaysAssertExit (ant2Col(row) == int(j)); dataExp += Complex(0.01, 0.02); - weightExp += Float(1); + weightExp += float(1); ++row; } } } // Check values in TIME column. - Vector times = timeCol.getColumn(); + Vector times = timeCol.getColumn(); AlwaysAssertExit (times.size() == nrow); row=0; startTime += interval/2; - for (uInt i=0; i wg = wspecCol.getColumnCells (rownrs); } -void updateTable (uInt nchan, uInt npol, const Complex& startValue) +void updateTable (unsigned int nchan, unsigned int npol, const Complex& startValue) { // Open the table for write. Table tab("tLofarStMan_tmp.data", Table::Update); - uInt nrow = tab.nrow(); + unsigned int nrow = tab.nrow(); // Create object for DATA column. ArrayColumn dataCol(tab, "DATA"); // Check we can write the column, but not change the shape. @@ -553,7 +553,7 @@ void updateTable (uInt nchan, uInt npol, const Complex& startValue) Array data(IPosition(2,npol,nchan)); indgen (data, startValue, Complex(0.01, 0.01)); // Loop through all rows in the table and write the data. - for (uInt row=0; row 1) { istringstream istr(argv[1]); istr >> nseq; @@ -584,7 +584,7 @@ int main (int argc, char* argv[]) if (nseq == 0) { Table tab(argv[2]); cout << "nrow=" << tab.nrow() << endl; - ROArrayColumn uvwcol(tab, "UVW"); + ArrayColumn uvwcol(tab, "UVW"); cout << "uvws="<< uvwcol(0) << endl; cout << "uvws="<< uvwcol(1) << endl; cout << "uvwe="<< uvwcol(tab.nrow()-1) << endl; @@ -602,8 +602,8 @@ int main (int argc, char* argv[]) istr >> npol; } // Test all possible bytes per sample. - uInt nbytesPerSample[] = {0, 2,4,1}; - uInt maxWeight[] = {0, 256*256, 256*256*256*127, 256}; + unsigned int nbytesPerSample[] = {0, 2,4,1}; + unsigned int maxWeight[] = {0, 256*256, 256*256*256*127, 256}; // Test the various versions. for (int v=1; v<4; ++v) { cout << "Test version " << v << endl; @@ -615,7 +615,7 @@ int main (int argc, char* argv[]) double interval= 30.; double startTime = 4472025740.0 - interval*0.5; createData (nseq, nant, nchan, npol, startTime, interval, - Complex(0.1, 0.1), 512, True, v, nbytesPerSample[v], v%2==0); + Complex(0.1, 0.1), 512, true, v, nbytesPerSample[v], v%2==0); readTable (nseq, nant, nchan, npol, startTime, interval, Complex(0.1, 0.1), maxWeight[v]); // Update the table and check again. @@ -624,7 +624,7 @@ int main (int argc, char* argv[]) Complex(-3.52, -20.3), maxWeight[v]); // Write data in local format and check it. No alignment. createData (nseq, nant, nchan, npol, startTime, interval, - Complex(3.1, -5.2), 0, False, v, nbytesPerSample[v], v%2!=0); + Complex(3.1, -5.2), 0, false, v, nbytesPerSample[v], v%2!=0); readTable (nseq, nant, nchan, npol, startTime, interval, Complex(3.1, -5.2), maxWeight[v]); // Update the table and check again. diff --git a/test/tfix.cc b/test/tfix.cc index bdbb828..c44451b 100644 --- a/test/tfix.cc +++ b/test/tfix.cc @@ -41,9 +41,9 @@ void fixTable (const String& name) cout << "MS already contains column WEIGHT_SPECTRUM" << endl; } else { TableDesc td; - ArrayColumnDesc cd("WEIGHT_SPECTRUM"); - //# Note: True means add to existing LofarStMan. - t.addColumn (cd, "LofarStMan", True); + ArrayColumnDesc cd("WEIGHT_SPECTRUM"); + //# Note: true means add to existing LofarStMan. + t.addColumn (cd, "LofarStMan", true); cout << "Added column WEIGHT_SPECTRUM to the MS" << endl; } } From 81cbe8a875aa459955d6ebb9e8354770514fe72a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Tue, 6 Oct 2026 10:44:56 +0200 Subject: [PATCH 2/4] Enable std set of warnings --- CMakeLists.txt | 13 ++++++++++++- src/LofarStMan.cc | 24 ++++++++++++------------ test/tLofarStMan.cc | 2 +- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d0b1e00..23bce69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,18 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3") +add_compile_options( + -O3 + -Wall + -Wnon-virtual-dtor + -Wzero-as-null-pointer-constant + -Wduplicated-branches + -Wundef + -Wvla + -Wpointer-arith + -Wextra + -Wno-unused-parameter + -Wno-psabi) if(PORTABLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ") diff --git a/src/LofarStMan.cc b/src/LofarStMan.cc index 2703cf2..8a3cad0 100644 --- a/src/LofarStMan.cc +++ b/src/LofarStMan.cc @@ -41,8 +41,8 @@ LofarStMan::LofarStMan (const String& dataManName) : DataManager (), itsDataManName (dataManName), itsFD (-1), - itsRegFile (0), - itsSeqFile (0) + itsRegFile (nullptr), + itsSeqFile (nullptr) {} LofarStMan::LofarStMan (const String& dataManName, @@ -50,16 +50,16 @@ LofarStMan::LofarStMan (const String& dataManName, : DataManager (), itsDataManName (dataManName), itsFD (-1), - itsRegFile (0), - itsSeqFile (0) + itsRegFile (nullptr), + itsSeqFile (nullptr) {} LofarStMan::LofarStMan (const LofarStMan& that) : DataManager (), itsDataManName (that.itsDataManName), itsFD (-1), - itsRegFile (0), - itsSeqFile (0) + itsRegFile (nullptr), + itsSeqFile (nullptr) {} LofarStMan::~LofarStMan() @@ -236,25 +236,25 @@ void LofarStMan::openFiles (bool writable) if ((long long) (itsBuffer.size()) < itsBLDataSize) { itsBuffer.resize (itsBLDataSize); } - itsSpec.define ("useSeqnrFile", itsSeqFile!=0); + itsSpec.define ("useSeqnrFile", itsSeqFile!=nullptr); } void LofarStMan::mapSeqFile() { delete itsSeqFile; - itsSeqFile = 0; + itsSeqFile = nullptr; try { itsSeqFile = new MMapIO (fileName() + "seqnr"); } catch (...) { delete itsSeqFile; - itsSeqFile = 0; + itsSeqFile = nullptr; } // Check the size of the sequencenumber file, close file if it doesn't match. // It should contain the nr of time slots. if (itsSeqFile && (itsSeqFile->getFileSize() != static_cast(itsNrRows / itsAnt1.size() * sizeof(unsigned int)))) { delete itsSeqFile; - itsSeqFile = 0; + itsSeqFile = nullptr; } } @@ -265,9 +265,9 @@ void LofarStMan::closeFiles() itsFD = -1; } delete itsRegFile; - itsRegFile = 0; + itsRegFile = nullptr; delete itsSeqFile; - itsSeqFile = 0; + itsSeqFile = nullptr; } void LofarStMan::resync (unsigned int) diff --git a/test/tLofarStMan.cc b/test/tLofarStMan.cc index 7f1c0dc..1d0fb6e 100644 --- a/test/tLofarStMan.cc +++ b/test/tLofarStMan.cc @@ -322,7 +322,7 @@ void createData (unsigned int nseq, unsigned int nant, unsigned int nchan, unsig delete cfile; if (useSeqFile && myStManVersion > 1) { - TypeIO* sfile = 0; + TypeIO* sfile = nullptr; // create seperate file for sequence numbers if version > 1 auto file = std::make_shared( RegularFile("tLofarStMan_tmp.data/table.f0seqnr"), ByteIO::New); From 159419c83c8327c3c8a503f043bd3630290294ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Tue, 6 Oct 2026 10:46:46 +0200 Subject: [PATCH 3/4] Update minimum CMake version to 3.12 Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23bce69..c23eae8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # $Id: CMakeLists.txt 14280 2009-10-16 13:48:46Z loose $ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.12) project(LofarStMan VERSION 1.0.2) From db789f5640e8d59c12ae365c0cac0cbecd6de6ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Tue, 6 Oct 2026 11:40:27 +0200 Subject: [PATCH 4/4] Avoid ambiguity with older casacore --- src/LofarStMan.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/LofarStMan.cc b/src/LofarStMan.cc index 8a3cad0..fa7fd04 100644 --- a/src/LofarStMan.cc +++ b/src/LofarStMan.cc @@ -526,11 +526,21 @@ const unsigned int* LofarStMan::getNSample4 (unsigned int rownr, bool) return to; } +template +inline static void seekDispatcher(casacore::FiledesIO& file, NumericType offset) +{ + // Older versions use long long as the parameter and return value for seek, whereas + // newer versions use int64_t. The parameter type equals the return value, even for the + // return value of the seek(int) overload. Hence, we cast the parameter to this type + // to avoid compiler errors due to overload ambiguity. + using OffsetType = decltype(file.seek(0)); + file.seek(static_cast(offset)); +} void* LofarStMan::readFile (unsigned int blocknr, unsigned int offset, unsigned int size) { AlwaysAssert (size <= itsBuffer.size(), AipsError); - itsRegFile->seek (blocknr*itsBlockSize + offset); + seekDispatcher (*itsRegFile, blocknr*itsBlockSize + offset); itsRegFile->read (size, itsBuffer.storage()); return itsBuffer.storage(); } @@ -544,7 +554,7 @@ void* LofarStMan::getBuffer (unsigned int size) void LofarStMan::writeFile (unsigned int blocknr, unsigned int offset, unsigned int size) { AlwaysAssert (size <= itsBuffer.size(), AipsError); - itsRegFile->seek (blocknr*itsBlockSize + offset); + seekDispatcher(*itsRegFile, blocknr*itsBlockSize + offset); itsRegFile->write (size, itsBuffer.storage()); }