LMDBAL 0.6.0
LMDB (Lightning Memory-Mapped Database Manager) Abstraction Layer
|
An object to manage cursor internals and state. More...
Public Member Functions | |
void | open () |
Opens the cursor for operations. | |
void | open (const Transaction &transaction) |
Opens the cursor for operations. | |
void | renew () |
Renews a cursor. | |
void | renew (const Transaction &transaction) |
Renews a cursor. | |
bool | opened () const |
Tells if the cursor is open. | |
bool | empty () const |
Returns true if the cursor is empty. | |
void | close () |
Termiates a sequence of operations with the cursor. | |
Protected Types | |
enum | State { closed , openedPublic , openedPrivate } |
Protected Member Functions | |
CursorCommon () | |
Creates a empty class. | |
CursorCommon (StorageCommon *storage) | |
Creates a cursor. | |
CursorCommon (const CursorCommon &other)=delete | |
CursorCommon (CursorCommon &&other) | |
Moves other cursor into this class. | |
virtual | ~CursorCommon () noexcept |
Destroys this cursor. | |
CursorCommon & | operator= (const CursorCommon &other)=delete |
CursorCommon & | operator= (CursorCommon &&other) |
Move assignment operator. | |
void | terminated () |
A private function called to inform the cursor he has been terminated. | |
void | dropped () |
A private method that turns cursor into an empty one. | |
void | reset () |
A private method that turns cursor into an empty one. | |
Protected Attributes | |
uint32_t | id |
State | state |
MDB_cursor * | handle |
StorageCommon * | storage |
Friends | |
class | Transaction |
An object to manage cursor internals and state.
Cursors are owned by the storage, they die with the storage. They also get closed if the storage is closed (if you close by the database for example)
You can obtain an instance of this class calling LMDBAL::Storage::createCursor() and destory it calling LMDBAL::Storage::destoryCursor() at any time, LMDBAL::Base doesn't necessarily need to be opened.
You are not supposed to instantiate or destory instances of this class yourself!
|
protected |
Enumerator | |
---|---|
closed | Cursor state:
|
openedPublic |
|
openedPrivate |
|
|
protected |
Creates a cursor.
[in] | _storage | a storage that created this cursor |
|
protected |
Moves other cursor into this class.
[in] | other | other instance that is being moved |
|
protectedvirtualnoexcept |
Destroys this cursor.
If the cursor wasn't properly closed - it's going to be upon destruction
void LMDBAL::CursorCommon::close | ( | ) |
Termiates a sequence of operations with the cursor.
This is a normal way to tell that you're done with the cursor and don't want to continue the sequence of queries. The state of the cursor is lost after calling this method, some inner resorce is freed.
If the cursor was opened with the private transaction - the owner storage will be notified of the aborted transaction.
This function does nothing on a closed cursor.
|
protected |
A private method that turns cursor into an empty one.
This function is called from LMDBAL::Storage, when it gets destroyed, but still has some valid cursors. Those cursors will become empty, and can't be used anymore
bool LMDBAL::CursorCommon::empty | ( | ) | const |
Returns true if the cursor is empty.
Empty cursors can't be used, they can be only targets of move operations
void LMDBAL::CursorCommon::open | ( | ) |
Opens the cursor for operations.
This is a normal way to start the sequence of operations with the cursor. This variant of the function creates a read only transaction just for this cursor
This function should be called when the LMDBAL::Storage is already opened and before any query with this cursor! It will do nothing to a cursor that was already opened (no matter what way).
LMDBAL::Closed | thrown if you try to open the cursor on a closed database |
LMDBAL::Unknown | thrown if there was a problem opening the cursor by the lmdb, or to begin a transaction |
LMDBAL::CursorEmpty | thrown if the cursor was empty |
void LMDBAL::CursorCommon::open | ( | const Transaction & | transaction | ) |
Opens the cursor for operations.
This is a normal way to start the sequence of operations with the cursor. This variant of the function uses for queries a transaction you have obtained somewhere else.
This function should be called when the LMDBAL::Storage is already opened and before any query with this cursor! It will do nothing to a cursor that was already opened (no matter what way).
[in] | transaction | - a transaction, can be read only |
LMDBAL::Closed | thrown if you try to open the cursor on a closed database |
LMDBAL::Unknown | thrown if there was a problem opening the cursor by the lmdb |
LMDBAL::TransactionTerminated | thrown if the passed transaction not active, any action with it's inner ID is an error |
LMDBAL::CursorEmpty | thrown if the cursor was empty |
|
protected |
Move assignment operator.
Transfers other cursor into this one
void LMDBAL::CursorCommon::renew | ( | ) |
Renews a cursor.
This function aborts current transaction if the cursor was opened with it's own transaction (does not mess up if the transaction was public), creates new private transaction and rebinds this cursor to it.
Theoretically you could call this method if your public transaction was aborted (or commited) but you wish to continue to keep working with your cursor. Or if you just want to rebind your cursor to a new private transaction.
This function does nothing if the cursor is closed
LMDBAL::Closed | thrown if you try to renew the cursor on a closed database |
LMDBAL::Unknown | thrown if there was a problem beginning new transaction or if there was a problem renewing the cursor by lmdb |
LMDBAL::CursorEmpty | thrown if the cursor was empty |
void LMDBAL::CursorCommon::renew | ( | const Transaction & | transaction | ) |
Renews a cursor.
This function aborts current transaction if the cursor was opened with it's own transaction (does not mess up if the transaction was public), and rebinds this cursor to a passed new transaction.
Theoretically you could call this method if your previous public transaction was aborted (or commited) but you wish to continue to keep working with your cursor. Or if you just want to rebind your cursor to another public transaction.
This function does nothing if the cursor is closed
[in] | transaction | - a transaction you wish this cursor to be bound to |
LMDBAL::Closed | thrown if you try to renew the cursor on a closed database |
LMDBAL::Unknown | thrown if there was a problem renewing the cursor by lmdb |
LMDBAL::TransactionTerminated | thrown if the passed transaction not active, any action with it's inner ID is an error |
LMDBAL::CursorEmpty | thrown if the cursor was empty |
|
protected |
A private method that turns cursor into an empty one.
This method is called from LMDBAL::Storage, when the cursor is getting destoryed. After this method cursors will become empty, and can't be used anymore
|
protected |
A private function called to inform the cursor he has been terminated.
Is expected to be called from transaction, database, storage or move constructor