BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
Classes | Public Member Functions | List of all members
graphene::db::undo_database Class Reference

tracks changes to the state and allows changes to be undone More...

#include <undo_database.hpp>

Classes

class  session
 

Public Member Functions

 undo_database (object_database &db)
 
void disable ()
 
void enable ()
 
bool enabled () const
 
session start_undo_session (bool force_enable=false)
 
void on_create (const object &obj)
 
void on_modify (const object &obj)
 
void on_remove (const object &obj)
 
void pop_commit ()
 
std::size_t size () const
 
void set_max_size (size_t new_max_size)
 
size_t max_size () const
 
uint32_t active_sessions () const
 
const undo_statehead () const
 

Detailed Description

tracks changes to the state and allows changes to be undone

Definition at line 47 of file undo_database.hpp.

Constructor & Destructor Documentation

◆ undo_database()

graphene::db::undo_database::undo_database ( object_database db)
inlineexplicit

Definition at line 50 of file undo_database.hpp.

Member Function Documentation

◆ active_sessions()

uint32_t graphene::db::undo_database::active_sessions ( ) const
inline

Definition at line 123 of file undo_database.hpp.

◆ disable()

void graphene::db::undo_database::disable ( )

Definition at line 31 of file undo_database.cpp.

◆ enable()

void graphene::db::undo_database::enable ( )

Definition at line 30 of file undo_database.cpp.

◆ enabled()

bool graphene::db::undo_database::enabled ( ) const
inline

Definition at line 87 of file undo_database.hpp.

◆ head()

const undo_state & graphene::db::undo_database::head ( ) const

Definition at line 301 of file undo_database.cpp.

◆ max_size()

size_t graphene::db::undo_database::max_size ( ) const
inline

Definition at line 122 of file undo_database.hpp.

◆ on_create()

void graphene::db::undo_database::on_create ( const object obj)

This should be called just after an object is created

Definition at line 60 of file undo_database.cpp.

◆ on_modify()

void graphene::db::undo_database::on_modify ( const object obj)

This should be called just before an object is modified

If it's a new object as of this undo state, its pre-modification value is not stored, because prior to this undo state, it did not exist. Any modifications in this undo state are irrelevant, as the object will simply be removed if we undo.

Definition at line 73 of file undo_database.cpp.

◆ on_remove()

void graphene::db::undo_database::on_remove ( const object obj)

This should be called just before an object is removed.

If it's a new object as of this undo state, its pre-removal value is not stored, because prior to this undo state, it did not exist. Now that it's been removed, it doesn't exist again, so nothing has happened. Instead, remove it from the list of newly created objects (which must be deleted if we undo), as we don't want to re-delete it if this state is undone.

Definition at line 86 of file undo_database.cpp.

◆ pop_commit()

void graphene::db::undo_database::pop_commit ( )

Removes the last committed session, note... this is dangerous if there are active sessions... thus active sessions should track

Definition at line 264 of file undo_database.cpp.

◆ set_max_size()

void graphene::db::undo_database::set_max_size ( size_t  new_max_size)
inline

Definition at line 121 of file undo_database.hpp.

◆ size()

std::size_t graphene::db::undo_database::size ( ) const
inline

Definition at line 120 of file undo_database.hpp.

◆ start_undo_session()

undo_database::session graphene::db::undo_database::start_undo_session ( bool  force_enable = false)

Definition at line 46 of file undo_database.cpp.


The documentation for this class was generated from the following files: