NCBI C++ ToolKit
psg_cache_base.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef PSG_CACHE_BASE__HPP
2 #define PSG_CACHE_BASE__HPP
3 
4 /* $Id: psg_cache_base.hpp 99744 2023-05-05 15:04:59Z saprykin $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Dmitri Dmitrienko
30  *
31  * File Description: Base class for all cache subclasses
32  *
33  */
34 
35 #include <memory>
36 #include <string>
37 #include <utility>
38 
39 #include <util/lmdbxx/lmdb++.h>
40 
41 #include <corelib/ncbistd.hpp>
42 
44 
47 
49 {
50  public:
52  : m_Txn(nullptr)
53  {
54  }
55 
56  explicit CLMDBReadOnlyTxn(lmdb::txn&& txn)
57  : m_Txn(move(txn))
58  {
59  }
60 
62  {
63  m_Txn.commit();
64  }
65 
70 
71  operator MDB_txn*() const
72  {
73  return m_Txn.handle();
74  }
75 
76  private:
78 };
79 
81 {
82  public:
83  explicit CPubseqGatewayCacheBase(const string& file_name);
84  virtual ~CPubseqGatewayCacheBase() = default;
85  // @throws lmdb::error
86  void Open();
87 
88  protected:
90  string m_FileName;
91  unique_ptr<lmdb::env> m_Env;
92 };
93 
95 
96 #endif // PSG_CACHE_BASE__HPP
#define END_IDBLOB_SCOPE
Definition: IdCassScope.hpp:40
#define BEGIN_IDBLOB_SCOPE
Definition: IdCassScope.hpp:39
CLMDBReadOnlyTxn(lmdb::txn &&txn)
CLMDBReadOnlyTxn & operator=(const CLMDBReadOnlyTxn &)=delete
CLMDBReadOnlyTxn(const CLMDBReadOnlyTxn &)=delete
CLMDBReadOnlyTxn(CLMDBReadOnlyTxn &&)=default
CLMDBReadOnlyTxn & operator=(CLMDBReadOnlyTxn &&)=default
unique_ptr< lmdb::env > m_Env
virtual ~CPubseqGatewayCacheBase()=default
CPubseqGatewayCacheBase(const string &file_name)
CLMDBReadOnlyTxn BeginReadTxn()
Resource class for `MDB_txn*` handles.
Definition: lmdb++.h:1262
void commit()
Commits this transaction.
Definition: lmdb++.h:1350
MDB_txn * handle() const noexcept
Returns the underlying `MDB_txn*` handle.
Definition: lmdb++.h:1333
Include a standard set of the NCBI C++ Toolkit most basic headers.
const char * file_name[]
#define nullptr
Definition: ncbimisc.hpp:45
BEGIN_IDBLOB_SCOPE USING_NCBI_SCOPE
A database transaction.
Definition: mdb.c:1084
Modified on Mon Jun 24 05:21:50 2024 by modify_doxy.py rev. 669887