Buddies: progress with -d >= 10 and XOR: enhanced report

This commit is contained in:
Matthias Koefferlein 2017-08-22 21:38:56 +02:00
parent f53a3be51a
commit 9633a1b9af
3 changed files with 100 additions and 16 deletions

View File

@ -22,6 +22,7 @@
#include "bdInit.h"
#include "tlCommandLineParser.h"
#include "tlProgress.h"
#include "version.h"
namespace bd
@ -47,9 +48,84 @@ void init ()
tl::CommandLineOptions::set_license (license);
}
class ProgressAdaptor
: public tl::ProgressAdaptor
{
public:
ProgressAdaptor (int verbosity);
virtual ~ProgressAdaptor ();
virtual void register_object (tl::Progress *progress);
virtual void unregister_object (tl::Progress *progress);
virtual void trigger (tl::Progress *progress);
virtual void yield (tl::Progress *progress);
private:
std::list<tl::Progress *> mp_objects;
int m_verbosity;
std::string m_progress_text, m_progress_value;
};
ProgressAdaptor::ProgressAdaptor (int verbosity)
: m_verbosity (verbosity)
{
// .. nothing yet ..
}
ProgressAdaptor::~ProgressAdaptor ()
{
// .. nothing yet ..
}
void
ProgressAdaptor::register_object (tl::Progress *progress)
{
mp_objects.push_back (progress); // this keeps the outmost one visible. push_front would make the latest one visible.
}
void
ProgressAdaptor::unregister_object (tl::Progress *progress)
{
for (std::list<tl::Progress *>::iterator k = mp_objects.begin (); k != mp_objects.end (); ++k) {
if (*k == progress) {
mp_objects.erase (k);
return;
}
}
}
void
ProgressAdaptor::trigger (tl::Progress *progress)
{
if (! mp_objects.empty () && mp_objects.front () == progress && tl::verbosity () >= m_verbosity) {
std::string text = mp_objects.front ()->desc ();
if (m_progress_text != text) {
tl::info << text << " ..";
m_progress_text = text;
}
std::string value = mp_objects.front ()->formatted_value ();
if (m_progress_value != value) {
tl::info << ".. " << value;
m_progress_value = value;
}
}
}
void
ProgressAdaptor::yield (tl::Progress * /*progress*/)
{
// .. nothing yet ..
}
int _main_impl (int (*delegate) (int, char *[]), int argc, char *argv[])
{
try {
ProgressAdaptor progress_adaptor (10);
init ();
return (*delegate) (argc, argv);
} catch (tl::CancelException & /*ex*/) {

View File

@ -432,11 +432,11 @@ BD_PUBLIC int strmxor (int argc, char *argv[])
tl::info << "No differences found";
} else {
const char *line_format = " %-10s %s";
const char *line_format = " %-10s %-12s %s";
const char *sep = " -------------------------------------------------------";
tl::info << "Result summary (layers without differences are not shown):" << tl::endl;
tl::info << tl::sprintf (line_format, "Layer", "Differences (shape count)") << tl::endl << sep;
tl::info << tl::sprintf (line_format, "Layer", "Output", "Differences (shape count)") << tl::endl << sep;
int ti = -1;
for (std::map<std::pair<int, db::LayerProperties>, ResultDescriptor>::const_iterator r = results.begin (); r != results.end (); ++r) {
@ -445,16 +445,24 @@ BD_PUBLIC int strmxor (int argc, char *argv[])
ti = r->first.first;
if (tolerances[ti] > db::epsilon) {
tl::info << tl::endl << "Tolerance " << tl::micron_to_string (tolerances[ti]) << ":" << tl::endl;
tl::info << tl::sprintf (line_format, "Layer", "Differences (shape count)") << tl::endl << sep;
tl::info << tl::sprintf (line_format, "Layer", "Output", "Differences (shape count)") << tl::endl << sep;
}
}
std::string out ("-");
std::string value;
if (r->second.layer_a < 0 && ! dont_summarize_missing_layers) {
tl::info << tl::sprintf (line_format, r->first.second.to_string (), "(no such layer in first layout)");
value = "(no such layer in first layout)";
} else if (r->second.layer_b < 0 && ! dont_summarize_missing_layers) {
tl::info << tl::sprintf (line_format, r->first.second.to_string (), "(no such layer in second layout)");
value = "(no such layer in second layout)";
} else if (! r->second.is_empty ()) {
tl::info << tl::sprintf (line_format, r->first.second.to_string (), tl::to_string (r->second.count ()));
if (r->second.layer_output >= 0 && r->second.layout) {
out = r->second.layout->get_properties (r->second.layer_output).to_string ();
}
value = tl::to_string (r->second.count ());
}
if (! value.empty ()) {
tl::info << tl::sprintf (line_format, r->first.second.to_string (), out, value);
}
}

View File

@ -82,12 +82,12 @@ TEST(1A)
"Layer 10/0 is not present in first layout, but in second\n"
"Result summary (layers without differences are not shown):\n"
"\n"
" Layer Differences (shape count)\n"
" Layer Output Differences (shape count)\n"
" -------------------------------------------------------\n"
" 3/0 30\n"
" 6/0 41\n"
" 8/1 1\n"
" 10/0 (no such layer in first layout)\n"
" 3/0 3/0 30\n"
" 6/0 6/0 41\n"
" 8/1 8/1 1\n"
" 10/0 - (no such layer in first layout)\n"
"\n"
);
}
@ -112,12 +112,12 @@ TEST(1B)
"Layer 10/0 is not present in first layout, but in second\n"
"Result summary (layers without differences are not shown):\n"
"\n"
" Layer Differences (shape count)\n"
" Layer Output Differences (shape count)\n"
" -------------------------------------------------------\n"
" 3/0 30\n"
" 6/0 41\n"
" 8/1 1\n"
" 10/0 (no such layer in first layout)\n"
" 3/0 - 30\n"
" 6/0 - 41\n"
" 8/1 - 1\n"
" 10/0 - (no such layer in first layout)\n"
"\n"
);
}