libdballe  9.11
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
dballe::db::v7::Transaction Struct Reference
Inheritance diagram for dballe::db::v7::Transaction:
dballe::db::Transaction dballe::Transaction dballe::db::v7::TestTransaction

Public Types

typedef v7::DB DB
 

Public Member Functions

 Transaction (std::shared_ptr< v7::DB > db, std::unique_ptr< dballe::sql::Transaction > sql_transaction)
 
 Transaction (const Transaction &)=delete
 
 Transaction (Transaction &&)=delete
 
Transactionoperator= (const Transaction &)=delete
 
Transactionoperator= (Transaction &&)=delete
 
v7::Repinforepinfo ()
 Access the repinfo table.
 
v7::Stationstation ()
 Access the station table.
 
v7::LevTrlevtr ()
 Access the levtr table.
 
v7::StationDatastation_data ()
 Access the station_data table.
 
v7::Datadata ()
 Access the data table.
 
void commit () override
 Commit this transaction.
 
void rollback () override
 Roll back this transaction.
 
void rollback_nothrow () noexcept override
 Roll back this transaction.
 
void clear_cached_state () override
 Clear state information cached during the transaction. More...
 
std::shared_ptr< dballe::CursorStationquery_stations (const Query &query) override
 Start a query on the station variables archive. More...
 
std::shared_ptr< dballe::CursorStationDataquery_station_data (const Query &query) override
 Query the station variables in the database. More...
 
std::shared_ptr< dballe::CursorDataquery_data (const Query &query) override
 Query the database. More...
 
std::shared_ptr< dballe::CursorSummaryquery_summary (const Query &query) override
 Query a summary of what the result would be for a query. More...
 
std::shared_ptr< dballe::CursorMessagequery_messages (const Query &query) override
 Query the database returning the matching data as Message objects. More...
 
void attr_query_station (int data_id, std::function< void(std::unique_ptr< wreport::Var >)> dest) override
 Query attributes on a station value. More...
 
void attr_query_data (int data_id, std::function< void(std::unique_ptr< wreport::Var >)> dest) override
 Query attributes on a data value. More...
 
void insert_station_data (dballe::Data &vals, const dballe::DBInsertOptions &opts=dballe::DBInsertOptions::defaults) override
 Insert station values into the database. More...
 
void insert_data (dballe::Data &vals, const dballe::DBInsertOptions &opts=dballe::DBInsertOptions::defaults) override
 Insert data values into the database. More...
 
void remove_station_data (const Query &query) override
 Remove data from the database. More...
 
void remove_data (const Query &query) override
 Remove data from the database. More...
 
void remove_station_data_by_id (int id)
 
void remove_data_by_id (int id)
 
void remove_all () override
 Remove all data from the database. More...
 
void attr_insert_station (int data_id, const Values &attrs) override
 Insert new attributes on a station value. More...
 
void attr_insert_data (int data_id, const Values &attrs) override
 Insert new attributes on a data value. More...
 
void attr_remove_station (int data_id, const db::AttrList &attrs) override
 Delete attributes from a station value. More...
 
void attr_remove_data (int data_id, const db::AttrList &attrs) override
 Delete attributes from a data value. More...
 
void import_message (const Message &message, const dballe::DBImportOptions &opts) override
 Import a Message into the DB-All.e database. More...
 
void import_messages (const std::vector< std::shared_ptr< Message >> &msgs, const dballe::DBImportOptions &opts) override
 Import Messages into the DB-All.e database. More...
 
void update_repinfo (const char *repinfo_file, int *added, int *deleted, int *updated) override
 Update the repinfo table in the database, with the data found in the given file. More...
 
void dump (FILE *out) override
 Dump the entire contents of the database to an output stream.
 

Static Public Member Functions

static Transactiondowncast (dballe::db::Transaction &transaction)
 

Public Attributes

std::shared_ptr< v7::DBdb
 
std::shared_ptr< dballe::sql::Transactionsql_transaction
 SQL-side transaction.
 
bool fired = false
 True if commit or rollback have already been called on this transaction.
 
v7::Batch batch
 Batch importer.
 
v7::Tracer< v7::trace::Transactiontrc
 Tracing system.
 

Protected Member Functions

void add_msg_to_batch (Tracer<> &trc, const Message &message, const dballe::DBImportOptions &opts)
 
void track_cursor (std::weak_ptr< dballe::Cursor > cursor)
 

Protected Attributes

v7::Repinfom_repinfo = nullptr
 Report information.
 
v7::Stationm_station = nullptr
 Station information.
 
v7::LevTrm_levtr = nullptr
 Level/timerange information.
 
v7::StationDatam_station_data = nullptr
 Station data.
 
v7::Datam_data = nullptr
 Variable data.
 
std::vector< std::weak_ptr< dballe::Cursor > > tracked_cursors
 Track active cursors to invalidate them on commit/rollback.
 

Member Function Documentation

◆ attr_insert_data()

void dballe::db::v7::Transaction::attr_insert_data ( int  data_id,
const Values attrs 
)
overridevirtual

Insert new attributes on a data value.

Parameters
data_idThe id (returned by Cursor::attr_reference_id()) used to refer to the value
attrsThe attributes to be added

Implements dballe::db::Transaction.

◆ attr_insert_station()

void dballe::db::v7::Transaction::attr_insert_station ( int  data_id,
const Values attrs 
)
overridevirtual

Insert new attributes on a station value.

Parameters
data_idThe id (returned by Cursor::attr_reference_id()) used to refer to the value
attrsThe attributes to be added

Implements dballe::db::Transaction.

◆ attr_query_data()

void dballe::db::v7::Transaction::attr_query_data ( int  data_id,
std::function< void(std::unique_ptr< wreport::Var >)>  dest 
)
overridevirtual

Query attributes on a data value.

Parameters
data_idThe id (returned by Cursor::attr_reference_id()) used to refer to the value
destThe function that will be called on each resulting attribute

Implements dballe::db::Transaction.

◆ attr_query_station()

void dballe::db::v7::Transaction::attr_query_station ( int  data_id,
std::function< void(std::unique_ptr< wreport::Var >)>  dest 
)
overridevirtual

Query attributes on a station value.

Parameters
data_idThe id (returned by Cursor::attr_reference_id()) used to refer to the value
destThe function that will be called on each resulting attribute

Implements dballe::db::Transaction.

◆ attr_remove_data()

void dballe::db::v7::Transaction::attr_remove_data ( int  data_id,
const db::AttrList &  attrs 
)
overridevirtual

Delete attributes from a data value.

Parameters
data_idThe id (returned by Cursor::attr_reference_id()) used to refer to the value
attrsArray of WMO codes of the attributes to delete. If empty, all attributes associated to the value will be deleted.

Implements dballe::db::Transaction.

◆ attr_remove_station()

void dballe::db::v7::Transaction::attr_remove_station ( int  data_id,
const db::AttrList &  attrs 
)
overridevirtual

Delete attributes from a station value.

Parameters
data_idThe id (returned by Cursor::attr_reference_id()) used to refer to the value
attrsArray of WMO codes of the attributes to delete. If empty, all attributes associated to the value will be deleted.

Implements dballe::db::Transaction.

◆ clear_cached_state()

void dballe::db::v7::Transaction::clear_cached_state ( )
overridevirtual

Clear state information cached during the transaction.

This can be used when, for example, a command that deletes data is issued that would invalidate ID information cached inside the transaction.

Implements dballe::db::Transaction.

◆ import_message()

void dballe::db::v7::Transaction::import_message ( const Message message,
const dballe::DBImportOptions opts 
)
overridevirtual

Import a Message into the DB-All.e database.

Parameters
messageThe Message to import
optsOptions controlling the import process

Implements dballe::Transaction.

◆ import_messages()

void dballe::db::v7::Transaction::import_messages ( const std::vector< std::shared_ptr< Message >> &  messages,
const dballe::DBImportOptions opts 
)
overridevirtual

Import Messages into the DB-All.e database.

Parameters
messagesThe messages to import
optsOptions controlling the import process

Reimplemented from dballe::Transaction.

◆ insert_data()

void dballe::db::v7::Transaction::insert_data ( dballe::Data data,
const dballe::DBInsertOptions opts = dballe::DBInsertOptions::defaults 
)
overridevirtual

Insert data values into the database.

The IDs of the station and all variables that were inserted will be stored in vals.

Parameters
dataThe values to insert.
optsOptions controlling the insert operation

Implements dballe::Transaction.

◆ insert_station_data()

void dballe::db::v7::Transaction::insert_station_data ( dballe::Data data,
const dballe::DBInsertOptions opts = dballe::DBInsertOptions::defaults 
)
overridevirtual

Insert station values into the database.

The IDs of the station and all variables that were inserted will be stored in vals.

Parameters
dataThe values to insert.
optsOptions controlling the insert operation

Implements dballe::Transaction.

◆ query_data()

std::shared_ptr<dballe::CursorData> dballe::db::v7::Transaction::query_data ( const Query query)
overridevirtual

Query the database.

When multiple values per variable are present, the results will be presented in increasing order of priority.

Parameters
queryThe Query selecting the data to return
Returns
The cursor to use to iterate over the results

Implements dballe::Transaction.

◆ query_messages()

std::shared_ptr<dballe::CursorMessage> dballe::db::v7::Transaction::query_messages ( const Query query)
overridevirtual

Query the database returning the matching data as Message objects.

Parameters
queryThe Query selecting the data that will go into the Message objects
Returns
The cursor to use to iterate over the results

Implements dballe::Transaction.

◆ query_station_data()

std::shared_ptr<dballe::CursorStationData> dballe::db::v7::Transaction::query_station_data ( const Query query)
overridevirtual

Query the station variables in the database.

When multiple values per variable are present, the results will be presented in increasing order of priority.

Parameters
queryThe Query selecting the station data to return
Returns
The cursor to use to iterate over the results

Implements dballe::Transaction.

◆ query_stations()

std::shared_ptr<dballe::CursorStation> dballe::db::v7::Transaction::query_stations ( const Query query)
overridevirtual

Start a query on the station variables archive.

The cursor will iterate over unique lat, lon, ident triples, and will contain all station vars. If a station var exists twice on two different networks, only one will be present: the one of the network with the highest priority.

Parameters
queryThe Query selecting the stations to return
Returns
The cursor to use to iterate over the results

Implements dballe::Transaction.

◆ query_summary()

std::shared_ptr<dballe::CursorSummary> dballe::db::v7::Transaction::query_summary ( const Query query)
overridevirtual

Query a summary of what the result would be for a query.

Parameters
queryThe Query selecting the data to summarise
Returns
The cursor to use to iterate over the results

Implements dballe::Transaction.

◆ remove_all()

void dballe::db::v7::Transaction::remove_all ( )
overridevirtual

Remove all data from the database.

This is faster than remove() with an empty record, and unlike reset() it preserves existing report information.

Implements dballe::Transaction.

◆ remove_data()

void dballe::db::v7::Transaction::remove_data ( const Query query)
overridevirtual

Remove data from the database.

Parameters
queryThe query selecting the data to remove

Implements dballe::Transaction.

◆ remove_station_data()

void dballe::db::v7::Transaction::remove_station_data ( const Query query)
overridevirtual

Remove data from the database.

Parameters
queryThe query selecting the data to remove

Implements dballe::Transaction.

◆ update_repinfo()

void dballe::db::v7::Transaction::update_repinfo ( const char *  repinfo_file,
int *  added,
int *  deleted,
int *  updated 
)
overridevirtual

Update the repinfo table in the database, with the data found in the given file.

Parameters
repinfo_fileThe name of the CSV file with the report type information data to load. The file is in CSV format with 6 columns: report code, mnemonic id, description, priority, descriptor, table A category. If repinfo_file is NULL, then the default of /etc/dballe/repinfo.csv is used.
Return values
addedThe number of repinfo entries that have been added
deletedThe number of repinfo entries that have been deleted
updatedThe number of repinfo entries that have been updated

Implements dballe::db::Transaction.


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