1 #ifndef DBALLE_DB_SQL_REPINFO_H
2 #define DBALLE_DB_SQL_REPINFO_H
57 Cache(
int id,
const std::string& memo,
const std::string& desc,
int prio,
const std::string& descriptor,
int tablea);
60 void dump(FILE* out)
const;
71 bool operator<(
const Memoidx& memo)
const;
96 int get_id(
const char* rep_memo);
117 void update(
const char* deffile,
int* added,
int* deleted,
int* updated);
142 virtual void dump(FILE* out) = 0;
164 void cache_append(
unsigned id,
const char* memo,
const char* desc,
int prio,
const char* descriptor,
int tablea);
173 virtual int id_use_count(
unsigned id,
const char* name) = 0;
virtual void insert_auto_entry(const char *memo)=0
Create an automatic entry for a missing memo, and insert it in the database.
unsigned id
Report code.
Definition: sql/repinfo.h:33
std::vector< int > ids_by_prio(const core::Query &rec)
Return a vector of IDs matching the priority constraints in the given record.
virtual void insert_entry(const repinfo::Cache &entry)=0
Insert an entry using the new_* fields of entry.
int get_priority(int id)
Get the priority for a given ID; returns INT_MAX if id is not valid.
int obtain_id(const char *memo)
Get the id of a repinfo entry given its name.
virtual void update_entry(const repinfo::Cache &entry)=0
Update an entry using the new_* fields of entry.
std::string new_desc
New report description used when updating the repinfo table.
Definition: sql/repinfo.h:49
std::string new_descriptor
New report descriptor used when updating the repinfo table.
Definition: sql/repinfo.h:53
std::vector< repinfo::Cache > cache
Cache of table entries.
Definition: sql/repinfo.h:146
virtual int id_use_count(unsigned id, const char *name)=0
Return how many time this ID is used in the database.
Key/value store where keys are strings and values are wreport variables.
Definition: record.h:16
Standard dballe::Query implementation.
Definition: core/query.h:29
int prio
Report priority.
Definition: sql/repinfo.h:40
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
std::string desc
Report description.
Definition: sql/repinfo.h:38
repinfo cache entry
Definition: sql/repinfo.h:30
int cache_find_by_id(unsigned id) const
Lookup a cache index by database ID. Returns -1 if not found.
const repinfo::Cache * get_by_id(unsigned id) const
Get a Cache entry by database ID.
int cache_find_by_memo(const char *memo) const
Lookup a cache index by report name. Returns -1 if not found.
void to_record(int id, Record &rec)
Fill repinfo information in a Record based on the repinfo entry with the given ID.
std::string memo
Report name.
Definition: sql/repinfo.h:36
std::vector< repinfo::Memoidx > memo_idx
rep_memo -> rep_cod reverse index
Definition: sql/repinfo.h:149
const repinfo::Cache * get_by_memo(const char *memo) const
Get a Cache entry by report name.
Fast cached access to the repinfo table.
Definition: sql/repinfo.h:77
virtual void read_cache()=0
Reread the repinfo cache from the database.
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; throws if rep_memo is not valid.
std::vector< repinfo::Cache > read_repinfo_file(const char *deffile)
Read cache entries from a repinfo file on disk.
void rebuild_memo_idx() const
Rebuild the memo_idx cache.
std::map< std::string, int > get_priorities()
Get a mapping between rep_memo and their priorities.
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.
int new_prio
New report priority used when updating the repinfo table.
Definition: sql/repinfo.h:51
unsigned new_tablea
New report A table value used when updating the repinfo table.
Definition: sql/repinfo.h:55
virtual void dump(FILE *out)=0
Dump the entire contents of the database to an output stream.
void cache_append(unsigned id, const char *memo, const char *desc, int prio, const char *descriptor, int tablea)
Append an entry to the cache.
int id
Report code.
Definition: sql/repinfo.h:69
unsigned tablea
Report A table value (currently unused)
Definition: sql/repinfo.h:44
reverse rep_memo -> rep_cod cache entry
Definition: sql/repinfo.h:64
virtual void delete_entry(unsigned id)=0
Delete a repinfo entry.
std::string descriptor
Report descriptor (currently unused)
Definition: sql/repinfo.h:42
std::string new_memo
New report name used when updating the repinfo table.
Definition: sql/repinfo.h:47
std::string memo
Report name.
Definition: sql/repinfo.h:67