Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

UndoHistory Class Reference

#include <UndoHistory.h>

List of all members.

Public Methods

 UndoHistory ()
virtual ~UndoHistory ()
void Clear (Undoable *u=0)
void Undo ()
void Redo ()
void Store (Undoable *u)

Private Methods

void ClearOneList (std::list< UndoRecord > &l, Undoable *u)

Private Attributes

std::list< UndoRecordfUndoList
std::list< UndoRecordfRedoList


Constructor & Destructor Documentation

UndoHistory::UndoHistory  
 

UndoHistory::~UndoHistory   [virtual]
 

Definition at line 13 of file UndoHistory.cxx.

References Clear().

00014 {
00015     this->Clear();
00016 }


Member Function Documentation

void UndoHistory::Clear Undoable   u = 0
 

Definition at line 33 of file UndoHistory.cxx.

References ClearOneList(), fRedoList, fUndoList, Msg::kDebug, and MSG.

Referenced by DisplayBase::Configure(), Undoable::~Undoable(), and ~UndoHistory().

00034 {
00035     MSG("UndoHistory",Msg::kDebug) << "Clear: " << (void*)u << endl;
00036 
00037     this->ClearOneList(fUndoList,u);
00038     this->ClearOneList(fRedoList,u);
00039 }

void UndoHistory::ClearOneList std::list< UndoRecord > &    l,
Undoable   u
[private]
 

Definition at line 18 of file UndoHistory.cxx.

References UndoHistory::UndoRecord::object, and UndoHistory::UndoRecord::state.

Referenced by Clear().

00019 {
00020     list<UndoRecord>::iterator lit;
00021     lit = l.begin();
00022     while (lit != l.end()) {
00023         UndoRecord ur = *lit;
00024         if (!u || ur.object == u) {
00025             lit = l.erase(lit);
00026             delete ur.state;
00027         }
00028         else ++lit;
00029     }
00030 
00031 }

void UndoHistory::Redo  
 

Definition at line 58 of file UndoHistory.cxx.

References fRedoList, fUndoList, Undoable::GetState(), Msg::kDebug, Msg::kWarning, MSG, UndoHistory::UndoRecord::object, Undoable::Restore(), and UndoHistory::UndoRecord::state.

Referenced by test1(), and test2().

00059 {
00060     if (fRedoList.begin() == fRedoList.end()) {
00061         MSG("UndoHistory",Msg::kWarning) << "Redo: nothing to redo\n";
00062         return;
00063     }
00064     MSG("UndoHistory",Msg::kDebug) << "Redoing\n";
00065 
00066     UndoRecord ur = fRedoList.back();
00067     fRedoList.pop_back();
00068 
00069     UndoRecord urcur(ur.object,ur.object->GetState());
00070     fUndoList.push_back(urcur);
00071 
00072     ur.object->Restore(ur.state);
00073 }

void UndoHistory::Store Undoable   u
 

Definition at line 75 of file UndoHistory.cxx.

References fUndoList, Undoable::GetState(), Msg::kDebug, and MSG.

Referenced by Undoable::Store(), test1(), and test2().

00076 {
00077     MSG("UndoHistory",Msg::kDebug) << "Store: " << (void*)u << endl;
00078     UndoRecord ur(u,u->GetState());
00079     fUndoList.push_back(ur);
00080 }

void UndoHistory::Undo  
 

Definition at line 41 of file UndoHistory.cxx.

References fRedoList, fUndoList, Undoable::GetState(), Msg::kDebug, Msg::kWarning, MSG, UndoHistory::UndoRecord::object, Undoable::Restore(), and UndoHistory::UndoRecord::state.

Referenced by test1(), and test2().

00042 {
00043     if (fUndoList.begin() == fUndoList.end()) {
00044         MSG("UndoHistory",Msg::kWarning) << "Undo: nothing to undo\n";
00045         return;
00046     }
00047     MSG("UndoHistory",Msg::kDebug) << "Undoing\n";
00048 
00049     UndoRecord ur = fUndoList.back();
00050     fUndoList.pop_back();
00051 
00052     UndoRecord urcur(ur.object,ur.object->GetState());
00053     fRedoList.push_back(urcur);
00054 
00055     ur.object->Restore(ur.state);
00056 }


Member Data Documentation

std::list<UndoRecord> UndoHistory::fRedoList [private]
 

Definition at line 60 of file UndoHistory.h.

Referenced by Clear(), Redo(), and Undo().

std::list<UndoRecord> UndoHistory::fUndoList [private]
 

Definition at line 59 of file UndoHistory.h.

Referenced by Clear(), Redo(), Store(), and Undo().


The documentation for this class was generated from the following files:
Generated on Wed Sep 4 19:24:29 2002 for loon by doxygen1.2.16