libdballe  6.8
Public Member Functions | Data Fields | Protected Member Functions
dballe::db::v5::Repinfo Struct Reference

Fast cached access to the repinfo table. More...

#include <repinfo.h>

Inheritance diagram for dballe::db::v5::Repinfo:
dballe::db::v6::Repinfo

Public Member Functions

 Repinfo (Connection *conn)
 
void invalidate_cache ()
 Invalidate the repinfo cache. More...
 
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. More...
 
int get_id (const char *memo) const
 Get the id of a repinfo entry given its name. More...
 
int obtain_id (const char *memo)
 Get the id of a repinfo entry given its name. More...
 
bool has_id (unsigned id) const
 Check if the database contains the given rep_cod id. More...
 
const repinfo::Cacheget_by_id (unsigned id) const
 Get a repinfo cache entry by id. More...
 
const repinfo::Cacheget_by_memo (const char *memo) const
 Get a repinfo cache entry by name. More...
 
std::vector< int > ids_by_prio (const Record &rec) const
 Return a vector of IDs matching the priority constraints in the given record.
 
std::map< std::string, int > get_priorities () const
 Get a mapping between rep_memo and their priorities.
 
void dump (FILE *out)
 Dump the entire contents of the table to an output stream.
 

Data Fields

std::vector< repinfo::Cachecache
 Cache of table entries.
 
std::vector< repinfo::Memoidxmemo_idx
 rep_memo -> rep_cod reverse index
 
Connectionconn
 DB connection. More...
 

Protected Member Functions

virtual int id_use_count (unsigned id, const char *name)
 Return how many time this ID is used in the database.
 
void read_cache ()
 
void cache_append (unsigned id, const char *memo, const char *desc, int prio, const char *descriptor, int tablea)
 
void rebuild_memo_idx () const
 
int cache_find_by_memo (const char *memo) const
 
int cache_find_by_id (unsigned id) const
 
std::vector< repinfo::Cacheread_repinfo_file (const char *deffile)
 
void insert_auto_entry (const char *memo)
 Create an automatic entry for a missing memo, and insert it in the database.
 

Detailed Description

Fast cached access to the repinfo table.

Member Function Documentation

const repinfo::Cache* dballe::db::v5::Repinfo::get_by_id ( unsigned  id) const

Get a repinfo cache entry by id.

Parameters
idid to query
Returns
The Cache structure found, or NULL if none was found.
const repinfo::Cache* dballe::db::v5::Repinfo::get_by_memo ( const char *  memo) const

Get a repinfo cache entry by name.

Parameters
memoname to query
Returns
The Cache structure found, or NULL if none was found.
int dballe::db::v5::Repinfo::get_id ( const char *  memo) const

Get the id of a repinfo entry given its name.

Parameters
memoThe name to query
Returns
The resulting id. It will always be a valid one, because the functions fails if memo is not found.
bool dballe::db::v5::Repinfo::has_id ( unsigned  id) const

Check if the database contains the given rep_cod id.

Parameters
idid to check
Returns
true if id exists, else false.
void dballe::db::v5::Repinfo::invalidate_cache ( )

Invalidate the repinfo cache.

To be called if the repinfo table is modified externally; for example, when the table is recreated on database reset.

int dballe::db::v5::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.

Parameters
memoThe name to query
Returns
The resulting id.
void dballe::db::v5::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.

Parameters
ridba_db_repinfo used to update the database
deffilePathname of the file to use for the update. The NULL value is accepted and means to use the default configure repinfo.csv file.
Return values
addedNumber of entries that have been added during the update.
deletedNumber of entries that have been deleted during the update.
updatedNumber of entries that have been updated during the update.

Field Documentation

Connection* dballe::db::v5::Repinfo::conn

DB connection.

The pointer is assumed always valid during the lifetime of the object


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