From a9f382a30c5336459960939acf1342b2983184a1 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Sat, 30 Oct 2010 23:30:40 +0200 Subject: [PATCH] fix #13: remove the use of the verbose members, replaced by the eo::log system ; functions prototypes keep their verbose parameters, but display a warning until next version --- eo/src/eoCombinedInit.h | 5 ++--- eo/src/eoGenContinue.h | 10 ++++----- eo/src/eoProportionalCombinedOp.h | 3 ++- eo/src/utils/eoData.h | 4 ---- eo/src/utils/eoOStreamMonitor.cpp | 35 +++++++++++++------------------ eo/src/utils/eoOStreamMonitor.h | 6 ++++-- eo/src/utils/eoStdoutMonitor.h | 6 +++++- 7 files changed, 32 insertions(+), 37 deletions(-) diff --git a/eo/src/eoCombinedInit.h b/eo/src/eoCombinedInit.h index 7acbe379..240dd7b8 100644 --- a/eo/src/eoCombinedInit.h +++ b/eo/src/eoCombinedInit.h @@ -44,15 +44,14 @@ public: } /** The usual method to add objects to the combination - * note the _verbose parameter, that allows to print what's - * inside the combination with scaled rates */ void add(eoInit & _init, double _rate, bool _verbose=false) { + eo::log << eo::warnings << "WARNING: the use of the verbose parameter in eoCombinedInit::add is deprecated and will be removed in the next release." << std::endl; + initializers.push_back(&_init); rates.push_back(_rate); // compute the relative rates in percent - to warn the user! - if (_verbose) printOn( eo::log << eo::logging ); } diff --git a/eo/src/eoGenContinue.h b/eo/src/eoGenContinue.h index e670cf31..3619a520 100644 --- a/eo/src/eoGenContinue.h +++ b/eo/src/eoGenContinue.h @@ -42,14 +42,16 @@ public: : eoValueParam(0, "Generations", "Generations"), repTotalGenerations( _totalGens ), thisGenerationPlaceHolder(0), - thisGeneration(thisGenerationPlaceHolder), verbose(true) {}; + thisGeneration(thisGenerationPlaceHolder) + {}; /// Ctor for enabling the save/load the no. of generations counted eoGenContinue( unsigned long _totalGens, unsigned long& _currentGen) : eoValueParam(0, "Generations", "Generations"), repTotalGenerations( _totalGens ), thisGenerationPlaceHolder(0), - thisGeneration(_currentGen), verbose(true){}; + thisGeneration(_currentGen) + {}; /** Returns false when a certain number of generations is * reached */ @@ -60,7 +62,6 @@ public: if (thisGeneration >= repTotalGenerations) { - if (verbose) eo::log << eo::logging << "STOP in eoGenContinue: Reached maximum number of generations [" << thisGeneration << "/" << repTotalGenerations << "]\n"; return false; } @@ -97,9 +98,6 @@ private: unsigned long repTotalGenerations; unsigned long thisGenerationPlaceHolder; unsigned long& thisGeneration; - -public: - bool verbose; // allows to turn off annoying message to cout }; #endif diff --git a/eo/src/eoProportionalCombinedOp.h b/eo/src/eoProportionalCombinedOp.h index 79b74111..58dd79a4 100644 --- a/eo/src/eoProportionalCombinedOp.h +++ b/eo/src/eoProportionalCombinedOp.h @@ -176,10 +176,11 @@ virtual std::string className() const { return "eoPropCombinedQuadOp"; } // addition of a true operator virtual void add(eoQuadOp & _op, const double _rate, bool _verbose=false) { + eo::log << eo::warnings << "WARNING: the use of the verbose parameter in eoPropCombinedQuadOp::add is deprecated and will be removed in the next release." << std::endl; + ops.push_back(&_op); rates.push_back(_rate); // compute the relative rates in percent - to warn the user! - if (_verbose) printOn( eo::log << eo::logging ); } diff --git a/eo/src/utils/eoData.h b/eo/src/utils/eoData.h index b5e11bac..ea70cabe 100644 --- a/eo/src/utils/eoData.h +++ b/eo/src/utils/eoData.h @@ -33,10 +33,6 @@ //----------------------------------------------------------------------------- // some defines to make things easier to get at first sight -// tuning the amount of output using a boolean argument: -// true should always mean more output -#define eo_verbose true -#define eo_no_verbose false // to be used in selection / replacement procedures to indicate whether // the argument (rate, a double) shoudl be treated as a rate (number=rate*popSize) // or as an absolute integer (number=rate regardless of popsize). diff --git a/eo/src/utils/eoOStreamMonitor.cpp b/eo/src/utils/eoOStreamMonitor.cpp index 817d9ab2..073793d8 100644 --- a/eo/src/utils/eoOStreamMonitor.cpp +++ b/eo/src/utils/eoOStreamMonitor.cpp @@ -25,38 +25,33 @@ eoMonitor& eoOStreamMonitor::operator()(void) if (firsttime) { - if (verbose) { eo::log << eo::progress << "First Generation" << std::endl; - } else { // else verbose - for (iterator it = vec.begin (); it != vec.end (); ++it) { - out << (*it)->longName (); - out << delim << std::left << std::setfill(fill) << std::setw(width); - } - out << std::endl; - } // else verbose + for (iterator it = vec.begin (); it != vec.end (); ++it) { + out << (*it)->longName (); + out << delim << std::left << std::setfill(fill) << std::setw(width); + } + out << std::endl; - firsttime = false; + firsttime = false; } // if firstime // ok, now the real saving. write out - if (verbose) { + /* TODO old verbose formatting, do we still need it? for (iterator it = vec.begin (); it != vec.end (); ++it) { // name: value out << (*it)->longName () << ": " << (*it)->getValue () << std::endl; } // for it in vec + */ - eo::log << eo::progress << "End of Generation" << std::endl; + for (iterator it = vec.begin (); it != vec.end (); ++it) { + // value only + out << (*it)->getValue (); + out << delim << std::left << std::setfill(fill) << std::setw(width); + } // for it in vec - } else { // else verbose - for (iterator it = vec.begin (); it != vec.end (); ++it) { - // value only - out << (*it)->getValue (); - out << delim << std::left << std::setfill(fill) << std::setw(width); - } // for it in vec - - out << std::endl; - } // if verbose + out << std::endl; + eo::log << eo::progress << "End of Generation" << std::endl; return *this; } diff --git a/eo/src/utils/eoOStreamMonitor.h b/eo/src/utils/eoOStreamMonitor.h index d9658804..506944cd 100644 --- a/eo/src/utils/eoOStreamMonitor.h +++ b/eo/src/utils/eoOStreamMonitor.h @@ -43,7 +43,10 @@ class eoOStreamMonitor : public eoMonitor { public : eoOStreamMonitor( std::ostream & _out, bool _verbose=true, std::string _delim = "\t", unsigned int _width=20, char _fill=' ' ) : - out(_out), verbose(_verbose), delim(_delim), width(_width), fill(_fill), firsttime(true) {} + out(_out), delim(_delim), width(_width), fill(_fill), firsttime(true) + { + eo::log << eo::warnings << "WARNING: the use of the verbose parameter in eoOStreamMonitor constructor is deprecated and will be removed in the next release" << std::endl; + } eoMonitor& operator()(void); @@ -51,7 +54,6 @@ public : private : std::ostream & out; - bool verbose; std::string delim; unsigned int width; char fill; diff --git a/eo/src/utils/eoStdoutMonitor.h b/eo/src/utils/eoStdoutMonitor.h index 4a2083ab..68e694c5 100644 --- a/eo/src/utils/eoStdoutMonitor.h +++ b/eo/src/utils/eoStdoutMonitor.h @@ -42,7 +42,11 @@ class eoStdoutMonitor : public eoOStreamMonitor { public : eoStdoutMonitor(bool _verbose=true, std::string _delim = "\t", unsigned int _width=20, char _fill=' ' ) : - eoOStreamMonitor( std::cout, _verbose, _delim, _width, _fill) {} + eoOStreamMonitor( std::cout, _verbose, _delim, _width, _fill) + { + + eo::log << eo::warnings << "WARNING: the use of the verbose parameter in eoStdutMonitor constructor is deprecated and will be removed in the next release" << std::endl; + } virtual std::string className(void) const { return "eoStdoutMonitor"; } };