public OpStatus StepForwardToAfterNextTag(string tag) { bool bContinue = true; while (bContinue) { OpStatus result = StepForward(); if (result.code != OpStatus.no_error) { return(result); } if (iCurrent == vHistory.Count) { bContinue = false; } else { var tags = vHistory[iCurrent].GetTags(); if (tags != null && tags.Contains(tag)) { bContinue = false; } } } return(OpStatus.Success); }
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); }
/// <summary> /// play history forward until current node has the given tag /// </summary> public OpStatus StepForwardToAfterNextTag(string tag) { bool bContinue = true; bool bFound = false; while (bContinue) { OpStatus result = StepForward(); if (result.code != OpStatus.no_error) { return(result); } if (iCurrent == vHistory.Count) { bContinue = false; } else { IChangeOp op = vHistory[iCurrent]; if (op.HasTags && op.Tags.Contains(tag)) { bContinue = false; bFound = true; } } } // step to *after* this node, otherwise if we push a new node we will replace this one! // [TODO] this is maybe a bit weird...? if (bFound) { StepForward(); } return(OpStatus.Success); }
/// <summary> /// Rewind history until current node has the given tag /// </summary> public OpStatus StepBackwardToAfterPreviousTag(string tag) { bool bContinue = true; while (bContinue) { OpStatus result = StepBack(); if (result.code != OpStatus.no_error) { return(result); } if (iCurrent == 0) { bContinue = false; } else { IChangeOp op = vHistory[iCurrent - 1]; if (op.HasTags && op.Tags.Contains(tag)) { bContinue = false; } } } return(OpStatus.Success); }
public override OpStatus Cull() { OpStatus totalResult = OpStatus.Success; foreach (var change in Changes) { var result = change.Cull(); if (result.code != OpStatus.Success.code) { totalResult = result; } } return(totalResult); }
public override OpStatus Revert() { OpStatus totalResult = OpStatus.Success; int N = Changes.Count; for (int i = N - 1; i >= 0; --i) { var change = Changes[i]; var result = change.Revert(); if (result.code != OpStatus.Success.code) { totalResult = result; } } return(totalResult); }
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); }