libdballe 9.6
|
Fast cached access to the repinfo table. More...
#include <repinfo.h>
Public Member Functions | |
Repinfo (dballe::sql::Connection &conn) | |
const char * | get_rep_memo (int id) |
Get the rep_memo for a given ID; throws if id is not valud. | |
int | get_id (const char *rep_memo) |
Get the ID for a given rep_memo; returns -1 if rep_memo is not valid. | |
int | get_priority (const std::string &report) |
Get the priority for a given ID; returns INT_MAX if id is not valid. | |
void | update (const char *deffile, int *added, int *deleted, int *updated) |
Update the report type information in the database using the data from the given file. | |
std::map< std::string, int > | get_priorities () |
Get a mapping between rep_memo and their priorities. | |
std::vector< int > | ids_by_prio (const core::Query &rec) |
Return a vector of IDs matching the priority constraints in the given record. | |
int | obtain_id (const char *memo) |
Get the id of a repinfo entry given its name. | |
virtual void | dump (FILE *out)=0 |
Dump the entire contents of the database to an output stream. | |
virtual void | read_cache ()=0 |
Reread the repinfo cache from the database FIXME: needed when rolling back a transaction, won't be needed anymore when repinfo is moved to Transaction instead of db. | |
Public Attributes | |
dballe::sql::Connection & | conn |
Protected Member Functions | |
const repinfo::Cache * | get_by_id (unsigned id) const |
Get a Cache entry by database ID. | |
const repinfo::Cache * | get_by_memo (const char *memo) const |
Get a Cache entry by report name. | |
int | cache_find_by_id (unsigned id) const |
Lookup a cache index by database ID. Returns -1 if not found. | |
int | cache_find_by_memo (const char *memo) const |
Lookup a cache index by report name. Returns -1 if not found. | |
void | cache_append (unsigned id, const char *memo, const char *desc, int prio, const char *descriptor, int tablea) |
Append an entry to the cache. | |
void | rebuild_memo_idx () const |
Rebuild the memo_idx cache. | |
std::vector< repinfo::Cache > | read_repinfo_file (const char *deffile) |
Read cache entries from a repinfo file on disk. | |
virtual int | id_use_count (unsigned id, const char *name)=0 |
Return how many time this ID is used in the database. | |
virtual void | delete_entry (unsigned id)=0 |
Delete a repinfo entry. | |
virtual void | update_entry (const repinfo::Cache &entry)=0 |
Update an entry using the new_* fields of entry. | |
virtual void | insert_entry (const repinfo::Cache &entry)=0 |
Insert an entry using the new_* fields of entry. | |
virtual void | insert_auto_entry (const char *memo)=0 |
Create an automatic entry for a missing memo, and insert it in the database. | |
Protected Attributes | |
std::vector< repinfo::Cache > | cache |
Cache of table entries. | |
std::vector< repinfo::Memoidx > | memo_idx |
rep_memo -> rep_cod reverse index | |
Fast cached access to the repinfo table.
|
protectedpure virtual |
Delete a repinfo entry.
Implemented in dballe::db::v7::mysql::MySQLRepinfoV7, dballe::db::v7::postgresql::PostgreSQLRepinfo, and dballe::db::v7::sqlite::SQLiteRepinfoV7.
|
pure virtual |
Dump the entire contents of the database to an output stream.
Implemented in dballe::db::v7::mysql::MySQLRepinfoV7, dballe::db::v7::postgresql::PostgreSQLRepinfo, and dballe::db::v7::sqlite::SQLiteRepinfoV7.
|
protectedpure virtual |
Return how many time this ID is used in the database.
Implemented in dballe::db::v7::mysql::MySQLRepinfoV7, dballe::db::v7::postgresql::PostgreSQLRepinfo, and dballe::db::v7::sqlite::SQLiteRepinfoV7.
|
protectedpure virtual |
Create an automatic entry for a missing memo, and insert it in the database.
Implemented in dballe::db::v7::mysql::MySQLRepinfoV7, dballe::db::v7::postgresql::PostgreSQLRepinfo, and dballe::db::v7::sqlite::SQLiteRepinfoV7.
|
protectedpure virtual |
Insert an entry using the new_* fields of entry.
Implemented in dballe::db::v7::mysql::MySQLRepinfoV7, dballe::db::v7::postgresql::PostgreSQLRepinfo, and dballe::db::v7::sqlite::SQLiteRepinfoV7.
int dballe::db::v7::Repinfo::obtain_id | ( | const char * | memo | ) |
Get the id of a repinfo entry given its name.
It creates a new entry if the memo is missing from the database.
memo | The name to query |
|
pure virtual |
Reread the repinfo cache from the database FIXME: needed when rolling back a transaction, won't be needed anymore when repinfo is moved to Transaction instead of db.
Implemented in dballe::db::v7::mysql::MySQLRepinfoV7, dballe::db::v7::postgresql::PostgreSQLRepinfo, and dballe::db::v7::sqlite::SQLiteRepinfoV7.
void dballe::db::v7::Repinfo::update | ( | const char * | deffile, |
int * | added, | ||
int * | deleted, | ||
int * | updated | ||
) |
Update the report type information in the database using the data from the given file.
deffile | Pathname of the file to use for the update. The NULL value is accepted and means to use the default configure repinfo.csv file. |
added | Number of entries that have been added during the update. |
deleted | Number of entries that have been deleted during the update. |
updated | Number of entries that have been updated during the update. |
|
protectedpure virtual |
Update an entry using the new_* fields of entry.
Implemented in dballe::db::v7::mysql::MySQLRepinfoV7, dballe::db::v7::postgresql::PostgreSQLRepinfo, and dballe::db::v7::sqlite::SQLiteRepinfoV7.