General purpose changelog; allows incremental changes made to a datastructure to be undone quickly. More...
#include <ChangeLog.hpp>
Public Types | |
enum | Action { ADD, REMOVE, PROCESSED, MARKER } |
Available actions. More... | |
Public Member Functions | |
ChangeLog () | |
Constructor. | |
bool | empty () const |
Returns true if changelog is empty. | |
int | size () const |
Returns size of changelog. | |
void | push (Action action, const T &data) |
Adds an entry onto the changelog. | |
void | pop () |
Pops the top entry off of the changelog. | |
Action | topAction () const |
Returns the action on top of the changelog. | |
T | topData () const |
Returns a copy of the data on top of the changelog. | |
void | clear () |
Clears the log. | |
std::string | dump () const |
Dump the contents of the log to a string. | |
Private Attributes | |
std::vector< T > | m_data |
std::vector< Action > | m_action |
General purpose changelog; allows incremental changes made to a datastructure to be undone quickly.
A changelog is a stack that tracks the changes to some data structure with data type T. There are three actions: ADD, REMOVE, and MARKER. And ADD action means the data was recently added to the datastructure, and REMOVE means it was recently removed. MARKER is used to mark how far back to go when you want to undo the changes made.
Definition at line 30 of file ChangeLog.hpp.
enum ChangeLog::Action |
Available actions.
Definition at line 38 of file ChangeLog.hpp.
Constructor.
Definition at line 79 of file ChangeLog.hpp.
void ChangeLog< T >::clear | ( | ) | [inline] |
Clears the log.
Definition at line 119 of file ChangeLog.hpp.
References ChangeLog< T >::m_action, and ChangeLog< T >::m_data.
std::string ChangeLog< T >::dump | ( | ) | const [inline] |
Dump the contents of the log to a string.
Definition at line 126 of file ChangeLog.hpp.
References ChangeLog< T >::ADD, ChangeLog< T >::m_action, ChangeLog< T >::m_data, ChangeLog< T >::MARKER, ChangeLog< T >::PROCESSED, and ChangeLog< T >::REMOVE.
bool ChangeLog< T >::empty | ( | ) | const [inline] |
Returns true if changelog is empty.
Definition at line 84 of file ChangeLog.hpp.
References ChangeLog< T >::m_action.
Referenced by ChangeLog< T >::pop(), VCSet::Revert(), ChangeLog< VC >::topAction(), and ChangeLog< T >::topData().
void ChangeLog< T >::pop | ( | ) | [inline] |
Pops the top entry off of the changelog.
Asserts log is not empty.
Definition at line 103 of file ChangeLog.hpp.
References ChangeLog< T >::empty(), ChangeLog< T >::m_action, and ChangeLog< T >::m_data.
Referenced by VCSet::Revert().
Adds an entry onto the changelog.
Definition at line 96 of file ChangeLog.hpp.
References ChangeLog< T >::m_action, and ChangeLog< T >::m_data.
Referenced by VCList::add(), HexBoard::MarkChangeLog(), VCBuilder::ProcessFulls(), VCBuilder::ProcessSemis(), VCList::remove(), VCList::removeAllContaining(), and VCList::removeSuperSetsOf().
int ChangeLog< T >::size | ( | ) | const [inline] |
Returns size of changelog.
Definition at line 90 of file ChangeLog.hpp.
References ChangeLog< T >::m_action.
Returns the action on top of the changelog.
Asserts log is not empty.
Definition at line 60 of file ChangeLog.hpp.
Referenced by VCSet::Revert().
T ChangeLog< T >::topData | ( | ) | const [inline] |
Returns a copy of the data on top of the changelog.
Asserts log is not empty.
Definition at line 111 of file ChangeLog.hpp.
References ChangeLog< T >::empty(), and ChangeLog< T >::m_data.
Referenced by VCSet::Revert().
Definition at line 75 of file ChangeLog.hpp.
Referenced by ChangeLog< T >::clear(), ChangeLog< T >::dump(), ChangeLog< T >::empty(), ChangeLog< T >::pop(), ChangeLog< T >::push(), ChangeLog< T >::size(), and ChangeLog< VC >::topAction().
Definition at line 74 of file ChangeLog.hpp.
Referenced by ChangeLog< T >::clear(), ChangeLog< T >::dump(), ChangeLog< T >::pop(), ChangeLog< T >::push(), and ChangeLog< T >::topData().