From cd8e6d874c30db69e9bb57b491c485ea7d7051db Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 8 Dec 2015 22:14:29 +0100 Subject: [PATCH] EventLog: switch to shared PImpl this is prerequisite for joining and sharing logs --- src/lib/test/event-log.hpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/lib/test/event-log.hpp b/src/lib/test/event-log.hpp index 9051fc4fc..ef82238fa 100644 --- a/src/lib/test/event-log.hpp +++ b/src/lib/test/event-log.hpp @@ -54,6 +54,7 @@ //#include #include +#include #include #include @@ -275,21 +276,26 @@ namespace test{ using Log = std::vector; using Iter = lib::RangeIter; - string logID_; - Log log_; + std::shared_ptr log_; void log (std::initializer_list const&& ili) { - log_.emplace_back(ili); + log_->emplace_back(ili); + } + + string + getID() const + { + log_->front().get("ID"); } public: explicit EventLog (string logID) - : logID_(logID) + : log_(new Log) { - log({"type=EventLogHeader", "ID="+logID_}); + log({"type=EventLogHeader", "ID="+logID}); } explicit @@ -332,14 +338,14 @@ namespace test{ bool empty() const { - return 1 >= log_.size(); + return 1 >= log_->size(); } typedef Iter const_iterator; typedef const Entry value_type; - const_iterator begin() const { return Iter(log_.begin(), log_.end()); } + const_iterator begin() const { return Iter(log_->begin(), log_->end()); } const_iterator end() const { return Iter(); } friend const_iterator begin (EventLog const& log) { return log.begin(); } @@ -353,7 +359,7 @@ namespace test{ EventMatch verify (string match) const { - EventMatch matcher(log_); + EventMatch matcher(*log_); matcher.before (match); return matcher; } @@ -379,7 +385,7 @@ namespace test{ EventMatch ensureNot (string match) const { - EventMatch matcher(log_); + EventMatch matcher(*log_); matcher.look_for_match_ = false; // flip logic; fail if match succeeds matcher.before (match); return matcher; @@ -390,7 +396,9 @@ namespace test{ friend bool operator== (EventLog const& l1, EventLog const& l2) { - return l1.log_ == l2.log_; + return l1.log_ == l2.log_ + or (l1.log_ and l2.log_ + and *l1.log_ == *l2.log_); } friend bool operator!= (EventLog const& l1, EventLog const& l2)