diff --git a/src/db/db/dbCommonReader.cc b/src/db/db/dbCommonReader.cc index 315499971..0400621eb 100644 --- a/src/db/db/dbCommonReader.cc +++ b/src/db/db/dbCommonReader.cc @@ -556,6 +556,7 @@ CommonReader::read (db::Layout &layout) void CommonReader::init (const LoadLayoutOptions &options) { + ReaderBase::init (options); CommonReaderBase::init (); db::CommonReaderOptions common_options = options.get_options (); diff --git a/src/db/db/dbCommonReader.h b/src/db/db/dbCommonReader.h index 9610e1634..b5a5a9a19 100644 --- a/src/db/db/dbCommonReader.h +++ b/src/db/db/dbCommonReader.h @@ -237,7 +237,7 @@ protected: friend class CommonReaderLayerMapping; virtual void common_reader_error (const std::string &msg) = 0; - virtual void common_reader_warn (const std::string &msg) = 0; + virtual void common_reader_warn (const std::string &msg, int warn_level = 1) = 0; /** * @brief Merge (and delete) the src_cell into target_cell diff --git a/src/db/db/dbLoadLayoutOptions.cc b/src/db/db/dbLoadLayoutOptions.cc index 88356b4c5..4bcf972c9 100644 --- a/src/db/db/dbLoadLayoutOptions.cc +++ b/src/db/db/dbLoadLayoutOptions.cc @@ -30,6 +30,7 @@ namespace db { LoadLayoutOptions::LoadLayoutOptions () + : m_warn_level (1) { // .. nothing yet .. } @@ -44,6 +45,8 @@ namespace db { if (&d != this) { + m_warn_level = d.m_warn_level; + release (); for (std::map ::const_iterator o = d.m_options.begin (); o != d.m_options.end (); ++o) { m_options.insert (std::make_pair (o->first, o->second->clone ())); diff --git a/src/db/db/dbLoadLayoutOptions.h b/src/db/db/dbLoadLayoutOptions.h index 67262f353..0062cd551 100644 --- a/src/db/db/dbLoadLayoutOptions.h +++ b/src/db/db/dbLoadLayoutOptions.h @@ -79,6 +79,26 @@ public: */ ~LoadLayoutOptions (); + /** + * @brief Gets the warning level + * + * The warning level is a reader-specific setting which enables or disables warnings + * on specific levels. Level 0 is always "warnings off". The default level is 1 + * which means "reasonable warnings emitted". + */ + int warn_level () const + { + return m_warn_level; + } + + /** + * @brief Sets the warning level + */ + void set_warn_level (int w) + { + m_warn_level = w; + } + /** * @brief Sets specific options for the given format * @@ -217,6 +237,7 @@ public: private: std::map m_options; + int m_warn_level; void release (); }; diff --git a/src/db/db/dbReader.cc b/src/db/db/dbReader.cc index b48026113..93f49a354 100644 --- a/src/db/db/dbReader.cc +++ b/src/db/db/dbReader.cc @@ -61,7 +61,7 @@ join_layer_names (std::string &s, const std::string &n) // ReaderBase implementation ReaderBase::ReaderBase () - : m_warnings_as_errors (false) + : m_warnings_as_errors (false), m_warn_level (1) { } @@ -75,6 +75,12 @@ ReaderBase::set_warnings_as_errors (bool f) m_warnings_as_errors = f; } +void +ReaderBase::init (const db::LoadLayoutOptions &options) +{ + m_warn_level = options.warn_level (); +} + // --------------------------------------------------------------- // Reader implementation diff --git a/src/db/db/dbReader.h b/src/db/db/dbReader.h index d4dd83d9f..53b259dca 100644 --- a/src/db/db/dbReader.h +++ b/src/db/db/dbReader.h @@ -89,8 +89,20 @@ public: return m_warnings_as_errors; } + /** + * @brief Gets the warning level + */ + int warn_level () const + { + return m_warn_level; + } + +protected: + virtual void init (const db::LoadLayoutOptions &options); + private: bool m_warnings_as_errors; + int m_warn_level; }; /** diff --git a/src/db/db/gsiDeclDbReader.cc b/src/db/db/gsiDeclDbReader.cc index 2b97afcc2..d1909a6f0 100644 --- a/src/db/db/gsiDeclDbReader.cc +++ b/src/db/db/gsiDeclDbReader.cc @@ -384,7 +384,20 @@ namespace gsi // NOTE: the contribution comes from format specific extensions. Class decl_LoadLayoutOptions ("db", "LoadLayoutOptions", - gsi::Methods (), + gsi::method ("warn_level=", &db::LoadLayoutOptions::set_warn_level, gsi::arg ("level"), + "@brief Sets the warning level.\n" + "The warning level is a reader-specific setting which enables or disables warnings\n" + "on specific levels. Level 0 is always \"warnings off\". The default level is 1\n" + "which means \"reasonable warnings emitted\".\n" + "\n" + "This attribute has been added in version 0.28." + ) + + gsi::method ("warn_level", &db::LoadLayoutOptions::warn_level, + "@brief Sets the warning level.\n" + "See \\warn_level= for details about this attribute.\n" + "\n" + "This attribute has been added in version 0.28." + ), "@brief Layout reader options\n" "\n" "This object describes various layer reader options used for loading layouts.\n" diff --git a/src/plugins/streamers/cif/db_plugin/dbCIF.h b/src/plugins/streamers/cif/db_plugin/dbCIF.h index acf233e34..023dc61ec 100644 --- a/src/plugins/streamers/cif/db_plugin/dbCIF.h +++ b/src/plugins/streamers/cif/db_plugin/dbCIF.h @@ -53,7 +53,7 @@ public: /** * @brief Issue a warning with positional information */ - virtual void warn (const std::string &txt) = 0; + virtual void warn (const std::string &txt, int warn_level = 1) = 0; }; } diff --git a/src/plugins/streamers/cif/db_plugin/dbCIFReader.cc b/src/plugins/streamers/cif/db_plugin/dbCIFReader.cc index 1d935a0fe..0ac05f9de 100644 --- a/src/plugins/streamers/cif/db_plugin/dbCIFReader.cc +++ b/src/plugins/streamers/cif/db_plugin/dbCIFReader.cc @@ -59,6 +59,8 @@ CIFReader::~CIFReader () const LayerMap & CIFReader::read (db::Layout &layout, const db::LoadLayoutOptions &options) { + init (options); + const db::CIFReaderOptions &specific_options = options.get_options (); m_wire_mode = specific_options.wire_mode; m_dbu = specific_options.dbu; @@ -88,8 +90,12 @@ CIFReader::error (const std::string &msg) } void -CIFReader::warn (const std::string &msg) +CIFReader::warn (const std::string &msg, int wl) { + if (warn_level () < wl) { + return; + } + // TODO: compress tl::warn << msg << tl::to_string (tr (" (line=")) << m_stream.line_number () diff --git a/src/plugins/streamers/cif/db_plugin/dbCIFReader.h b/src/plugins/streamers/cif/db_plugin/dbCIFReader.h index 1b5240854..ba68c91df 100644 --- a/src/plugins/streamers/cif/db_plugin/dbCIFReader.h +++ b/src/plugins/streamers/cif/db_plugin/dbCIFReader.h @@ -129,7 +129,7 @@ public: * * Reimplements CIFDiagnostics */ - virtual void warn (const std::string &txt); + virtual void warn (const std::string &txt, int warn_level = 1); private: tl::TextInputStream m_stream; diff --git a/src/plugins/streamers/dxf/db_plugin/dbDXF.h b/src/plugins/streamers/dxf/db_plugin/dbDXF.h index 13ad9c55f..3fb51cfc5 100644 --- a/src/plugins/streamers/dxf/db_plugin/dbDXF.h +++ b/src/plugins/streamers/dxf/db_plugin/dbDXF.h @@ -53,7 +53,7 @@ public: /** * @brief Issue a warning with positional information */ - virtual void warn (const std::string &txt) = 0; + virtual void warn (const std::string &txt, int warn_level = 1) = 0; }; } diff --git a/src/plugins/streamers/dxf/db_plugin/dbDXFReader.cc b/src/plugins/streamers/dxf/db_plugin/dbDXFReader.cc index d63a8b03f..fdb586b4a 100644 --- a/src/plugins/streamers/dxf/db_plugin/dbDXFReader.cc +++ b/src/plugins/streamers/dxf/db_plugin/dbDXFReader.cc @@ -316,6 +316,8 @@ DXFReader::determine_polyline_mode () const LayerMap & DXFReader::read (db::Layout &layout, const db::LoadLayoutOptions &options) { + init (options); + const db::DXFReaderOptions &specific_options = options.get_options (); m_dbu = specific_options.dbu; @@ -372,8 +374,12 @@ DXFReader::error (const std::string &msg) } void -DXFReader::warn (const std::string &msg) +DXFReader::warn (const std::string &msg, int wl) { + if (warn_level () < wl) { + return; + } + // TODO: compress if (m_ascii) { tl::warn << msg @@ -2794,7 +2800,7 @@ DXFReader::read_entities (db::Layout &layout, db::Cell &cell, const db::DVector } } else { - warn ("Entity " + entity_code + " not supported - ignored."); + warn ("Entity " + entity_code + " not supported - ignored.", 2); while ((g = read_group_code()) != 0) { skip_value (g); } @@ -2978,7 +2984,7 @@ DXFReader::skip_value (int g) read_int32 (); } else { if (m_ascii) { - warn ("Unexpected group code: " + tl::to_string (g)); + warn ("Unexpected group code: " + tl::to_string (g), 2); } else { error ("Unexpected group code: " + tl::to_string (g)); } @@ -2998,7 +3004,7 @@ DXFReader::read_group_code () tl::Extractor ex (m_line.c_str ()); int x = 0; if (! ex.try_read (x) || ! ex.at_end ()) { - warn ("Expected an ASCII integer value - line ignored"); + warn ("Expected an ASCII integer value - line ignored", 2); } else { return x; } diff --git a/src/plugins/streamers/dxf/db_plugin/dbDXFReader.h b/src/plugins/streamers/dxf/db_plugin/dbDXFReader.h index 1bc2ffe24..c753cf81a 100644 --- a/src/plugins/streamers/dxf/db_plugin/dbDXFReader.h +++ b/src/plugins/streamers/dxf/db_plugin/dbDXFReader.h @@ -134,7 +134,7 @@ public: * * Reimplements DXFDiagnostics */ - virtual void warn (const std::string &txt); + virtual void warn (const std::string &txt, int warn_level = 1); private: struct VariantKey diff --git a/src/plugins/streamers/gds2/db_plugin/contrib/dbGDS2TextReader.cc b/src/plugins/streamers/gds2/db_plugin/contrib/dbGDS2TextReader.cc index 82aa1ec7f..a63c48869 100644 --- a/src/plugins/streamers/gds2/db_plugin/contrib/dbGDS2TextReader.cc +++ b/src/plugins/streamers/gds2/db_plugin/contrib/dbGDS2TextReader.cc @@ -302,8 +302,12 @@ GDS2ReaderText::error (const std::string &msg) } void -GDS2ReaderText::warn (const std::string &msg) +GDS2ReaderText::warn (const std::string &msg, int wl) { + if (warn_level () < wl) { + return; + } + // TODO: compress tl::warn << msg << tl::to_string (tr (", line number=")) << sStream.line_number() diff --git a/src/plugins/streamers/gds2/db_plugin/contrib/dbGDS2TextReader.h b/src/plugins/streamers/gds2/db_plugin/contrib/dbGDS2TextReader.h index 8463ba5fc..65fe36857 100644 --- a/src/plugins/streamers/gds2/db_plugin/contrib/dbGDS2TextReader.h +++ b/src/plugins/streamers/gds2/db_plugin/contrib/dbGDS2TextReader.h @@ -101,7 +101,7 @@ private: void vConvertToXY(const std::string &_sArg); void error (const std::string &txt); - void warn (const std::string &txt); + void warn (const std::string &txt, int warn_level = 1); }; } diff --git a/src/plugins/streamers/gds2/db_plugin/dbGDS2Reader.cc b/src/plugins/streamers/gds2/db_plugin/dbGDS2Reader.cc index c64725513..68b2a14f5 100644 --- a/src/plugins/streamers/gds2/db_plugin/dbGDS2Reader.cc +++ b/src/plugins/streamers/gds2/db_plugin/dbGDS2Reader.cc @@ -272,8 +272,12 @@ GDS2Reader::error (const std::string &msg) } void -GDS2Reader::warn (const std::string &msg) +GDS2Reader::warn (const std::string &msg, int wl) { + if (warn_level () < wl) { + return; + } + // TODO: compress tl::warn << msg << tl::to_string (tr (" (position=")) << m_stream.pos () diff --git a/src/plugins/streamers/gds2/db_plugin/dbGDS2Reader.h b/src/plugins/streamers/gds2/db_plugin/dbGDS2Reader.h index 8f965f222..bb32934b8 100644 --- a/src/plugins/streamers/gds2/db_plugin/dbGDS2Reader.h +++ b/src/plugins/streamers/gds2/db_plugin/dbGDS2Reader.h @@ -92,7 +92,7 @@ private: tl::AbsoluteProgress m_progress; virtual void error (const std::string &txt); - virtual void warn (const std::string &txt); + virtual void warn (const std::string &txt, int wl = 1); virtual std::string path () const; virtual const char *get_string (); diff --git a/src/plugins/streamers/gds2/db_plugin/dbGDS2ReaderBase.h b/src/plugins/streamers/gds2/db_plugin/dbGDS2ReaderBase.h index 7f07a382b..c8632e720 100644 --- a/src/plugins/streamers/gds2/db_plugin/dbGDS2ReaderBase.h +++ b/src/plugins/streamers/gds2/db_plugin/dbGDS2ReaderBase.h @@ -101,10 +101,10 @@ private: void finish_element (); virtual void common_reader_error (const std::string &msg) { error (msg); } - virtual void common_reader_warn (const std::string &msg) { warn (msg); } + virtual void common_reader_warn (const std::string &msg, int warn_level = 1) { warn (msg, warn_level); } virtual void error (const std::string &txt) = 0; - virtual void warn (const std::string &txt) = 0; + virtual void warn (const std::string &txt, int warn_level = 1) = 0; virtual std::string path () const = 0; virtual const char *get_string () = 0; diff --git a/src/plugins/streamers/lefdef/db_plugin/dbDEFImporter.cc b/src/plugins/streamers/lefdef/db_plugin/dbDEFImporter.cc index 3368a0558..7694722dc 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbDEFImporter.cc +++ b/src/plugins/streamers/lefdef/db_plugin/dbDEFImporter.cc @@ -52,8 +52,9 @@ struct DEFImporterGroup std::vector comp_match; }; -DEFImporter::DEFImporter () - : LEFDEFImporter () +DEFImporter::DEFImporter (int warn_level) + : LEFDEFImporter (warn_level), + m_lef_importer (warn_level) { // .. nothing yet .. } diff --git a/src/plugins/streamers/lefdef/db_plugin/dbDEFImporter.h b/src/plugins/streamers/lefdef/db_plugin/dbDEFImporter.h index 432bde8a1..d29be8c07 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbDEFImporter.h +++ b/src/plugins/streamers/lefdef/db_plugin/dbDEFImporter.h @@ -48,7 +48,7 @@ public: /** * @brief Default constructor */ - DEFImporter (); + DEFImporter (int warn_level = 1); /** * @brief Read the given LEF file prior to the DEF file diff --git a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.cc b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.cc index 1eafacd05..3dbdcf266 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.cc +++ b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.cc @@ -914,10 +914,10 @@ LEFDEFReaderState::common_reader_error (const std::string &msg) } void -LEFDEFReaderState::common_reader_warn (const std::string &msg) +LEFDEFReaderState::common_reader_warn (const std::string &msg, int warn_level) { if (mp_importer) { - mp_importer->warn (msg); + mp_importer->warn (msg, warn_level); } } @@ -1902,11 +1902,12 @@ LEFDEFReaderState::macro_cell (const std::string &mn, Layout &layout, const std: // ----------------------------------------------------------------------------------- // LEFDEFImporter implementation -LEFDEFImporter::LEFDEFImporter () +LEFDEFImporter::LEFDEFImporter (int warn_level) : mp_progress (0), mp_stream (0), mp_reader_state (0), m_produce_net_props (false), m_net_prop_name_id (0), m_produce_inst_props (false), m_inst_prop_name_id (0), - m_produce_pin_props (false), m_pin_prop_name_id (0) + m_produce_pin_props (false), m_pin_prop_name_id (0), + m_warn_level (warn_level) { // .. nothing yet .. } @@ -1993,8 +1994,12 @@ LEFDEFImporter::error (const std::string &msg) } void -LEFDEFImporter::warn (const std::string &msg) +LEFDEFImporter::warn (const std::string &msg, int wl) { + if (m_warn_level < wl) { + return; + } + tl::warn << msg << tl::to_string (tr (" (line=")) << mp_stream->line_number () << tl::to_string (tr (", cell=")) << m_cellname diff --git a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.h b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.h index ed0af0a49..b91e3dc50 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.h +++ b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.h @@ -1342,7 +1342,7 @@ public: protected: virtual void common_reader_error (const std::string &msg); - virtual void common_reader_warn (const std::string &msg); + virtual void common_reader_warn (const std::string &msg, int warn_level = 1); private: /** @@ -1490,7 +1490,7 @@ public: /** * @brief Default constructor */ - LEFDEFImporter (); + LEFDEFImporter (int warn_level); /** * @brief Destructor @@ -1520,7 +1520,7 @@ protected: /** * @brief Issue a warning at the current location */ - void warn (const std::string &msg); + void warn (const std::string &msg, int wl = 1); /** * @brief Returns true if the reader is at the end of the file @@ -1705,6 +1705,7 @@ private: bool m_produce_pin_props; db::property_names_id_type m_pin_prop_name_id; db::LEFDEFReaderOptions m_options; + int m_warn_level; const std::string &next (); }; diff --git a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc index bf4d35314..90e376a2f 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc +++ b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc @@ -110,6 +110,8 @@ LEFDEFReader::format () const const db::LayerMap & LEFDEFReader::read_lefdef (db::Layout &layout, const db::LoadLayoutOptions &options, bool import_lef) { + init (options); + const db::LEFDEFReaderOptions *lefdef_options = dynamic_cast (options.get_options (format ())); db::LEFDEFReaderOptions effective_options; if (lefdef_options) { @@ -135,7 +137,7 @@ LEFDEFReader::read_lefdef (db::Layout &layout, const db::LoadLayoutOptions &opti tl::SelfTimer timer (tl::verbosity () >= 21, tl::to_string (tr ("Reading LEF file"))); - db::LEFImporter importer; + db::LEFImporter importer (warn_level ()); for (std::vector::const_iterator l = effective_options.begin_lef_files (); l != effective_options.end_lef_files (); ++l) { @@ -156,7 +158,7 @@ LEFDEFReader::read_lefdef (db::Layout &layout, const db::LoadLayoutOptions &opti tl::SelfTimer timer (tl::verbosity () >= 21, tl::to_string (tr ("Reading DEF file"))); - DEFImporter importer; + DEFImporter importer (warn_level ()); for (std::vector::const_iterator l = effective_options.begin_lef_files (); l != effective_options.end_lef_files (); ++l) { diff --git a/src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.cc b/src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.cc index 5f458d7c8..316870c7d 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.cc +++ b/src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.cc @@ -33,7 +33,8 @@ namespace db // ----------------------------------------------------------------------------------- // LEFImporter implementation -LEFImporter::LEFImporter () +LEFImporter::LEFImporter (int warn_level) + : LEFDEFImporter (warn_level) { // .. nothing yet .. } diff --git a/src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.h b/src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.h index b638d775c..6be28fc5f 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.h +++ b/src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.h @@ -50,7 +50,7 @@ public: /** * @brief Default constructor */ - LEFImporter (); + LEFImporter (int warn_level); /** * @brief Destructor diff --git a/src/plugins/streamers/magic/db_plugin/dbMAG.h b/src/plugins/streamers/magic/db_plugin/dbMAG.h index 1ed40cedf..94602e9e2 100644 --- a/src/plugins/streamers/magic/db_plugin/dbMAG.h +++ b/src/plugins/streamers/magic/db_plugin/dbMAG.h @@ -53,7 +53,7 @@ public: /** * @brief Issue a warning with positional information */ - virtual void warn (const std::string &txt) = 0; + virtual void warn (const std::string &txt, int warn_level) = 0; }; } diff --git a/src/plugins/streamers/magic/db_plugin/dbMAGReader.cc b/src/plugins/streamers/magic/db_plugin/dbMAGReader.cc index ff5ccbe27..5e03c7b35 100644 --- a/src/plugins/streamers/magic/db_plugin/dbMAGReader.cc +++ b/src/plugins/streamers/magic/db_plugin/dbMAGReader.cc @@ -72,6 +72,8 @@ MAGReader::read (db::Layout &layout) const LayerMap & MAGReader::read (db::Layout &layout, const db::LoadLayoutOptions &options) { + init (options); + prepare_layers (layout); mp_klayout_tech = layout.technology (); @@ -135,8 +137,12 @@ MAGReader::error (const std::string &msg) } void -MAGReader::warn (const std::string &msg) +MAGReader::warn (const std::string &msg, int wl) { + if (warn_level () < wl) { + return; + } + // TODO: compress tl::warn << msg << tl::to_string (tr (" (line=")) << mp_current_stream->line_number () diff --git a/src/plugins/streamers/magic/db_plugin/dbMAGReader.h b/src/plugins/streamers/magic/db_plugin/dbMAGReader.h index 1d9901732..10eeee840 100644 --- a/src/plugins/streamers/magic/db_plugin/dbMAGReader.h +++ b/src/plugins/streamers/magic/db_plugin/dbMAGReader.h @@ -131,7 +131,7 @@ public: * * Reimplements MAGDiagnostics */ - virtual void warn (const std::string &txt); + virtual void warn (const std::string &txt, int wl = 1); private: tl::TextInputStream m_stream; diff --git a/src/plugins/streamers/oasis/db_plugin/dbOASIS.h b/src/plugins/streamers/oasis/db_plugin/dbOASIS.h index ec21e4937..f53ab29c2 100644 --- a/src/plugins/streamers/oasis/db_plugin/dbOASIS.h +++ b/src/plugins/streamers/oasis/db_plugin/dbOASIS.h @@ -55,7 +55,7 @@ public: /** * @brief Issue a warning with positional information */ - virtual void warn (const std::string &txt) = 0; + virtual void warn (const std::string &txt, int warn_level = 1) = 0; }; class RepetitionBase; diff --git a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc index 9e732deb0..3480e0530 100644 --- a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc +++ b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc @@ -489,8 +489,12 @@ OASISReader::error (const std::string &msg) } void -OASISReader::warn (const std::string &msg) +OASISReader::warn (const std::string &msg, int wl) { + if (warn_level () < wl) { + return; + } + if (warnings_as_errors ()) { error (msg); } else { diff --git a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h index 3ebab974e..db08f8fb0 100644 --- a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h +++ b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h @@ -99,10 +99,10 @@ protected: * * Reimplements OASISDiagnostics */ - virtual void warn (const std::string &txt); + virtual void warn (const std::string &txt, int warn_level = 1); virtual void common_reader_error (const std::string &msg) { error (msg); } - virtual void common_reader_warn (const std::string &msg) { warn (msg); } + virtual void common_reader_warn (const std::string &msg, int warn_level = 1) { warn (msg, warn_level); } virtual void init (const LoadLayoutOptions &options); virtual void do_read (db::Layout &layout); diff --git a/src/plugins/streamers/pcb/db_plugin/dbGerberDrillFileReader.cc b/src/plugins/streamers/pcb/db_plugin/dbGerberDrillFileReader.cc index 3067a94ff..68e0e43bb 100644 --- a/src/plugins/streamers/pcb/db_plugin/dbGerberDrillFileReader.cc +++ b/src/plugins/streamers/pcb/db_plugin/dbGerberDrillFileReader.cc @@ -29,8 +29,8 @@ namespace db // --------------------------------------------------------------------------------- // GerberDrillFileReader implementation -GerberDrillFileReader::GerberDrillFileReader () - : GerberFileReader () +GerberDrillFileReader::GerberDrillFileReader (int warn_level) + : GerberFileReader (warn_level) { init (); } diff --git a/src/plugins/streamers/pcb/db_plugin/dbGerberDrillFileReader.h b/src/plugins/streamers/pcb/db_plugin/dbGerberDrillFileReader.h index 749997ba1..24af0d39d 100644 --- a/src/plugins/streamers/pcb/db_plugin/dbGerberDrillFileReader.h +++ b/src/plugins/streamers/pcb/db_plugin/dbGerberDrillFileReader.h @@ -57,7 +57,7 @@ class GerberDrillFileReader : public GerberFileReader { public: - GerberDrillFileReader (); + GerberDrillFileReader (int warn_level); ~GerberDrillFileReader (); double um (double u) diff --git a/src/plugins/streamers/pcb/db_plugin/dbGerberImporter.cc b/src/plugins/streamers/pcb/db_plugin/dbGerberImporter.cc index 7f1a64142..f0cf8cb42 100644 --- a/src/plugins/streamers/pcb/db_plugin/dbGerberImporter.cc +++ b/src/plugins/streamers/pcb/db_plugin/dbGerberImporter.cc @@ -108,7 +108,7 @@ static std::string format_to_string (int l, int t, bool tz) // --------------------------------------------------------------------------------------- // Implementation of GerberFile -GerberFileReader::GerberFileReader () +GerberFileReader::GerberFileReader (int warn_level) : m_circle_points (64), m_digits_before (-1), m_digits_after (-1), m_omit_leading_zeroes (true), m_merge (false), m_inverse (false), m_dbu (0.001), m_unit (1000.0), @@ -117,7 +117,8 @@ GerberFileReader::GerberFileReader () m_orot (0.0), m_os (1.0), m_omx (false), m_omy (false), m_ep (true /*report progress*/), mp_layout (0), mp_top_cell (0), mp_stream (0), - m_progress (tl::to_string (tr ("Reading Gerber file")), 10000) + m_progress (tl::to_string (tr ("Reading Gerber file")), 10000), + m_warn_level (warn_level) { m_progress.set_format (tl::to_string (tr ("%.0f MB"))); m_progress.set_unit (1024 * 1024); @@ -196,8 +197,12 @@ GerberFileReader::format_string () const } void -GerberFileReader::warn (const std::string &warning) +GerberFileReader::warn (const std::string &warning, int wl) { + if (m_warn_level < wl) { + return; + } + tl::warn << warning << tl::to_string (tr (" in line ")) << mp_stream->line_number () << tl::to_string (tr (" (file ")) << mp_stream->source () << ")"; } @@ -541,18 +546,18 @@ GerberFile::layers_string () const // Implementation of GerberImporter // TODO: generalize this: -std::vector > get_readers () +std::vector > get_readers (int warn_level) { std::vector > readers; - readers.push_back (new db::GerberDrillFileReader ()); - readers.push_back (new db::RS274XReader ()); + readers.push_back (new db::GerberDrillFileReader (warn_level)); + readers.push_back (new db::RS274XReader (warn_level)); return readers; } -GerberImporter::GerberImporter () +GerberImporter::GerberImporter (int warn_level) : m_cell_name ("PCB"), m_dbu (0.001), m_merge (false), m_invert_negative_layers (false), m_border (5000), - m_circle_points (64) + m_circle_points (64), m_warn_level (warn_level) { // .. nothing yet .. } @@ -593,7 +598,7 @@ GerberImporter::scan (tl::TextInputStream &stream) { try { - std::vector > readers = get_readers (); + std::vector > readers = get_readers (0); // determine the reader to use: for (std::vector >::iterator r = readers.begin (); r != readers.end (); ++r) { @@ -1010,7 +1015,7 @@ GerberImporter::do_read (db::Layout &layout, db::cell_index_type cell_index) tl::InputStream input_file (fp); tl::TextInputStream stream (input_file); - std::vector > readers = get_readers (); + std::vector > readers = get_readers (m_warn_level); // determine the reader to use: db::GerberFileReader *reader = 0; @@ -1115,14 +1120,16 @@ public: // .. nothing yet .. } - virtual const db::LayerMap &read (db::Layout &layout, const db::LoadLayoutOptions & /*options*/) - { - // TODO: too simple, should provide at least a layer filtering. - return read (layout); - } - virtual const db::LayerMap &read (db::Layout &layout) { + return read (layout, db::LoadLayoutOptions ()); + } + + virtual const db::LayerMap &read (db::Layout &layout, const db::LoadLayoutOptions &options) + { + init (options); + + // TODO: too simple, should provide at least a layer filtering. db::GerberImportData data; std::string fn (m_stream.source ()); @@ -1132,7 +1139,7 @@ public: data.load (m_stream); - db::GerberImporter importer; + db::GerberImporter importer (warn_level ()); data.setup_importer (&importer); importer.read (layout); diff --git a/src/plugins/streamers/pcb/db_plugin/dbGerberImporter.h b/src/plugins/streamers/pcb/db_plugin/dbGerberImporter.h index 0fcf5ebc4..a5eb64494 100644 --- a/src/plugins/streamers/pcb/db_plugin/dbGerberImporter.h +++ b/src/plugins/streamers/pcb/db_plugin/dbGerberImporter.h @@ -184,7 +184,7 @@ public: /** * @brief Constructor */ - GerberFileReader (); + GerberFileReader (int warn_level); /** * @brief Destructor @@ -405,7 +405,7 @@ protected: /** * @brief Issue a warning */ - void warn (const std::string &warning); + void warn (const std::string &warning, int warn_level = 1); /** * @brief Issue a non-fatal error @@ -597,6 +597,7 @@ private: tl::TextInputStream *mp_stream; tl::AbsoluteProgress m_progress; std::list m_graphics_stack; + int m_warn_level; void process_clear_polygons (); void swap_graphics_state (GraphicsState &state); @@ -775,7 +776,7 @@ public: /** * @brief Default constructor */ - GerberImporter (); + GerberImporter (int warn_level = 1); /** * @brief Scans the given file and extracts the metadata from it @@ -1043,6 +1044,7 @@ private: bool m_invert_negative_layers; double m_border; int m_circle_points; + int m_warn_level; std::string m_format_string; std::string m_layer_styles; std::string m_dir; diff --git a/src/plugins/streamers/pcb/db_plugin/dbRS274XReader.cc b/src/plugins/streamers/pcb/db_plugin/dbRS274XReader.cc index ee8e4eec8..627e14da6 100644 --- a/src/plugins/streamers/pcb/db_plugin/dbRS274XReader.cc +++ b/src/plugins/streamers/pcb/db_plugin/dbRS274XReader.cc @@ -30,8 +30,8 @@ namespace db // --------------------------------------------------------------------------------- // RS274XReader implementation -RS274XReader::RS274XReader () - : GerberFileReader () +RS274XReader::RS274XReader (int warn_level) + : GerberFileReader (warn_level) { init (); } diff --git a/src/plugins/streamers/pcb/db_plugin/dbRS274XReader.h b/src/plugins/streamers/pcb/db_plugin/dbRS274XReader.h index 77db31ee0..22c834f57 100644 --- a/src/plugins/streamers/pcb/db_plugin/dbRS274XReader.h +++ b/src/plugins/streamers/pcb/db_plugin/dbRS274XReader.h @@ -48,7 +48,7 @@ class RS274XReader : public GerberFileReader { public: - RS274XReader (); + RS274XReader (int warn_level); ~RS274XReader (); double um (double u) diff --git a/testdata/ruby/dbReaders.rb b/testdata/ruby/dbReaders.rb index 47dba1771..1fe9057d3 100644 --- a/testdata/ruby/dbReaders.rb +++ b/testdata/ruby/dbReaders.rb @@ -29,6 +29,11 @@ class DBReaders_TestClass < TestBase def test_common_options opt = RBA::LoadLayoutOptions::new + + assert_equal(opt.warn_level, 1) + opt.warn_level = 2 + assert_equal(opt.warn_level, 2) + lm = RBA::LayerMap::new lm.map(RBA::LayerInfo::new(1, 0), 2, RBA::LayerInfo::new(42, 17)) opt.set_layer_map(lm, true)