Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

ChangeLog< T > Class Template Reference

General purpose changelog; allows incremental changes made to a datastructure to be undone quickly. More...

#include <ChangeLog.hpp>

List of all members.

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.
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< Actionm_action

Detailed Description

template<typename T>
class ChangeLog< T >

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.


Member Enumeration Documentation

template<typename T>
enum ChangeLog::Action

Available actions.

Enumerator:
ADD 
REMOVE 
PROCESSED 
MARKER 

Definition at line 38 of file ChangeLog.hpp.


Constructor & Destructor Documentation

template<typename T >
ChangeLog< T >::ChangeLog (  )  [inline]

Constructor.

Definition at line 79 of file ChangeLog.hpp.


Member Function Documentation

template<typename T >
void ChangeLog< T >::clear (  )  [inline]

Clears the log.

Todo:
vector::clear() takes linear time. Is this a problem?

Definition at line 119 of file ChangeLog.hpp.

References ChangeLog< T >::m_action, and ChangeLog< T >::m_data.

template<typename T >
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.

template<typename T >
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().

template<typename T >
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().

template<typename T>
void ChangeLog< T >::push ( Action  action,
const T &  data 
) [inline]
template<typename T >
int ChangeLog< T >::size (  )  const [inline]

Returns size of changelog.

Definition at line 90 of file ChangeLog.hpp.

References ChangeLog< T >::m_action.

template<typename T>
Action ChangeLog< T >::topAction (  )  const [inline]

Returns the action on top of the changelog.

Asserts log is not empty.

Todo:
how to write this method using the 'inline' syntax? I keep getting compile errors.

Definition at line 60 of file ChangeLog.hpp.

Referenced by VCSet::Revert().

template<typename T >
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().


Member Data Documentation

template<typename T>
std::vector<Action> ChangeLog< T >::m_action [private]
template<typename T>
std::vector<T> ChangeLog< T >::m_data [private]

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


6 Jan 2011 Doxygen 1.6.3