Added a verbose mode (the default behavior) which is as before.
But when in non-verbose mode, prints only one line per generation.
This commit is contained in:
parent
0fd1336bfe
commit
08e6be4b66
2 changed files with 34 additions and 19 deletions
|
|
@ -10,28 +10,41 @@ using namespace std;
|
||||||
|
|
||||||
eoMonitor& eoStdoutMonitor::operator()(void)
|
eoMonitor& eoStdoutMonitor::operator()(void)
|
||||||
{
|
{
|
||||||
if (firsttime)
|
|
||||||
{
|
|
||||||
cout << "First Generation" << endl;
|
|
||||||
|
|
||||||
firsttime = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
// ok, now the real saving. write out
|
|
||||||
|
|
||||||
if (!cout)
|
if (!cout)
|
||||||
{
|
{
|
||||||
string str = "eoStdoutMonitor: Could not write to cout";
|
string str = "eoStdoutMonitor: Could not write to cout";
|
||||||
throw runtime_error(str);
|
throw runtime_error(str);
|
||||||
}
|
}
|
||||||
|
if (firsttime)
|
||||||
for(iterator it = vec.begin(); it != vec.end(); ++it)
|
|
||||||
{
|
{
|
||||||
cout << (*it)->longName() << ": " << (*it)->getValue() << '\n';
|
if (verbose)
|
||||||
|
cout << "First Generation" << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(iterator it = vec.begin(); it != vec.end(); ++it)
|
||||||
|
{
|
||||||
|
cout << (*it)->longName() << delim;
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
|
}
|
||||||
|
firsttime = false;
|
||||||
}
|
}
|
||||||
|
// ok, now the real saving. write out
|
||||||
cout << "\n****** End of Generation ******\n" << endl; // endl: flush
|
if (verbose)
|
||||||
|
{
|
||||||
|
for(iterator it = vec.begin(); it != vec.end(); ++it)
|
||||||
|
{
|
||||||
|
cout << (*it)->longName() << ": " << (*it)->getValue() << '\n';
|
||||||
|
}
|
||||||
|
cout << "\n****** End of Generation ******\n" << endl;
|
||||||
|
}
|
||||||
|
else // a one-liner
|
||||||
|
{
|
||||||
|
for(iterator it = vec.begin(); it != vec.end(); ++it)
|
||||||
|
{
|
||||||
|
cout << (*it)->getValue() << delim;
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,14 @@
|
||||||
class eoStdoutMonitor : public eoMonitor
|
class eoStdoutMonitor : public eoMonitor
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
eoStdoutMonitor(std::string _delim = "\t") : delim(_delim), firsttime(true) {}
|
eoStdoutMonitor(bool _verbose=true, std::string _delim = "\t") :
|
||||||
|
verbose(_verbose), delim(_delim), firsttime(true) {}
|
||||||
eoMonitor& operator()(void);
|
eoMonitor& operator()(void);
|
||||||
|
|
||||||
private :
|
private :
|
||||||
std::string delim;
|
bool verbose;
|
||||||
bool firsttime;
|
std::string delim;
|
||||||
|
bool firsttime;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue