JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
Loading...
Searching...
No Matches

this represents one chunk of memory which can represent one or more columns of data for JKQTBasePlotter. See JKQTPDatastore for more information. More...

#include <jkqtpdatastorage.h>

Public Member Functions

 JKQTPDatastoreItem (const QVector< double > &data)
 class constructor: initializes the object for internal data storage with the given data
 
 JKQTPDatastoreItem (JKQTPDatastoreItemFormat dataformat, double *data, size_t columns, size_t rows)
 class constructor: initializes the object for external data storage
 
 JKQTPDatastoreItem (JKQTPDatastoreItemFormat dataformat, double *data, size_t columns, size_t rows, bool storageType)
 class constructor: initializes the object for external data storage
 
 JKQTPDatastoreItem (size_t columns, size_t rows)
 class constructor: initializes the object for internal data storage
 
 ~JKQTPDatastoreItem ()
 class destructor: frees unfreed internal memory
 
bool append (size_t column, const QVector< double > &values)
 adds new rows to the given column. Returns true on success and false else
 
bool append (size_t column, const std::vector< double > &values)
 adds new rows to the given column. Returns true on success and false else
 
bool append (size_t column, double value)
 adds a new row to the given column. Returns true on success and false else
 
double & at (size_t column, size_t row)
 returns a reference to the data at the position (column, row ). Throws an exception when the entry does not exist!
 
const double & at (size_t column, size_t row) const
 returns a const reference to the data at the position (column, row ). Throws an exception when the entry does not exist!
 
void erase (size_t row)
 if isValid() : erase the row row
 
void erase (size_t row, size_t rowEnd)
 if isValid() : erase all rows (and including) from row to rowEnd
 
double get (size_t column, size_t row)
 returns the data at the position (column, row ).
 
size_t getColumns () const
 as data may also point to a matrix, this specifies the number of columns in this element (default: 1)
 
double * getPointer (size_t column, size_t row)
 returns the data at the position (column, row ). The column index specifies the column inside THIS item, not the global column number.
 
const double * getPointer (size_t column, size_t row) const
 returns the data at the position (column, row ). The column index specifies the column inside THIS item, not the global column number.
 
size_t getRows () const
 number of rows in this item
 
bool isVector () const
 checks whether dataformat==JKQTPDatastoreItemFormat::SingleColumn and storageType==StorageType::Vector
 
bool push_back (size_t column, double value)
 adds a new row to the given column. Returns true on success and false else
 
void resize (size_t rows_new)
 if isValid() : resize the row to have rows_new rows
 
bool resizeColumns (size_t rows)
 change the size of all columns to the givne number of rows. Returns true if the old data could be retained/saved and false if the old data was lost (which happens in most of the cases!)
 
void set (size_t column, size_t row, double value)
 set the data at the position (column, row ) to value. The column index specifies the column inside THIS item, not the global column number.
 

Protected Member Functions

 JKQTPDatastoreItem ()
 hidden default constructor
 

Private Types

enum class  StorageType {
  Internal ,
  External ,
  Vector
}
 how data is represented in this JKQTPDatastoreItem More...
 

Private Attributes

bool allocated
 Specifies whether memory for the data has been allocated. This is only used, when internal==true.
 
size_t columns
 as data may also point to a matrix, this specifies the number of columns in this element (default: 1)
 
double * data
 a pointer to the actual data
 
JKQTPDatastoreItemFormat dataformat
 memory format of the data in this item
 
QVector< double > datavec
 iif storageType is StorageType::Vector, the data is actually save here and data contains a pointer to the data in datavec
 
size_t rows
 number of rows in this item
 
StorageType storageType
 specifies whether the datastore manages the memory (true ) or whether the user application does this (false ) .
 

Detailed Description

this represents one chunk of memory which can represent one or more columns of data for JKQTBasePlotter. See JKQTPDatastore for more information.

Each chunk of memory is pointed at by a simple double* pointer data. the memory layout of the memory layout of the RAM segment pointed at by data is determined by the parameter dataformat:

the types of data in one JKQTdatastoreItem

JKQTPSingleColumn:

+-----+-----+-----+....................+-----+
|  0  |  1  |  2  |                    + N-1 |
+-----+-----+-----+....................+-----+

JKQTPMatrixColumn:

 ================= COLUMN 1 =================  ================= COLUMN 2 =================
+-----+-----+-----+....................+-----++-----+-----+-----+....................+-----+ .....
|  0  |  1  |  2  |                    + N-1 ||  0  |  1  |  2  |                    + N-1 |
+-----+-----+-----+....................+-----++-----+-----+-----+....................+-----+ .....
 =R1== =R2== =R3==                      =RN==  =R1== =R2== =R3==                      =RN==

JKQTPMatrixRow (C standard representation of matrices):

 ================== ROW  1 ==================  ================== ROW  2 ==================
+-----+-----+-----+....................+-----++-----+-----+-----+....................+-----+ .....
|  0  |  1  |  2  |                    + N-1 ||  0  |  1  |  2  |                    + N-1 |
+-----+-----+-----+....................+-----++-----+-----+-----+....................+-----+ .....
 =C1== =C2== =C3==                      =CN==  =C1== =C2== =C3==                      =CN==

The properties columns and rows determine how many columns and rows are represented by this item (access via getColumns() and getRows() ). This class may manage chunks of "internal" and "external" memory (which is indicated by the boolean property internal. Internal memory will be allocated (in the constructor) and freed (in the destructor) by this object. External memory may be accessed via this class, but will neither by allocated nor freed. These tasks are up to the user. Use this option, if you don't want to generate copies of huge datasets, or you want to change the data while the program is running and don't want to do the change at more than one spot.

you can use get() and set() to access the memory chunc.

See also
JKQTPDatastore

Member Enumeration Documentation

◆ StorageType

enum class JKQTPDatastoreItem::StorageType
strongprivate

how data is represented in this JKQTPDatastoreItem

Enumerator
Internal 

data is stored in an internally managed (=owned, i.e. freed in the destructor) C-array

External 

data is stored in an externally managed (=not owned) C-array

Vector 

data is stored in the internal QVector<double> datavec

Constructor & Destructor Documentation

◆ JKQTPDatastoreItem() [1/5]

JKQTPDatastoreItem::JKQTPDatastoreItem ( )
protected

hidden default constructor

◆ JKQTPDatastoreItem() [2/5]

JKQTPDatastoreItem::JKQTPDatastoreItem ( size_t  columns,
size_t  rows 
)

class constructor: initializes the object for internal data storage

◆ JKQTPDatastoreItem() [3/5]

JKQTPDatastoreItem::JKQTPDatastoreItem ( const QVector< double > &  data)

class constructor: initializes the object for internal data storage with the given data

◆ JKQTPDatastoreItem() [4/5]

JKQTPDatastoreItem::JKQTPDatastoreItem ( JKQTPDatastoreItemFormat  dataformat,
double *  data,
size_t  columns,
size_t  rows 
)

class constructor: initializes the object for external data storage

◆ JKQTPDatastoreItem() [5/5]

JKQTPDatastoreItem::JKQTPDatastoreItem ( JKQTPDatastoreItemFormat  dataformat,
double *  data,
size_t  columns,
size_t  rows,
bool  storageType 
)

class constructor: initializes the object for external data storage

◆ ~JKQTPDatastoreItem()

JKQTPDatastoreItem::~JKQTPDatastoreItem ( )

class destructor: frees unfreed internal memory

Member Function Documentation

◆ append() [1/3]

bool JKQTPDatastoreItem::append ( size_t  column,
const QVector< double > &  values 
)
inline

adds new rows to the given column. Returns true on success and false else

This operation is currently only possible, if storageType==StorageType::Vector !

◆ append() [2/3]

bool JKQTPDatastoreItem::append ( size_t  column,
const std::vector< double > &  values 
)
inline

adds new rows to the given column. Returns true on success and false else

This operation is currently only possible, if storageType==StorageType::Vector !

◆ append() [3/3]

bool JKQTPDatastoreItem::append ( size_t  column,
double  value 
)
inline

adds a new row to the given column. Returns true on success and false else

This operation is currently only possible, if storageType==StorageType::Vector !

◆ at() [1/2]

double & JKQTPDatastoreItem::at ( size_t  column,
size_t  row 
)
inline

returns a reference to the data at the position (column, row ). Throws an exception when the entry does not exist!

Note
The column index specifies the column inside THIS item, not the global column number.

◆ at() [2/2]

const double & JKQTPDatastoreItem::at ( size_t  column,
size_t  row 
) const
inline

returns a const reference to the data at the position (column, row ). Throws an exception when the entry does not exist!

Note
The column index specifies the column inside THIS item, not the global column number.

◆ erase() [1/2]

void JKQTPDatastoreItem::erase ( size_t  row)
inline

if isValid() : erase the row row

◆ erase() [2/2]

void JKQTPDatastoreItem::erase ( size_t  row,
size_t  rowEnd 
)
inline

if isValid() : erase all rows (and including) from row to rowEnd

◆ get()

double JKQTPDatastoreItem::get ( size_t  column,
size_t  row 
)
inline

returns the data at the position (column, row ).

Note
The column index specifies the column inside THIS item, not the global column number.

◆ getColumns()

size_t JKQTPDatastoreItem::getColumns ( ) const
inline

as data may also point to a matrix, this specifies the number of columns in this element (default: 1)

◆ getPointer() [1/2]

double * JKQTPDatastoreItem::getPointer ( size_t  column,
size_t  row 
)
inline

returns the data at the position (column, row ). The column index specifies the column inside THIS item, not the global column number.

◆ getPointer() [2/2]

const double * JKQTPDatastoreItem::getPointer ( size_t  column,
size_t  row 
) const
inline

returns the data at the position (column, row ). The column index specifies the column inside THIS item, not the global column number.

◆ getRows()

size_t JKQTPDatastoreItem::getRows ( ) const
inline

number of rows in this item

◆ isVector()

bool JKQTPDatastoreItem::isVector ( ) const
inline

checks whether dataformat==JKQTPDatastoreItemFormat::SingleColumn and storageType==StorageType::Vector

◆ push_back()

bool JKQTPDatastoreItem::push_back ( size_t  column,
double  value 
)
inline

adds a new row to the given column. Returns true on success and false else

This operation is currently only possible, if storageType==StorageType::Vector !

◆ resize()

void JKQTPDatastoreItem::resize ( size_t  rows_new)
inline

if isValid() : resize the row to have rows_new rows

◆ resizeColumns()

bool JKQTPDatastoreItem::resizeColumns ( size_t  rows)

change the size of all columns to the givne number of rows. Returns true if the old data could be retained/saved and false if the old data was lost (which happens in most of the cases!)

◆ set()

void JKQTPDatastoreItem::set ( size_t  column,
size_t  row,
double  value 
)
inline

set the data at the position (column, row ) to value. The column index specifies the column inside THIS item, not the global column number.

Member Data Documentation

◆ allocated

bool JKQTPDatastoreItem::allocated
private

Specifies whether memory for the data has been allocated. This is only used, when internal==true.

◆ columns

size_t JKQTPDatastoreItem::columns
private

as data may also point to a matrix, this specifies the number of columns in this element (default: 1)

◆ data

double* JKQTPDatastoreItem::data
private

a pointer to the actual data

◆ dataformat

JKQTPDatastoreItemFormat JKQTPDatastoreItem::dataformat
private

memory format of the data in this item

◆ datavec

QVector<double> JKQTPDatastoreItem::datavec
private

iif storageType is StorageType::Vector, the data is actually save here and data contains a pointer to the data in datavec

◆ rows

size_t JKQTPDatastoreItem::rows
private

number of rows in this item

◆ storageType

StorageType JKQTPDatastoreItem::storageType
private

specifies whether the datastore manages the memory (true ) or whether the user application does this (false ) .


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