From 966a5670cbfe67068cf03ae17a36e12364dbc262 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 15:41:03 +0200 Subject: [PATCH] Add an option to print names in front of values in stream monitor --- eo/src/utils/eoOStreamMonitor.cpp | 6 ++++-- eo/src/utils/eoOStreamMonitor.h | 13 +++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/eo/src/utils/eoOStreamMonitor.cpp b/eo/src/utils/eoOStreamMonitor.cpp index 6836f337e..b9e848c58 100644 --- a/eo/src/utils/eoOStreamMonitor.cpp +++ b/eo/src/utils/eoOStreamMonitor.cpp @@ -47,8 +47,10 @@ eoMonitor& eoOStreamMonitor::operator()(void) */ for (iterator it = vec.begin (); it != vec.end (); ++it) { - // value only - out << (*it)->getValue (); + if( print_names ) { + out << (*it)->longName() << name_sep; + } + out << (*it)->getValue(); out << delim << std::left << std::setfill(fill) << std::setw(width); } // for it in vec diff --git a/eo/src/utils/eoOStreamMonitor.h b/eo/src/utils/eoOStreamMonitor.h index 982c954f9..032665224 100644 --- a/eo/src/utils/eoOStreamMonitor.h +++ b/eo/src/utils/eoOStreamMonitor.h @@ -56,8 +56,15 @@ public : } */ - eoOStreamMonitor( std::ostream & _out, std::string _delim = "\t", unsigned int _width=20, char _fill=' ' ) : - out(_out), delim(_delim), width(_width), fill(_fill), firsttime(true) + eoOStreamMonitor( + std::ostream & _out, + std::string _delim = "\t", unsigned int _width=20, char _fill=' ', + bool _print_names = false, std::string _name_sep = ":" + ) : + out(_out), + delim(_delim), width(_width), fill(_fill), + firsttime(true), + print_names(_print_names), name_sep(_name_sep) {} eoMonitor& operator()(void); @@ -70,6 +77,8 @@ private : unsigned int width; char fill; bool firsttime; + bool print_names; + std::string name_sep; }; #endif // _eoOStreamMonitor_h_