public OpStatus PushChange(IChangeOp op, bool bIsApplied = false) { DebugUtil.Log(2, "ChangeHistory.PushChange: pushed {0}", op.Identifier()); if (vHistory.Count > 0 && iCurrent < vHistory.Count) { TrimFuture(); } if (bIsApplied == false) { OpStatus result = op.Apply(); if (result.code != OpStatus.no_error) { DebugUtil.Error("[ChangeHistory::PushChange] Apply() of ChangeOp {0} failed - code {1} message {2}", op.Identifier(), result.code, result.message); return(result); } } vHistory.Add(op); iCurrent++; return(OpStatus.Success); }
public OpStatus StepBack() { if (iCurrent == 0) { return(OpStatus.Success); // weird but ok } IChangeOp op = vHistory[iCurrent - 1]; DebugUtil.Log(2, "ChangeHistory.StepBack: reverting {0}", op.Identifier()); OpStatus result = op.Revert(); if (result.code != OpStatus.no_error) { DebugUtil.Error("[ChangeHistory::StepBack] Revert() of ChangeOp {0} failed - result was code {1} message {2}", op.Identifier(), result.code, result.message); return(result); } iCurrent--; return(OpStatus.Success); }
public OpStatus StepForward() { if (iCurrent == vHistory.Count) { return(OpStatus.Success); } IChangeOp op = vHistory[iCurrent]; DebugUtil.Log(2, "ChangeHistory.StepForward: applying {0}", op.Identifier()); OpStatus result = op.Apply(); if (result.code != OpStatus.no_error) { DebugUtil.Error("[ChangeHistory::StepForward] Apply() of ChangeOp {0} failed - result was code {1} message {2}", op.Identifier(), result.code, result.message); return(result); } iCurrent++; return(OpStatus.Success); }