BitShares-Core  5.0.0
BitShares blockchain implementation and command-line interface 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 49 of file undo_database.hpp.

Constructor & Destructor Documentation

graphene::db::undo_database::undo_database ( object_database db)
inline

Definition at line 52 of file undo_database.hpp.

Member Function Documentation

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

Definition at line 122 of file undo_database.hpp.

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

Definition at line 31 of file undo_database.cpp.

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

Definition at line 30 of file undo_database.cpp.

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

Definition at line 86 of file undo_database.hpp.

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

Definition at line 301 of file undo_database.cpp.

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

Definition at line 121 of file undo_database.hpp.

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.

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.

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.

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.

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

Definition at line 120 of file undo_database.hpp.

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

Definition at line 119 of file undo_database.hpp.

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: