DAQ  1.0.0
Data Acquisition System (basic demo)
Public Member Functions | Private Attributes | List of all members
SQLiteWrapper Class Reference

#include <sqlitewrapper.h>

Inheritance diagram for SQLiteWrapper:
Inheritance graph
[legend]
Collaboration diagram for SQLiteWrapper:
Collaboration graph
[legend]

Public Member Functions

 SQLiteWrapper (const std::string &db_path)
 SQLiteWrapper create a sqlite3 connection. More...
 
 ~SQLiteWrapper () override
 ~SQLiteWrapper release the sqlite3 connection. More...
 
Err create_scheme () noexceptoverride
 create_scheme creates the database schema for sqlite3 More...
 
Err add_variable (const Variable &var) noexceptoverride
 add_variable add an entry to the variable table. More...
 
Err add_variable_value (const VarValue &var) noexceptoverride
 add_variable_value add an entry ti the vriable value table, related to an entry in the variable table. More...
 
Err fetch_variables (const std::function< void(const Variable &var, size_t index)> &send_vale) noexceptoverride
 fetch_variables get all variables. More...
 
Err fetch_variable_values (const std::string &var_name, const std::function< void(const VarValue &, size_t index)> &send_vale) noexceptoverride
 fetch_variable_values get all values related to a variable. More...
 
Err count_variable_values (const std::string &var_name, const std::function< void(size_t count)> &send_count) noexceptoverride
 count_variable_values count the number of values for a given variable. More...
 
Err fetch_variable_values (const std::string &var_name, const std::chrono::system_clock::time_point &start_data, const std::chrono::system_clock::time_point &end_date, const std::function< void(const VarValue &val, size_t index)> &send_vale) noexceptoverride
 fetch_variable_values get all values related to a variable in a date range. More...
 
virtual Err count_variable_values (const std::string &var_name, const std::chrono::system_clock::time_point &start_date, const std::chrono::system_clock::time_point &end_date, const std::function< void(size_t count)> &send_count) noexceptoverride
 count_variable_values count the number of values for a given variable in a date range. More...
 
- Public Member Functions inherited from IDataSource
 IDataSource ()=default
 
virtual ~IDataSource ()=default
 
 IDataSource (const IDataSource &)=delete
 
IDataSourceoperator= (const IDataSource &)=delete
 
 IDataSource (IDataSource &&)=default
 
IDataSourceoperator= (IDataSource &&)=default
 
virtual Err fetch_variable_values (const std::string &var_name, const std::function< void(const VarValue &val, size_t index)> &send_vale) noexcept=0
 fetch_variable_values get all values of a given variable More...
 

Private Attributes

sqlite3 * db_
 

Additional Inherited Members

- Public Types inherited from IDataSource
enum  Err { Err::Ok, Err::Failed }
 

Constructor & Destructor Documentation

SQLiteWrapper::SQLiteWrapper ( const std::string &  db_path)
explicit

SQLiteWrapper create a sqlite3 connection.

Exceptions
exceptionif any error happen.
Parameters
db_paththe path to the sqlite3 db file
See also
IDataSource

Here is the call graph for this function:

SQLiteWrapper::~SQLiteWrapper ( )
override

~SQLiteWrapper release the sqlite3 connection.

See also
SQLiteWrapper

Member Function Documentation

IDataSource::Err SQLiteWrapper::add_variable ( const Variable var)
overridevirtualnoexcept

add_variable add an entry to the variable table.

Parameters
varvariable info.
Returns
Err::Ok on success.
See also
IDataSource::add_variable

Implements IDataSource.

IDataSource::Err SQLiteWrapper::add_variable_value ( const VarValue var)
overridevirtualnoexcept

add_variable_value add an entry ti the vriable value table, related to an entry in the variable table.

Parameters
varvariable value info to be inserted.
Returns
Err::Ok on success.
See also
IDataSource::add_variable_value

Implements IDataSource.

IDataSource::Err SQLiteWrapper::count_variable_values ( const std::string &  var_name,
const std::function< void(size_t count)> &  send_count 
)
overridevirtualnoexcept

count_variable_values count the number of values for a given variable.

Parameters
var_namevariable to count related values from.
send_countget the values amount from this callback.
Returns
Err::Ok on success.

Implements IDataSource.

IDataSource::Err SQLiteWrapper::count_variable_values ( const std::string &  var_name,
const std::chrono::system_clock::time_point &  start_date,
const std::chrono::system_clock::time_point &  end_date,
const std::function< void(size_t count)> &  send_count 
)
overridevirtualnoexcept

count_variable_values count the number of values for a given variable in a date range.

Parameters
var_namevariable to count related values from.
start_databegin of the date range.
end_dateend of the date range.
send_countget the values amount from this callback.
Returns
Err::Ok on success.

Implements IDataSource.

Here is the caller graph for this function:

IDataSource::Err SQLiteWrapper::create_scheme ( )
overridevirtualnoexcept

create_scheme creates the database schema for sqlite3

a table with posible variables, a table with variable values and a relation betwen the two (a variable have many variable values).

Returns
Err::Ok on success.
See also
IDataSource::create_scheme

Implements IDataSource.

Err SQLiteWrapper::fetch_variable_values ( const std::string &  var_name,
const std::function< void(const VarValue &, size_t index)> &  send_vale 
)
overridenoexcept

fetch_variable_values get all values related to a variable.

Parameters
var_namevariable to get related values from.
send_valeget values one at a time from this callback.
Returns
Err::Ok on success.
See also
IDataSource::fetch_variable_values
IDataSource::Err SQLiteWrapper::fetch_variable_values ( const std::string &  var_name,
const std::chrono::system_clock::time_point &  start_data,
const std::chrono::system_clock::time_point &  end_date,
const std::function< void(const VarValue &val, size_t index)> &  send_vale 
)
overridevirtualnoexcept

fetch_variable_values get all values related to a variable in a date range.

Parameters
var_namevariable to get related values from.
start_databegin of the date range.
end_dateend of the date range.
send_valeget values one at a time from this callback.
Returns
Err::Ok on success.

Implements IDataSource.

IDataSource::Err SQLiteWrapper::fetch_variables ( const std::function< void(const Variable &var, size_t index)> &  send_vale)
overridevirtualnoexcept

fetch_variables get all variables.

Parameters
send_valethe variables will be send in this callback, one at a time, index is the current value index.
Returns
Err::Ok on succes

Implements IDataSource.

Member Data Documentation

sqlite3* SQLiteWrapper::db_
private

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