NCBI C++ ToolKit
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
lmdb::env Class Reference

Search Toolkit Book for lmdb::env

Resource class for `MDB_env*` handles. More...

#include <objtools/blast/seqdb_reader/impl/lmdb++.h>

+ Collaboration diagram for lmdb::env:

Public Member Functions

 env (MDB_env *const handle) noexcept
 Constructor. More...
 
 env (env &&other) noexcept
 Move constructor. More...
 
envoperator= (env &&other) noexcept
 Move assignment operator. More...
 
 ~env () noexcept
 Destructor. More...
 
 operator MDB_env * () const noexcept
 Returns the underlying `MDB_env*` handle. More...
 
MDB_envhandle () const noexcept
 Returns the underlying `MDB_env*` handle. More...
 
void sync (const bool force=true)
 Flushes data buffers to disk. More...
 
void close () noexcept
 Closes this environment, releasing the memory map. More...
 
envopen (const char *const path, const unsigned int flags=default_flags, const mode mode=default_mode)
 Opens this environment. More...
 
envset_flags (const unsigned int flags, const bool onoff=true)
 
envset_mapsize (const std::size_t size)
 
envset_max_readers (const unsigned int count)
 
envset_max_dbs (const MDB_dbi count)
 
 env (MDB_env *const handle) noexcept
 Constructor. More...
 
 env (env &&other) noexcept
 Move constructor. More...
 
envoperator= (env &&other) noexcept
 Move assignment operator. More...
 
 ~env () noexcept
 Destructor. More...
 
 operator MDB_env * () const noexcept
 Returns the underlying `MDB_env*` handle. More...
 
MDB_envhandle () const noexcept
 Returns the underlying `MDB_env*` handle. More...
 
void sync (const bool force=true)
 Flushes data buffers to disk. More...
 
void close () noexcept
 Closes this environment, releasing the memory map. More...
 
envopen (const char *const path, const unsigned int flags=default_flags, const mode mode=default_mode)
 Opens this environment. More...
 
envset_flags (const unsigned int flags, const bool onoff=true)
 
envset_mapsize (const std::size_t size)
 
envset_max_readers (const unsigned int count)
 
envset_max_dbs (const MDB_dbi count)
 

Static Public Member Functions

static env create (const unsigned int flags=default_flags)
 Creates a new LMDB environment. More...
 
static env create (const unsigned int flags=default_flags)
 Creates a new LMDB environment. More...
 

Static Public Attributes

static constexpr unsigned int default_flags = 0
 
static constexpr mode default_mode = 0644
 

Protected Attributes

MDB_env_handle {nullptr}
 

Detailed Description

Resource class for `MDB_env*` handles.

Note
Instances of this class are movable, but not copyable.
See also
http://symas.com/mdb/doc/group__internal.html#structMDB__env

Definition at line 1094 of file lmdb++.h.

Constructor & Destructor Documentation

◆ env() [1/4]

lmdb::env::env ( MDB_env *const  handle)
inlinenoexcept

Constructor.

Parameters
handlea valid `MDB_env*` handle

Definition at line 1131 of file lmdb++.h.

References handle().

◆ env() [2/4]

lmdb::env::env ( env &&  other)
inlinenoexcept

Move constructor.

Definition at line 1137 of file lmdb++.h.

References _handle, and swap().

◆ ~env() [1/2]

lmdb::env::~env ( )
inlinenoexcept

Destructor.

Definition at line 1154 of file lmdb++.h.

References close().

◆ env() [3/4]

lmdb::env::env ( MDB_env *const  handle)
inlinenoexcept

Constructor.

Parameters
handlea valid `MDB_env*` handle

Definition at line 1261 of file lmdb++.h.

References handle().

◆ env() [4/4]

lmdb::env::env ( env &&  other)
inlinenoexcept

Move constructor.

Definition at line 1267 of file lmdb++.h.

References _handle, and swap().

◆ ~env() [2/2]

lmdb::env::~env ( )
inlinenoexcept

Destructor.

Definition at line 1284 of file lmdb++.h.

References close().

Member Function Documentation

◆ close() [1/2]

void lmdb::env::close ( )
inlinenoexcept

Closes this environment, releasing the memory map.

Note
this method is idempotent
Postcondition
`handle() == nullptr`

Definition at line 1188 of file lmdb++.h.

References _handle, lmdb::env_close(), and handle().

Referenced by ~env().

◆ close() [2/2]

void lmdb::env::close ( )
inlinenoexcept

Closes this environment, releasing the memory map.

Note
this method is idempotent
Postcondition
`handle() == nullptr`

Definition at line 1318 of file lmdb++.h.

References _handle, lmdb::env_close(), and handle().

◆ create() [1/2]

static env lmdb::env::create ( const unsigned int  flags = default_flags)
inlinestatic

Creates a new LMDB environment.

Parameters
flags
Exceptions
lmdb::erroron failure

Definition at line 1108 of file lmdb++.h.

References assert, lmdb::env_close(), lmdb::env_create(), lmdb::env_set_flags(), flags, and handle().

Referenced by CPubseqGatewayCacheBase::CPubseqGatewayCacheBase().

◆ create() [2/2]

static env lmdb::env::create ( const unsigned int  flags = default_flags)
inlinestatic

Creates a new LMDB environment.

Parameters
flags
Exceptions
lmdb::erroron failure

Definition at line 1238 of file lmdb++.h.

References assert, lmdb::env_close(), lmdb::env_create(), lmdb::env_set_flags(), flags, and handle().

◆ handle() [1/2]

MDB_env* lmdb::env::handle ( ) const
inlinenoexcept

Returns the underlying `MDB_env*` handle.

Definition at line 1168 of file lmdb++.h.

References _handle.

Referenced by close(), create(), env(), open(), set_flags(), set_mapsize(), set_max_dbs(), set_max_readers(), sync(), CWriteDB_TaxID::x_IncreaseEnvMapSize(), and CWriteDB_LMDB::x_IncreaseEnvMapSize().

◆ handle() [2/2]

MDB_env* lmdb::env::handle ( ) const
inlinenoexcept

Returns the underlying `MDB_env*` handle.

Definition at line 1298 of file lmdb++.h.

References _handle.

◆ open() [1/2]

env& lmdb::env::open ( const char *const  path,
const unsigned int  flags = default_flags,
const mode  mode = default_mode 
)
inline

Opens this environment.

Parameters
path
flags
mode
Exceptions
lmdb::erroron failure

Definition at line 1203 of file lmdb++.h.

References lmdb::env_open(), flags, and handle().

Referenced by CBlastLMDBManager::CBlastEnv::CBlastEnv().

◆ open() [2/2]

env& lmdb::env::open ( const char *const  path,
const unsigned int  flags = default_flags,
const mode  mode = default_mode 
)
inline

Opens this environment.

Parameters
path
flags
mode
Exceptions
lmdb::erroron failure

Definition at line 1333 of file lmdb++.h.

References lmdb::env_open(), flags, and handle().

◆ operator MDB_env *() [1/2]

lmdb::env::operator MDB_env * ( ) const
inlinenoexcept

Returns the underlying `MDB_env*` handle.

Definition at line 1161 of file lmdb++.h.

References _handle.

◆ operator MDB_env *() [2/2]

lmdb::env::operator MDB_env * ( ) const
inlinenoexcept

Returns the underlying `MDB_env*` handle.

Definition at line 1291 of file lmdb++.h.

References _handle.

◆ operator=() [1/2]

env& lmdb::env::operator= ( env &&  other)
inlinenoexcept

Move assignment operator.

Definition at line 1144 of file lmdb++.h.

References _handle, and swap().

◆ operator=() [2/2]

env& lmdb::env::operator= ( env &&  other)
inlinenoexcept

Move assignment operator.

Definition at line 1274 of file lmdb++.h.

References _handle, and swap().

◆ set_flags() [1/2]

env& lmdb::env::set_flags ( const unsigned int  flags,
const bool  onoff = true 
)
inline
Parameters
flags
onoff
Exceptions
lmdb::erroron failure

Definition at line 1215 of file lmdb++.h.

References lmdb::env_set_flags(), flags, and handle().

◆ set_flags() [2/2]

env& lmdb::env::set_flags ( const unsigned int  flags,
const bool  onoff = true 
)
inline
Parameters
flags
onoff
Exceptions
lmdb::erroron failure

Definition at line 1345 of file lmdb++.h.

References lmdb::env_set_flags(), flags, and handle().

◆ set_mapsize() [1/2]

env& lmdb::env::set_mapsize ( const std::size_t  size)
inline

◆ set_mapsize() [2/2]

env& lmdb::env::set_mapsize ( const std::size_t  size)
inline
Parameters
size
Exceptions
lmdb::erroron failure

Definition at line 1355 of file lmdb++.h.

References lmdb::env_set_mapsize(), handle(), and ncbi::grid::netcache::search::fields::size.

◆ set_max_dbs() [1/2]

env& lmdb::env::set_max_dbs ( const MDB_dbi  count)
inline
Parameters
count
Exceptions
lmdb::erroron failure

Definition at line 1243 of file lmdb++.h.

References lmdb::env_set_max_dbs(), and handle().

Referenced by CBlastLMDBManager::CBlastEnv::CBlastEnv().

◆ set_max_dbs() [2/2]

env& lmdb::env::set_max_dbs ( const MDB_dbi  count)
inline
Parameters
count
Exceptions
lmdb::erroron failure

Definition at line 1373 of file lmdb++.h.

References lmdb::env_set_max_dbs(), and handle().

◆ set_max_readers() [1/2]

env& lmdb::env::set_max_readers ( const unsigned int  count)
inline
Parameters
count
Exceptions
lmdb::erroron failure

Definition at line 1234 of file lmdb++.h.

References lmdb::env_set_max_readers(), and handle().

◆ set_max_readers() [2/2]

env& lmdb::env::set_max_readers ( const unsigned int  count)
inline
Parameters
count
Exceptions
lmdb::erroron failure

Definition at line 1364 of file lmdb++.h.

References lmdb::env_set_max_readers(), and handle().

◆ sync() [1/2]

void lmdb::env::sync ( const bool  force = true)
inline

Flushes data buffers to disk.

Parameters
force
Exceptions
lmdb::erroron failure

Definition at line 1178 of file lmdb++.h.

References lmdb::env_sync(), and handle().

◆ sync() [2/2]

void lmdb::env::sync ( const bool  force = true)
inline

Flushes data buffers to disk.

Parameters
force
Exceptions
lmdb::erroron failure

Definition at line 1308 of file lmdb++.h.

References lmdb::env_sync(), and handle().

Member Data Documentation

◆ _handle

MDB_env * lmdb::env::_handle {nullptr}
protected

Definition at line 1096 of file lmdb++.h.

Referenced by close(), env(), handle(), operator MDB_env *(), and operator=().

◆ default_flags

static constexpr unsigned int lmdb::env::default_flags = 0
staticconstexpr

Definition at line 1099 of file lmdb++.h.

◆ default_mode

static constexpr mode lmdb::env::default_mode = 0644
staticconstexpr

Definition at line 1100 of file lmdb++.h.


The documentation for this class was generated from the following file:
Modified on Tue Jun 18 13:34:57 2024 by modify_doxy.py rev. 669887