diff --git a/src/lib/diff/list-diff-detector.hpp b/src/lib/diff/list-diff-detector.hpp index b22c60fe8..4e16940ab 100644 --- a/src/lib/diff/list-diff-detector.hpp +++ b/src/lib/diff/list-diff-detector.hpp @@ -74,7 +74,15 @@ namespace diff{ using std::swap; - + /** + * Detect and describe changes in a monitored data sequence. + * The DiffDetector takes snapshot(s) of the observed data, + * to find all differences between the last snapshot and the + * current state. Whenever such a "List Diff" is pulled, a new + * baseline snapshot is taken automatically. The description of + * all changes can be retrieved from the returned diff iterator, + * as a sequence of \link ListDiffLanguage diff verbs\endlink + */ template class DiffDetector : boost::noncopyable @@ -103,13 +111,18 @@ namespace diff{ /** does the current state of the underlying sequence differ - * from the state embodied into the last reference snapshot taken? + * from the state embodied into the last reference snapshot taken? * @remarks will possibly evaluate and iterate the whole sequence */ bool isChanged() const { - UNIMPLEMENTED("change detection"); + auto snapshot = refIdx_.begin(); + for (auto const& elm : currentData_) + if (snapshot != refIdx_.end() && elm != *snapshot++) + return true; + + return false; } @@ -190,7 +203,7 @@ namespace diff{ friend void iterNext (DiffFrame & frame) { - frame.establishNextState(); + frame.currentStep_ = frame.establishNextState(); } private: diff --git a/tests/library/diff/diff-list-application-test.cpp b/tests/library/diff/diff-list-application-test.cpp index 48d0dfdec..45ed4ef14 100644 --- a/tests/library/diff/diff-list-application-test.cpp +++ b/tests/library/diff/diff-list-application-test.cpp @@ -73,7 +73,6 @@ namespace test{ , skip(a5) , ins(b4) }); - } }//(End)Test fixture diff --git a/tests/library/diff/diff-list-generation-test.cpp b/tests/library/diff/diff-list-generation-test.cpp index 39f5aff21..26add3b3b 100644 --- a/tests/library/diff/diff-list-generation-test.cpp +++ b/tests/library/diff/diff-list-generation-test.cpp @@ -57,7 +57,7 @@ namespace test{ DiffStep_CTOR(pick); DiffStep_CTOR(find); DiffStep_CTOR(skip); - + }//(End)Test fixture @@ -95,7 +95,7 @@ namespace test{ auto changes = detector.pullUpdate(); CHECK (!isnil (changes)); - CHECK (!detector.isChanged()); + CHECK (!detector.isChanged()); // pullUpdate() also took a new snapshot DiffSeq generatedDiff; append_all (changes, generatedDiff); @@ -108,8 +108,8 @@ namespace test{ , ins(b2) , ins(b3) , pick(a4) - , skip(a5) , ins(b4) + , skip(a5) })); } };