libdballe 9.6
Public Member Functions | Static Public Member Functions | List of all members
dballe::db::DB Class Referenceabstract
Inheritance diagram for dballe::db::DB:
dballe::DB dballe::db::v7::DB

Public Member Functions

virtual db::Format format () const =0
 Return the format of this DB.
 
virtual void disappear ()=0
 Remove all our traces from the database, if applicable.
 
virtual void reset (const char *repinfo_file=0)=0
 Reset the database, removing all existing Db-All.e tables and re-creating them empty.
 
virtual std::shared_ptr< dballe::db::Transactiontest_transaction (bool readonly=false)=0
 Same as transaction(), but the resulting transaction will throw an exception if commit is called.
 
virtual void vacuum ()=0
 Perform database cleanup operations.
 
virtual void attr_query_station (int data_id, std::function< void(std::unique_ptr< wreport::Var >)> &&dest)
 Query attributes on a station value.
 
virtual void attr_query_data (int data_id, std::function< void(std::unique_ptr< wreport::Var >)> &&dest)
 Query attributes on a data value.
 
void attr_insert_station (int data_id, const Values &attrs)
 Insert new attributes on a station value.
 
void attr_insert_data (int data_id, const Values &attrs)
 Insert new attributes on a data value.
 
void attr_remove_station (int data_id, const db::AttrList &attrs)
 Delete attributes from a station value.
 
void attr_remove_data (int data_id, const db::AttrList &attrs)
 Delete attributes from a data value.
 
void dump (FILE *out)
 Dump the entire contents of the database to an output stream.
 
virtual void print_info (FILE *out)
 Print informations about the database to the given output stream.
 
- Public Member Functions inherited from dballe::DB
virtual std::shared_ptr< dballe::Transactiontransaction (bool readonly=false)=0
 Begin a transaction on this database, and return a Transaction object that can be used to commit it.
 
virtual std::shared_ptr< CursorStationquery_stations (const Query &query)
 Start a query on the station variables archive.
 
virtual std::shared_ptr< CursorStationDataquery_station_data (const Query &query)
 Query the station variables in the database.
 
virtual std::shared_ptr< CursorDataquery_data (const Query &query)
 Query the database.
 
virtual std::shared_ptr< CursorSummaryquery_summary (const Query &query)
 Query a summary of what the result would be for a query.
 
virtual std::shared_ptr< CursorMessagequery_messages (const Query &query)
 Query the database returning the matching data as Message objects.
 
void remove_all ()
 Remove all data from the database.
 
void remove_station_data (const Query &query)
 Remove data from the database.
 
void remove_data (const Query &query)
 Remove data from the database.
 
void import_message (const Message &message, const DBImportOptions &opts=DBImportOptions::defaults)
 Import a Message into the DB-All.e database.
 
void import_messages (const std::vector< std::shared_ptr< Message > > &messages, const DBImportOptions &opts=DBImportOptions::defaults)
 Import Messages into the DB-All.e database.
 
void insert_station_data (Data &vals, const DBInsertOptions &opts=DBInsertOptions::defaults)
 Insert station values into the database.
 
void insert_data (Data &vals, const DBInsertOptions &opts=DBInsertOptions::defaults)
 Insert data values into the database.
 

Static Public Member Functions

static db::Format get_default_format ()
 
static void set_default_format (db::Format format)
 
static std::shared_ptr< DBconnect_from_file (const char *pathname)
 Create from a SQLite file pathname.
 
static std::shared_ptr< DBconnect_memory ()
 Create an in-memory database.
 
static std::shared_ptr< DBcreate (std::shared_ptr< sql::Connection > conn)
 Create a database from an open Connection.
 
static bool is_url (const char *str)
 Return TRUE if the string looks like a DB URL.
 
static const char * default_repinfo_file ()
 Return the default repinfo file pathname.
 
static std::unique_ptr< db::DBdowncast (std::unique_ptr< dballe::DB > db)
 Downcast a unique_ptr pointer.
 
static std::shared_ptr< db::DBdowncast (std::shared_ptr< dballe::DB > db)
 Downcast a shared_ptr pointer.
 
- Static Public Member Functions inherited from dballe::DB
static std::shared_ptr< DBconnect (const DBConnectOptions &opts)
 Create a new DB.
 

Member Function Documentation

◆ attr_insert_data()

void dballe::db::DB::attr_insert_data ( int  data_id,
const Values attrs 
)

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

◆ attr_insert_station()

void dballe::db::DB::attr_insert_station ( int  data_id,
const Values attrs 
)

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

◆ attr_query_data()

virtual void dballe::db::DB::attr_query_data ( int  data_id,
std::function< void(std::unique_ptr< wreport::Var >)> &&  dest 
)
virtual

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

◆ attr_query_station()

virtual void dballe::db::DB::attr_query_station ( int  data_id,
std::function< void(std::unique_ptr< wreport::Var >)> &&  dest 
)
virtual

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

◆ attr_remove_data()

void dballe::db::DB::attr_remove_data ( int  data_id,
const db::AttrList &  attrs 
)

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.

◆ attr_remove_station()

void dballe::db::DB::attr_remove_station ( int  data_id,
const db::AttrList &  attrs 
)

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.

◆ connect_from_file()

static std::shared_ptr< DB > dballe::db::DB::connect_from_file ( const char *  pathname)
static

Create from a SQLite file pathname.

Parameters
pathnameThe pathname to a SQLite file

◆ disappear()

virtual void dballe::db::DB::disappear ( )
pure virtual

Remove all our traces from the database, if applicable.

After this has been called, all other DB methods except for reset() will fail.

Implemented in dballe::db::v7::DB.

◆ format()

virtual db::Format dballe::db::DB::format ( ) const
pure virtual

Return the format of this DB.

Implemented in dballe::db::v7::DB.

◆ is_url()

static bool dballe::db::DB::is_url ( const char *  str)
static

Return TRUE if the string looks like a DB URL.

Parameters
strThe string to test
Returns
true if it looks like a URL, else false

◆ reset()

virtual void dballe::db::DB::reset ( const char *  repinfo_file = 0)
pure virtual

Reset the database, removing all existing Db-All.e tables and re-creating them empty.

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.

Implemented in dballe::db::v7::DB.

◆ test_transaction()

virtual std::shared_ptr< dballe::db::Transaction > dballe::db::DB::test_transaction ( bool  readonly = false)
pure virtual

Same as transaction(), but the resulting transaction will throw an exception if commit is called.

Used for tests.

Implemented in dballe::db::v7::DB.

◆ vacuum()

virtual void dballe::db::DB::vacuum ( )
pure virtual

Perform database cleanup operations.

Orphan values are currently:

  • context values for which no data exists
  • station values for which no context exists

Depending on database size, this routine can take a few minutes to execute.

Implemented in dballe::db::v7::DB.


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