MeVisLab Toolbox Reference
ml::R2SonicWC::R2SonicWCLoader Class Reference

Class to read R2Sonic water column sonar data. More...

#include <mlR2SonicWCLoader.h>

Inheritance diagram for ml::R2SonicWC::R2SonicWCLoader:
ml::ByteDataReader

Public Member Functions

 R2SonicWCLoader ()
 Default constructor creating an instance with empty fileName and closed loader. More...
 
void open () override
 Opens the file if possible, isGood() will return true on success, otherwise false; if byte swapping may be required in file format then derived classes should overwrite this method and call _setNeedsByteSwapping() to make get*BitUWordInLocalEndianess() methods work correctly. More...
 
MLErrorCode loadWaterColumnPackage (PCLR2SonicWCLoader &updateObject, MLuint64 workMemoryHint=5000000000)
 After opening the file this loads all WaterColumnPackages of the file into memory. More...
 
 ~R2SonicWCLoader () override
 Destructor. More...
 
void reset ()
 Closes and resets internals. More...
 
std::string getStringDump (const MLint maxPackets=-1, const MLint maxBeams=-1, const MLint maxSamplesPerBeam=-1, const std::string &prefix="", const std::string &sep=" ", const bool showFirstOfEachPacketTypeOnly=false) const
 Convert content to a human readable string with the prefix prefix before all lines and separator sep between subcomponents. More...
 
virtual std::string getAsString (const std::string &prefix="", const std::string &sep=", ", const size_t maxNumBinaryEntries=8, const size_t maxNumStringEntries=20) const override
 Default implementation of virtual base class method which uses getStringDump with maxNumBinaryEntries for maxPackets, maxBeams, and maxSamplesPerBeam. More...
 
const WaterColumnDataSetgetLoadedWaterColumnPackage () const
 Returns the read-only pointer to the currently loaded WaterColumnDataSet if there is one or nullptr otherwise. More...
 
- Public Member Functions inherited from ml::ByteDataReader
 ByteDataReader ()
 Default constructor which gets its settings later. More...
 
 ByteDataReader (const std::string &fileName)
 Constructor already setting the file name. More...
 
virtual ~ByteDataReader ()
 Destructor (automatically closes the current open file if there is any and clear allocated subimage data). More...
 
virtual std::string getFileName () const
 Returns the currently used file name or "" on default case. More...
 
virtual void setFileName (const std::string &fileName)
 Sets the new file name. More...
 
virtual bool isOpen () const
 Returns true if the file is open, otherwise false. More...
 
virtual void close ()
 Closes the file if it was open, otherwise the call is ignored. More...
 
virtual bool isGood () const
 Returns true if the recent operations since the last clearState() call were successful. More...
 
virtual std::string getErrorState () const
 Returns the current state string which is non empty on any error, empty otherwise. More...
 
virtual void clearErrorState ()
 Resets the error state to success, i.e. to an empty string. More...
 
virtual void setIndent (const std::string &indent)
 Sets the default indentation string for tag dumps. More...
 
virtual const std::string & getIndent () const
 The default indentation string for tag dumps. More...
 
bool needsByteSwapping () const
 Returns true if raw file data needs byte swapping, otherwise false; needs to be set with _setNeedsByteSwapping when opening the file in derived classes. More...
 
virtual void prefetch ()
 Loads all file content into memory to avoid expensive file descriptor access on each get*Word call. More...
 
virtual const MLuint8getPrefetchData () const
 Returns pointer to prefetch data (or nullptr if not available). More...
 
virtual void clearPrefetchData ()
 If any data is in the prefetch data memory then it is freed. More...
 
MLuint8 get8BitUWord (MLuint64 pos) const
 Read an unsigned 8 bit word from position pos. More...
 
MLuint16 get16BitUWord (MLuint64 pos) const
 Read an unsigned 16 bit word from position pos. More...
 
MLuint16 get16BitUWordInLocalEndianess (MLuint64 pos) const
 Read an unsigned 16 bit word from position pos and convert it in local endianness. More...
 
MLuint32 get32BitUWord (MLuint64 pos) const
 Read an unsigned 32 bit word from position pos. More...
 
MLuint32 get32BitUWordInLocalEndianess (MLuint64 pos) const
 Read an unsigned 32 bit word from position pos and convert it in local endianness. More...
 
MLuint64 get64BitUWord (MLuint64 pos) const
 Read an unsigned 64 bit word from position pos. More...
 
MLuint64 get64BitUWordInLocalEndianess (MLuint64 pos) const
 Read an unsigned 64 bit word from position pos and convert it in local endianness. More...
 
std::string getNonTerminatedDataAsString (MLuint originPosition, MLuint numChars) const
 Return a non-null terminated data area starting at position originPosition of length numChars as std::string. More...
 
MLuint8getDataChunk (MLuint64 pos, MLuint64 numBytes) const
 Reads numBytes from position pos in the file and returns it as allocated data chunk which has to be freed with MLFree(). More...
 
const MLuint8getPrefetchDataChunk (MLuint64 pos, MLuint64 numBytes) const
 Returns a data pointer to position pos with size numBytes in the prefetch data if available and if chunk size is sufficient. More...
 
MLint getFileSizeFromCurrentDescriptor ()
 Returns MLFileGetSizeFromDescriptor(_getFileDescriptor()). More...
 
void appendStringToState (const std::string &errDesc) const
 Appends the given string to error state string (which also sets bad read state). More...
 

Protected Member Functions

MLErrorCode loadWaterColumnPackage (MLuint64 &waterColumnDataBaseOffset, WaterColumnDataSet &waterColumnPackage)
 Loads a WaterColumnPackage from the file position WaterColumnPackageBaseOffset. More...
 
- Protected Member Functions inherited from ml::ByteDataReader
int _getFileDescriptor () const
 Returns the current file descriptor. More...
 
void _appendErrNoToState (const std::string &errDesc) const
 Appends the given string as error description, translates errno to an MLErrorCode an also adds that state as an error description. More...
 
void _setNeedsByteSwapping (bool needsSwapping)
 To se set to true in open() by derived classes if raw file data needs byte swapping, otherwise it should be set to false; defaults to false. More...
 

Detailed Description

Class to read R2Sonic water column sonar data.

Definition at line 33 of file mlR2SonicWCLoader.h.

Constructor & Destructor Documentation

◆ R2SonicWCLoader()

ml::R2SonicWC::R2SonicWCLoader::R2SonicWCLoader ( )

Default constructor creating an instance with empty fileName and closed loader.

◆ ~R2SonicWCLoader()

ml::R2SonicWC::R2SonicWCLoader::~R2SonicWCLoader ( )
override

Destructor.

Member Function Documentation

◆ getAsString()

virtual std::string ml::R2SonicWC::R2SonicWCLoader::getAsString ( const std::string &  prefix = "",
const std::string &  sep = ", ",
const size_t  maxNumBinaryEntries = 8,
const size_t  maxNumStringEntries = 20 
) const
overridevirtual

Default implementation of virtual base class method which uses getStringDump with maxNumBinaryEntries for maxPackets, maxBeams, and maxSamplesPerBeam.

Reimplemented from ml::ByteDataReader.

◆ getLoadedWaterColumnPackage()

const WaterColumnDataSet& ml::R2SonicWC::R2SonicWCLoader::getLoadedWaterColumnPackage ( ) const

Returns the read-only pointer to the currently loaded WaterColumnDataSet if there is one or nullptr otherwise.

◆ getStringDump()

std::string ml::R2SonicWC::R2SonicWCLoader::getStringDump ( const MLint  maxPackets = -1,
const MLint  maxBeams = -1,
const MLint  maxSamplesPerBeam = -1,
const std::string &  prefix = "",
const std::string &  sep = " ",
const bool  showFirstOfEachPacketTypeOnly = false 
) const

Convert content to a human readable string with the prefix prefix before all lines and separator sep between subcomponents.

Parameters
maxPacketsThe maximum number of packets to dump.
maxBeamsThe maximum number of beams to dump.
maxSamplesPerBeamThe maximum number of samples to dump of each beam.
prefixA string added at begin of each line.
sepA separator string to be printed between values printed in one line.
showFirstOfEachPacketTypeOnlyIf enabled then only the first of each section type is shown (if available); in enabled case the maxPackets value is ignored (default is false). If more than the allowed number of values exist in data then "..." is dumped followed by a comment showing the number of skipped entries.

◆ loadWaterColumnPackage() [1/2]

MLErrorCode ml::R2SonicWC::R2SonicWCLoader::loadWaterColumnPackage ( MLuint64 waterColumnDataBaseOffset,
WaterColumnDataSet waterColumnPackage 
)
protected

Loads a WaterColumnPackage from the file position WaterColumnPackageBaseOffset.

Parameters
waterColumnDataBaseOffsetThe first byte of the WaterColumnPackage in the file, where the number of bytes of the WaterColumnPackage should be stored; incremented to the position of the next WaterColumnPackage after return.
waterColumnPackageFilled with the information from file on success, otherwise undefined.
Returns
ML_RESULT_OK if the WaterColumnPackage could successfully be loaded and stored in WaterColumnPackage, otherwise another error code describing the problem.

◆ loadWaterColumnPackage() [2/2]

MLErrorCode ml::R2SonicWC::R2SonicWCLoader::loadWaterColumnPackage ( PCLR2SonicWCLoader updateObject,
MLuint64  workMemoryHint = 5000000000 
)

After opening the file this loads all WaterColumnPackages of the file into memory.

Optionally a callback function with user data pointer can be passed. Must get a shared pointer explicitly to be able to store a shared reference to the loader to be able to make use of it later for (re/un)mapping data Mx data sections on demand from with the loaded WaterColumnDateSet.

Parameters
updateObjectThe object on which updateProgress shall be performed.
workMemoryHintSame meaning as documented for PCLR2SonicLoaderModule::_workingMemoryHintFld.
Returns
ML_RESULT_OK on success, otherwise an error code describing the problem.

◆ open()

void ml::R2SonicWC::R2SonicWCLoader::open ( )
overridevirtual

Opens the file if possible, isGood() will return true on success, otherwise false; if byte swapping may be required in file format then derived classes should overwrite this method and call _setNeedsByteSwapping() to make get*BitUWordInLocalEndianess() methods work correctly.

Reimplemented from ml::ByteDataReader.

◆ reset()

void ml::R2SonicWC::R2SonicWCLoader::reset ( )

Closes and resets internals.


The documentation for this class was generated from the following file: