UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
tr_hdrs_cache_qsql.hpp
1 /* tr_hdrs_cache_qsql.hpp */
2 /* $Id$ */
3 #ifndef __tr_hdrs_cache_qsql_hpp
4 #define __tr_hdrs_cache_qsql_hpp
5 
6 #include <QSqlQuery>
7 #include <hds_db/base/defines.hpp>
8 #include <hds_db/base/tr_header.hpp>
10 
12 namespace hds
13 {
15  namespace db
16  {
17  class SeismicQSql;
18 
21  {
22  public:
23 
26 
31  const size_t read_cache_size,
32  const size_t write_cache_size);
33 
35  void init(SeismicQSql *pseis,
36  const size_t read_cache_size,
37  const size_t write_cache_size);
38 
42  const TrHeader& get(const DbIndex &id);
43 
46  void update(const DbIndex &id, const TrHeader &hdr);
47 
51  DbIndex append(const TrHeader &hdr);
52 
55  void clear();
56 
59  void flush();
60 
65  ErrCode lastError() const {return m_last_error;}
66 
67  protected:
68 
71 
74 
76  ErrCode m_last_error;
77 
78  QSqlQuery m_get_hdr_query;
79  QSqlQuery m_get_all_hdrs_query;
80  QSqlQuery m_update_hdr_query;
81  QSqlQuery m_append_hdr_query;
82 
83 
84  ErrCode db_get_header(const DbIndex &trace_id, TrHeader &hdr);
85 
86  ErrCode db_update_header(const DbIndex &trace_id, const TrHeader &hdr);
87 
88  ErrCode db_append_header(const TrHeader &hdr, DbIndex &trace_id);
89 
92 
93  ErrCode query2hdr(const QSqlQuery &query, TrHeader &hdr) const;
94  };
95 
96  }; // db
97 }; // hds
98 
99 #endif /* tr_hdrs_cache_qsql.hpp */
Definition: tr_hdrs_cache_qsql.hpp:20
ErrCode db_cache_all_headers(LRUCache< DbIndex, TrHeader > &hdrs_cache)
uint64_t DbIndex
Definition: defines.hpp:26
DbIndex append(const TrHeader &hdr)
ErrCode
Definition: defines.hpp:46
Definition: seismic_qsql.hpp:24
ErrCode lastError() const
Definition: tr_hdrs_cache_qsql.hpp:65
void update(const DbIndex &id, const TrHeader &hdr)
void init(SeismicQSql *pseis, const size_t read_cache_size, const size_t write_cache_size)
Definition: tr_header.hpp:17
Template cache with an LRU removal policy.
Definition: lru_cache.h:86
SeismicQSql * mp_seis
Definition: tr_hdrs_cache_qsql.hpp:73
LRUCache< DbIndex, hds::db::TrHeader > m_cache
Definition: tr_hdrs_cache_qsql.hpp:70