2016-01-16 15:21:02 +00:00
|
|
|
#ifndef TESTTOOLDEFINITION_H
|
|
|
|
#define TESTTOOLDEFINITION_H
|
|
|
|
|
|
|
|
#include "DefinitionWatcher.h"
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
/**
|
|
|
|
* Definition watcher that registers all calls to nodeChanged.
|
|
|
|
*/
|
|
|
|
class RecordingDefinitionWatcher : public DefinitionWatcher {
|
|
|
|
public:
|
2016-01-21 22:02:22 +00:00
|
|
|
RecordingDefinitionWatcher() : DefinitionWatcher("RecordingDefinitionWatcher") {
|
2016-01-16 15:21:02 +00:00
|
|
|
}
|
|
|
|
|
2016-01-18 21:22:56 +00:00
|
|
|
virtual void nodeChanged(const DefinitionNode *node, const DefinitionDiff *diff,
|
|
|
|
const DefinitionNode *parent) override {
|
2016-01-16 15:21:02 +00:00
|
|
|
RecordedChange change;
|
|
|
|
change.node = node;
|
2016-01-18 21:22:56 +00:00
|
|
|
change.diff = diff; // FIXME Referenced diff may get deleted by the diff manager
|
2016-01-16 15:21:02 +00:00
|
|
|
change.parent = parent;
|
|
|
|
changes.push_back(change);
|
|
|
|
}
|
|
|
|
|
2016-01-21 22:02:22 +00:00
|
|
|
virtual void start(DefinitionNode *node, bool init_diffs = true) {
|
|
|
|
startWatching(node, init_diffs);
|
|
|
|
}
|
|
|
|
|
2016-01-16 15:21:02 +00:00
|
|
|
typedef struct {
|
|
|
|
const DefinitionNode *node;
|
|
|
|
const DefinitionDiff *diff;
|
|
|
|
const DefinitionNode *parent;
|
|
|
|
} RecordedChange;
|
|
|
|
vector<RecordedChange> changes;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TESTTOOLDEFINITION_H
|