DP3
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
dp3::base::BdaBuffer Class Reference

#include <BdaBuffer.h>

Classes

struct  Row
 

Public Member Functions

 BdaBuffer (const BdaBuffer &other, const common::Fields &fields)
 
 BdaBuffer (std::size_t pool_size, const common::Fields &fields)
 
void AddData (const std::string &name="")
 
bool AddRow (double time, double interval, double exposure, std::size_t baseline_nr, std::size_t n_channels, std::size_t n_correlations, common::rownr_t row_nr, const std::complex< float > *data=nullptr, const bool *flags=nullptr, const float *weights=nullptr, const double *uvw=nullptr)
 
void Clear ()
 
std::complex< float > * GetData (const std::string &name="")
 
const std::complex< float > * GetData (const std::string &name="") const
 
std::complex< float > * GetData (std::size_t row, const std::string &name="")
 
const std::complex< float > * GetData (std::size_t row, const std::string &name="") const
 
std::vector< std::string > GetDataNames () const
 
bool * GetFlags ()
 
const bool * GetFlags () const
 
bool * GetFlags (std::size_t row)
 
const bool * GetFlags (std::size_t row) const
 
std::size_t GetNumberOfElements () const
 
std::size_t GetRemainingCapacity () const
 
std::vector< Row > & GetRows ()
 
const std::vector< Row > & GetRows () const
 
float * GetWeights ()
 
const float * GetWeights () const
 
float * GetWeights (std::size_t row)
 
const float * GetWeights (std::size_t row) const
 
bool HasData (const std::string &name="") const
 
bool IsMetadataEqual (const BdaBuffer &other) const
 
void MoveData (BdaBuffer &source, const std::string &source_name="", const std::string &target_name="")
 
void RemoveData (const std::string &name="")
 
 BdaBuffer (const BdaBuffer &other)=delete
 
BdaBufferoperator= (const BdaBuffer &other)=delete
 

Static Public Member Functions

static constexpr bool TimeIsEqual (double x, double y)
 
static constexpr bool TimeIsGreaterEqual (double x, double y)
 
static constexpr bool TimeIsLess (double x, double y)
 
static constexpr bool TimeIsLessEqual (double x, double y)
 

Static Public Attributes

static constexpr double kTimeTolerance = 2.0e-6
 

Constructor & Destructor Documentation

◆ BdaBuffer() [1/3]

dp3::base::BdaBuffer::BdaBuffer ( std::size_t  pool_size,
const common::Fields fields 
)
explicit

Create a new BdaBuffer.

Parameters
pool_sizeSize of the memory pool for this buffer. (number of items)
fieldsThe fields that should be enabled in this buffer. The 'data' field enables the main visibility buffer. The 'uvw' field is always enabled in a BdaBuffer.

◆ BdaBuffer() [2/3]

dp3::base::BdaBuffer::BdaBuffer ( const BdaBuffer other)
delete

Disabling the default copy constructor and copy assignment operator avoids expensive implicit copies.

◆ BdaBuffer() [3/3]

dp3::base::BdaBuffer::BdaBuffer ( const BdaBuffer other,
const common::Fields fields 
)

Custom copy constructor. This constructor sets the memory pool size of the new buffer to the actual memory usage of the other buffer. Adding new rows to the new buffer is therefore not possible.

Parameters
otherAn existing BdaBuffer.
fieldsThe fields that are enabled in the new buffer. If 'other' does not have the field, memory is allocated for the field and the content is not initialized.

Member Function Documentation

◆ AddData()

void dp3::base::BdaBuffer::AddData ( const std::string &  name = "")
inline

Adds a visibility buffer. If the buffer already exists, nothing happens. If the buffer is created, its visibility values are not initialized.

Parameters
nameName for the new buffer. If empty, adds the main data buffer. The effect is then equal to enabling the 'data' field.

◆ AddRow()

bool dp3::base::BdaBuffer::AddRow ( double  time,
double  interval,
double  exposure,
std::size_t  baseline_nr,
std::size_t  n_channels,
std::size_t  n_correlations,
common::rownr_t  row_nr,
const std::complex< float > *  data = nullptr,
const bool *  flags = nullptr,
const float *  weights = nullptr,
const double *  uvw = nullptr 
)

Add a measurement line to the buffer.

Measurement lines have to obey the following ordering constraint: If a row starts at time T, all rows that end before or at T must be added before this row. A new row thus may not have an end time before or equal to the start time of the last row.

Use GetRemainingCapacity() for checking if the buffer has enough space.

Parameters
dataPointer to visibilities for the row. If null, initializes the visibilities to zero.
flagsPointer to flags for the row. If null, initializes the flags to false.
weightsPointer to weights for the row. If null, initializes the weights to zero.
Returns
True if the line is added. False if the buffer is full.
Exceptions
std::invalid_argumentIf the row ordering is incorrect.

◆ Clear()

void dp3::base::BdaBuffer::Clear ( )

Removes all rows from the buffer.

The memory pool capacity of the buffer remains unchanged. All data buffers also remain. Keeping all internal buffers allows reusing the BdaBuffer.

◆ GetData() [1/4]

std::complex<float>* dp3::base::BdaBuffer::GetData ( const std::string &  name = "")

◆ GetData() [2/4]

const std::complex<float>* dp3::base::BdaBuffer::GetData ( const std::string &  name = "") const

◆ GetData() [3/4]

std::complex<float>* dp3::base::BdaBuffer::GetData ( std::size_t  row,
const std::string &  name = "" 
)

◆ GetData() [4/4]

const std::complex<float>* dp3::base::BdaBuffer::GetData ( std::size_t  row,
const std::string &  name = "" 
) const

◆ GetDataNames()

std::vector<std::string> dp3::base::BdaBuffer::GetDataNames ( ) const
inline
Returns
The sorted names of all visibility buffers.

◆ GetFlags() [1/4]

bool* dp3::base::BdaBuffer::GetFlags ( )
inline

◆ GetFlags() [2/4]

const bool* dp3::base::BdaBuffer::GetFlags ( ) const
inline

◆ GetFlags() [3/4]

bool* dp3::base::BdaBuffer::GetFlags ( std::size_t  row)
inline

◆ GetFlags() [4/4]

const bool* dp3::base::BdaBuffer::GetFlags ( std::size_t  row) const
inline

◆ GetNumberOfElements()

std::size_t dp3::base::BdaBuffer::GetNumberOfElements ( ) const
inline

Determine the number of stored elements in all rows.

Returns
The total number of elements in this buffer.

◆ GetRemainingCapacity()

std::size_t dp3::base::BdaBuffer::GetRemainingCapacity ( ) const
inline

Determine the remaining capacity.

Returns
The remaining capacity (in number of elements) for this buffer.

◆ GetRows() [1/2]

std::vector<Row>& dp3::base::BdaBuffer::GetRows ( )
inline

◆ GetRows() [2/2]

const std::vector<Row>& dp3::base::BdaBuffer::GetRows ( ) const
inline

◆ GetWeights() [1/4]

float* dp3::base::BdaBuffer::GetWeights ( )
inline

◆ GetWeights() [2/4]

const float* dp3::base::BdaBuffer::GetWeights ( ) const
inline

◆ GetWeights() [3/4]

float* dp3::base::BdaBuffer::GetWeights ( std::size_t  row)
inline

◆ GetWeights() [4/4]

const float* dp3::base::BdaBuffer::GetWeights ( std::size_t  row) const
inline

◆ HasData()

bool dp3::base::BdaBuffer::HasData ( const std::string &  name = "") const
inline
Returns
If the BdaBuffer has a visibility buffer for the given name.

◆ IsMetadataEqual()

bool dp3::base::BdaBuffer::IsMetadataEqual ( const BdaBuffer other) const

◆ MoveData()

void dp3::base::BdaBuffer::MoveData ( BdaBuffer source,
const std::string &  source_name = "",
const std::string &  target_name = "" 
)

Moves a visibility buffer into the current BdaBuffer. If the target visibility buffer already exists, it is overwritten.

Parameters
sourceThe source BdaBuffer. It may equal the current BdaBuffer. In that case, rename a visibility buffer.
source_nameName of a visibility buffer in 'source'.
target_nameName of the target visibility buffer.

◆ operator=()

BdaBuffer& dp3::base::BdaBuffer::operator= ( const BdaBuffer other)
delete

◆ RemoveData()

void dp3::base::BdaBuffer::RemoveData ( const std::string &  name = "")
inline

Removes a visibility buffer. If the buffer does not exist, nothing happens.

Parameters
nameName of the buffer to remove. If empty, removes the main data buffer. The effect is then equal to disabling the 'data' field.

◆ TimeIsEqual()

static constexpr bool dp3::base::BdaBuffer::TimeIsEqual ( double  x,
double  y 
)
inlinestaticconstexpr

◆ TimeIsGreaterEqual()

static constexpr bool dp3::base::BdaBuffer::TimeIsGreaterEqual ( double  x,
double  y 
)
inlinestaticconstexpr

◆ TimeIsLess()

static constexpr bool dp3::base::BdaBuffer::TimeIsLess ( double  x,
double  y 
)
inlinestaticconstexpr

◆ TimeIsLessEqual()

static constexpr bool dp3::base::BdaBuffer::TimeIsLessEqual ( double  x,
double  y 
)
inlinestaticconstexpr

Member Data Documentation

◆ kTimeTolerance

constexpr double dp3::base::BdaBuffer::kTimeTolerance = 2.0e-6
staticconstexpr

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