Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more use of C++11 #377

Merged
merged 20 commits into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions six/modules/c++/cphd/include/cphd/ByteSwap.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ void byteSwap(void* buffer,
* \brief Threaded byte-swapping and promote input to complex<floats>
*
* Valid input types:
* sys::Int8_T
* sys::Int16_T
* int8_t
* int16_t
* sys::float
*
* \param input Input to swap and promote
Expand All @@ -72,8 +72,8 @@ void byteSwapAndPromote(const void* input,
* \brief Threaded byte-swapping and promote input to complex<floats>
*
* Valid input types:
* sys::Int8_T
* sys::Int16_T
* int8_t
* int16_t
* sys::float
*
* \param input Input to swap, promote and scale
Expand Down
2 changes: 1 addition & 1 deletion six/modules/c++/cphd/include/cphd/CPHDReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class CPHDReader
*
* \return offset of signal sample in file
*/
sys::Off_T getFileOffset(size_t channel, size_t vector, size_t sample) const
int64_t getFileOffset(size_t channel, size_t vector, size_t sample) const
{
return mWideband->getFileOffset(channel, vector, sample);
}
Expand Down
30 changes: 15 additions & 15 deletions six/modules/c++/cphd/include/cphd/CPHDWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class DataWriter
* \param numElements Total number of elements in array
* \param elementSize Size of each element
*/
virtual void operator()(const sys::ubyte* data,
virtual void operator()(const std::byte* data,
size_t numElements,
size_t elementSize) = 0;

Expand Down Expand Up @@ -110,15 +110,15 @@ class DataWriterLittleEndian : public DataWriter
* \param numElements Total number of elements in array
* \param elementSize Size of each element
*/
virtual void operator()(const sys::ubyte* data,
virtual void operator()(const std::byte* data,
size_t numElements,
size_t elementSize);

private:
// Size of scratch space
const size_t mScratchSize;
// Scratch space buffer
const mem::ScopedArray<sys::byte> mScratch;
const std::unique_ptr<std::byte[]> mScratch;
};

/*
Expand Down Expand Up @@ -151,7 +151,7 @@ class DataWriterBigEndian : public DataWriter
* \param numElements Total number of elements in array
* \param elementSize Size of each element
*/
virtual void operator()(const sys::ubyte* data,
virtual void operator()(const std::byte* data,
size_t numElements,
size_t elementSize);
};
Expand Down Expand Up @@ -226,8 +226,8 @@ class CPHDWriter
* This only works with valid CPHDWriter data types:
* std:: ubyte* (for compressed data)
* std::complex<float>
* std::complex<sys::Int16_T>
* std::complex<sys::Int8_T>
* std::complex<int16_t>
* std::complex<int8_t>
*
* \param pvpBlock The vector based metadata to write.
* \param widebandData .The wideband data to write to disk
Expand All @@ -237,7 +237,7 @@ class CPHDWriter
void write(
const PVPBlock& pvpBlock,
const T* widebandData,
const sys::ubyte* supportData = nullptr);
const std::byte* supportData = nullptr);

/*
* \func writeMetadata
Expand All @@ -264,7 +264,7 @@ class CPHDWriter
void writeSupportData(const T* data,
const std::string& id)
{
writeSupportDataImpl(reinterpret_cast<const sys::ubyte*>(data),
writeSupportDataImpl(reinterpret_cast<const std::byte*>(data),
mMetadata.data.getSupportArrayById(id).numRows * mMetadata.data.getSupportArrayById(id).numCols,
mMetadata.data.getSupportArrayById(id).bytesPerElement);
}
Expand All @@ -280,7 +280,7 @@ class CPHDWriter
template <typename T>
void writeSupportData(const T* data)
{
const sys::ubyte* dataPtr = reinterpret_cast<const sys::ubyte*>(data);
const std::byte* dataPtr = reinterpret_cast<const std::byte*>(data);
for (auto it = mMetadata.data.supportArrayMap.begin(); it != mMetadata.data.supportArrayMap.end(); ++it)
{
// Move inputstream head to offset of particular support array
Expand Down Expand Up @@ -311,8 +311,8 @@ class CPHDWriter
* valid CPHDWriter data types:
* std:: ubyte* (for compressed data)
* std::complex<float>
* std::complex<sys::Int16_T>
* std::complex<sys::Int8_T>
* std::complex<int16_t>
* std::complex<int8_t>
*
* \param data The data to write to disk.
* \param numElements The number of elements in data. Treat the data
Expand Down Expand Up @@ -342,25 +342,25 @@ class CPHDWriter
/*
* Write pvp helper
*/
void writePVPData(const sys::ubyte* pvpBlock,
void writePVPData(const std::byte* pvpBlock,
size_t index);

/*
* Implementation of write wideband
*/
void writeCPHDDataImpl(const sys::ubyte* data,
void writeCPHDDataImpl(const std::byte* data,
size_t size);

/*
* Implementation of write compressed wideband
*/
void writeCompressedCPHDDataImpl(const sys::ubyte* data,
void writeCompressedCPHDDataImpl(const std::byte* data,
size_t channel);

/*
* Implementation of write support data
*/
void writeSupportDataImpl(const sys::ubyte* data,
void writeSupportDataImpl(const std::byte* data,
size_t numElements, size_t elementSize);

//! DataWriter object
Expand Down
6 changes: 3 additions & 3 deletions six/modules/c++/cphd/include/cphd/Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ struct Data
//! Validates, and add new support array to supportArrayMap
void setSupportArray(const std::string& id, size_t numRows,
size_t numCols, size_t numBytes,
sys::Off_T offset);
int64_t offset);

//! Checks if wideband data is compressed
bool isCompressed() const;
Expand Down Expand Up @@ -321,7 +321,7 @@ struct Data
{
// Overload operator ()
// Returns true if offset lhs is less than other offset
bool operator()(const sys::Off_T& lhs, const sys::Off_T& rhs) const
bool operator()(const int64_t& lhs, const int64_t& rhs) const
{
return lhs < rhs;
}
Expand All @@ -335,7 +335,7 @@ struct Data
// Book keeping map for efficient validation
// Support Array Map with:
// key: offset, value: array size
std::map<sys::Off_T, size_t, CmpByOffset> mOffsetMap;
std::map<int64_t, size_t, CmpByOffset> mOffsetMap;
};

//! Ostream operators
Expand Down
54 changes: 27 additions & 27 deletions six/modules/c++/cphd/include/cphd/FileHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,31 +127,31 @@ class FileHeader : public BaseFileHeader
*
* \return Return size of header
*/
size_t set(sys::Off_T xmlBlockSize, sys::Off_T supportBlockSize,
sys::Off_T pvpBlockSize, sys::Off_T signalBlockSize);
size_t set(int64_t xmlBlockSize, int64_t supportBlockSize,
int64_t pvpBlockSize, int64_t signalBlockSize);

//! Set required elements
void setXMLBlockSize(sys::Off_T size)
void setXMLBlockSize(int64_t size)
{
mXmlBlockSize = size;
}
void setPvpBlockSize(sys::Off_T size)
void setPvpBlockSize(int64_t size)
{
mPvpBlockSize = size;
}
void setSignalBlockSize(sys::Off_T size)
void setSignalBlockSize(int64_t size)
{
mSignalBlockSize = size;
}
void setXMLBlockByteOffset(sys::Off_T offset)
void setXMLBlockByteOffset(int64_t offset)
{
mXmlBlockByteOffset = offset;
}
void setPvpBlockByteOffset(sys::Off_T offset)
void setPvpBlockByteOffset(int64_t offset)
{
mPvpBlockByteOffset = offset;
}
void setSignalBlockByteOffset(sys::Off_T offset)
void setSignalBlockByteOffset(int64_t offset)
{
mSignalBlockByteOffset = offset;
}
Expand All @@ -165,27 +165,27 @@ class FileHeader : public BaseFileHeader
}

//! Get required elements
sys::Off_T getXMLBlockSize() const
int64_t getXMLBlockSize() const
{
return mXmlBlockSize;
}
sys::Off_T getPvpBlockSize() const
int64_t getPvpBlockSize() const
{
return mPvpBlockSize;
}
sys::Off_T getSignalBlockSize() const
int64_t getSignalBlockSize() const
{
return mSignalBlockSize;
}
sys::Off_T getXMLBlockByteOffset() const
int64_t getXMLBlockByteOffset() const
{
return mXmlBlockByteOffset;
}
sys::Off_T getPvpBlockByteOffset() const
int64_t getPvpBlockByteOffset() const
{
return mPvpBlockByteOffset;
}
sys::Off_T getSignalBlockByteOffset() const
int64_t getSignalBlockByteOffset() const
{
return mSignalBlockByteOffset;
}
Expand All @@ -206,23 +206,23 @@ class FileHeader : public BaseFileHeader
*
* \return number of pad bytes
*/
sys::Off_T getPvpPadBytes() const;
int64_t getPvpPadBytes() const;

//! Optional elements
void setSupportBlockSize(sys::Off_T size)
void setSupportBlockSize(int64_t size)
{
mSupportBlockSize = size;
}
void setSupportBlockByteOffset(sys::Off_T offset)
void setSupportBlockByteOffset(int64_t offset)
{
mSupportBlockByteOffset = offset;
}

sys::Off_T getSupportBlockSize() const
int64_t getSupportBlockSize() const
{
return mSupportBlockSize;
}
sys::Off_T getSupportBlockByteOffset() const
int64_t getSupportBlockByteOffset() const
{
return mSupportBlockByteOffset;
}
Expand All @@ -235,18 +235,18 @@ class FileHeader : public BaseFileHeader
std::string mVersion;

// Required key-value pairs
sys::Off_T mXmlBlockSize;
sys::Off_T mXmlBlockByteOffset;
sys::Off_T mPvpBlockSize;
sys::Off_T mPvpBlockByteOffset;
sys::Off_T mSignalBlockSize;
sys::Off_T mSignalBlockByteOffset;
int64_t mXmlBlockSize;
int64_t mXmlBlockByteOffset;
int64_t mPvpBlockSize;
int64_t mPvpBlockByteOffset;
int64_t mSignalBlockSize;
int64_t mSignalBlockByteOffset;
std::string mClassification;
std::string mReleaseInfo;

// Optional key-value pairs
sys::Off_T mSupportBlockSize;
sys::Off_T mSupportBlockByteOffset;
int64_t mSupportBlockSize;
int64_t mSupportBlockByteOffset;
};
}

Expand Down
12 changes: 6 additions & 6 deletions six/modules/c++/cphd/include/cphd/PVPBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ struct PVPBlock
* be resized and zeroed internally.
*/
void getPVPdata(size_t channel,
std::vector<sys::ubyte>& data) const;
std::vector<std::byte>& data) const;

/*
* \func getPVPdata
Expand Down Expand Up @@ -322,9 +322,9 @@ struct PVPBlock
*/
// startPVP = cphd header keyword "PVP_BYTE_OFFSET" contains PVP block starting offset
// sizePVP = cphd header keyword "PVP_DATA_SIZE" contains PVP block size
sys::Off_T load(io::SeekableInputStream& inStream,
sys::Off_T startPVP,
sys::Off_T sizePVP,
int64_t load(io::SeekableInputStream& inStream,
int64_t startPVP,
int64_t sizePVP,
size_t numThreads);

//! Equality operators
Expand Down Expand Up @@ -370,7 +370,7 @@ struct PVPBlock
* \param input A pointer to an array of bytes that contains the
* parameter data to write into the pvp set
*/
void write(const PVPBlock& pvpBlock, const Pvp& pvp, const sys::byte* input);
void write(const PVPBlock& pvpBlock, const Pvp& pvp, const std::byte* input);

/*
* \func read
Expand All @@ -383,7 +383,7 @@ struct PVPBlock
* \param[out] output A pointer to an array of allocated bytes that
* will be written to
*/
void read(const Pvp& pvp, sys::ubyte* output) const;
void read(const Pvp& pvp, std::byte* output) const;

//! Equality operators
bool operator==(const PVPSet& other) const
Expand Down
Loading