From a391c5a2b73f40d7d922b0c3f69005197604f229 Mon Sep 17 00:00:00 2001 From: Johannes Mey <johannes.mey@tu-dresden.de> Date: Mon, 10 Jan 2022 10:03:22 +0100 Subject: [PATCH] add ostream operator --- include/action.h | 5 +++++ src/action.cpp | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/action.h b/include/action.h index 0e60abc..480b6c4 100644 --- a/include/action.h +++ b/include/action.h @@ -119,6 +119,11 @@ public: return true; } } + + friend std::ostream& operator<<(std::ostream& os, const Action& action); + }; +std::ostream& operator<<(std::ostream& os, const Action& action); + #endif // CCF_IMMERSIVE_SORTING_ACTION_H_ diff --git a/src/action.cpp b/src/action.cpp index 1eba944..f8b1569 100644 --- a/src/action.cpp +++ b/src/action.cpp @@ -1 +1,13 @@ #include "action.h" + +std::ostream& operator<<(std::ostream& os, const Action& action) +{ + switch (action.type_) { + case Action::PICK_DROP: + os << "[pick " << action.source_ << " and drop it into " << action.target_ << "]"; + break; + default: + os << "[unknown action with source " << action.source_ << " and target " << action.target_ << "]"; + } + return os; +} \ No newline at end of file -- GitLab