From a70b20c2c4e3e3bf45d291cd1a5306fe5286e253 Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Wed, 1 Jan 2025 07:12:06 +0000 Subject: [PATCH 01/15] odb: rm dbGDSNode Obsolete gds record. Not reving the schema since we have no usage of the GDS classes. Signed-off-by: Matt Liberty --- src/odb/include/odb/db.h | 27 --- src/odb/include/odb/dbCompare.h | 9 - src/odb/include/odb/dbObject.h | 1 - src/odb/include/odb/gdsin.h | 2 +- src/odb/include/odb/gdsout.h | 1 - src/odb/src/codeGenerator/schema.json | 6 - .../codeGenerator/schema/gds/dbGDSNode.json | 33 ---- src/odb/src/db/CMakeLists.txt | 1 - src/odb/src/db/dbGDSNode.cpp | 183 ------------------ src/odb/src/db/dbGDSNode.h | 70 ------- src/odb/src/db/dbGDSStructure.cpp | 20 -- src/odb/src/db/dbGDSStructure.h | 3 - src/odb/src/db/dbObject.cpp | 1 - src/odb/src/gdsin/gdsin.cpp | 23 ++- src/odb/src/gdsout/gdsout.cpp | 25 --- src/odb/test/cpp/TestGDSIn.cpp | 12 -- 16 files changed, 12 insertions(+), 405 deletions(-) delete mode 100644 src/odb/src/codeGenerator/schema/gds/dbGDSNode.json delete mode 100644 src/odb/src/db/dbGDSNode.cpp delete mode 100644 src/odb/src/db/dbGDSNode.h diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index 00475c2f429..4cd77d91fc9 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -134,7 +134,6 @@ class dbDft; class dbGCellGrid; class dbGDSBoundary; class dbGDSBox; -class dbGDSNode; class dbGDSPath; class dbGDSSRef; class dbGDSStructure; @@ -7505,30 +7504,6 @@ class dbGDSBox : public dbObject // User Code End dbGDSBox }; -class dbGDSNode : public dbObject -{ - public: - void setLayer(int16_t layer); - - int16_t getLayer() const; - - void setDatatype(int16_t datatype); - - int16_t getDatatype() const; - - void setXy(const std::vector& xy); - - void getXy(std::vector& tbl) const; - - // User Code Begin dbGDSNode - const std::vector& getXY(); - std::vector>& getPropattr(); - - static dbGDSNode* create(dbGDSStructure* structure); - static void destroy(dbGDSNode* node); - // User Code End dbGDSNode -}; - class dbGDSPath : public dbObject { public: @@ -7609,8 +7584,6 @@ class dbGDSStructure : public dbObject dbSet getGDSBoxs() const; - dbSet getGDSNodes() const; - dbSet getGDSPaths() const; dbSet getGDSSRefs() const; diff --git a/src/odb/include/odb/dbCompare.h b/src/odb/include/odb/dbCompare.h index 51ac12536a3..a9cfe7faadd 100644 --- a/src/odb/include/odb/dbCompare.h +++ b/src/odb/include/odb/dbCompare.h @@ -545,15 +545,6 @@ struct less } }; -template <> -struct less -{ - bool operator()(const odb::dbGDSNode* lhs, const odb::dbGDSNode* rhs) const - { - return odb::compare_by_id(lhs, rhs); - } -}; - template <> struct less { diff --git a/src/odb/include/odb/dbObject.h b/src/odb/include/odb/dbObject.h index 47676ee04c9..a3089e6df74 100644 --- a/src/odb/include/odb/dbObject.h +++ b/src/odb/include/odb/dbObject.h @@ -93,7 +93,6 @@ enum dbObjectType dbGCellGridObj, dbGDSBoundaryObj, dbGDSBoxObj, - dbGDSNodeObj, dbGDSPathObj, dbGDSSRefObj, dbGDSStructureObj, diff --git a/src/odb/include/odb/gdsin.h b/src/odb/include/odb/gdsin.h index 7c5518803fa..573a523db7d 100644 --- a/src/odb/include/odb/gdsin.h +++ b/src/odb/include/odb/gdsin.h @@ -129,7 +129,7 @@ class GDSReader dbGDSSRef* processSRef(dbGDSStructure* structure); dbGDSText* processText(dbGDSStructure* structure); dbGDSBox* processBox(dbGDSStructure* structure); - dbGDSNode* processNode(dbGDSStructure* structure); + void processNode(); /** * Parses special attributes of a GDS Element diff --git a/src/odb/include/odb/gdsout.h b/src/odb/include/odb/gdsout.h index 47cc86f2c3a..f15935afd7c 100644 --- a/src/odb/include/odb/gdsout.h +++ b/src/odb/include/odb/gdsout.h @@ -112,7 +112,6 @@ class GDSWriter void writeSRef(dbGDSSRef* sref); void writeText(dbGDSText* text); void writeBox(dbGDSBox* box); - void writeNode(dbGDSNode* node); /** Writes a Transform to _file */ void writeSTrans(const dbGDSSTrans& strans); diff --git a/src/odb/src/codeGenerator/schema.json b/src/odb/src/codeGenerator/schema.json index feb0e9a4780..278de3d2647 100644 --- a/src/odb/src/codeGenerator/schema.json +++ b/src/odb/src/codeGenerator/schema.json @@ -324,12 +324,6 @@ "type": "1_n", "tbl_name": "boxes_" }, - { - "first": "dbGDSStructure", - "second": "dbGDSNode", - "type": "1_n", - "tbl_name": "nodes_" - }, { "first": "dbGDSStructure", "second": "dbGDSPath", diff --git a/src/odb/src/codeGenerator/schema/gds/dbGDSNode.json b/src/odb/src/codeGenerator/schema/gds/dbGDSNode.json deleted file mode 100644 index a304c49fb0a..00000000000 --- a/src/odb/src/codeGenerator/schema/gds/dbGDSNode.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name":"dbGDSNode", - "type":"dbObject", - "fields":[ - { - "name":"_layer", - "type":"int16_t", - "default":"0", - "flags":[] - }, - { - "name":"_datatype", - "type":"int16_t", - "default":"0", - "flags":[] - }, - { - "name":"_xy", - "type":"std::vector", - "flags":["no-template"] - }, - { - "name":"_propattr", - "type":"std::vector>", - "flags":["no-template", "no-get", "no-set"] - } - ], - "h_includes": [ - "dbGDSStructure.h" - ], - "cpp_includes": ["odb/dbTypes.h"] -} - diff --git a/src/odb/src/db/CMakeLists.txt b/src/odb/src/db/CMakeLists.txt index 03f1ea51d87..2c2d8639149 100644 --- a/src/odb/src/db/CMakeLists.txt +++ b/src/odb/src/db/CMakeLists.txt @@ -93,7 +93,6 @@ add_library(db dbGCellGrid.cpp dbGDSBoundary.cpp dbGDSBox.cpp - dbGDSNode.cpp dbGDSPath.cpp dbGDSSRef.cpp dbGDSStructure.cpp diff --git a/src/odb/src/db/dbGDSNode.cpp b/src/odb/src/db/dbGDSNode.cpp deleted file mode 100644 index 721c1d0fdeb..00000000000 --- a/src/odb/src/db/dbGDSNode.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// BSD 3-Clause License -// -// Copyright (c) 2022, The Regents of the University of California -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -// Generator Code Begin Cpp -#include "dbGDSNode.h" - -#include "dbDatabase.h" -#include "dbDiff.hpp" -#include "dbTable.h" -#include "dbTable.hpp" -#include "odb/db.h" -#include "odb/dbTypes.h" -namespace odb { -template class dbTable<_dbGDSNode>; - -bool _dbGDSNode::operator==(const _dbGDSNode& rhs) const -{ - if (_layer != rhs._layer) { - return false; - } - if (_datatype != rhs._datatype) { - return false; - } - - return true; -} - -bool _dbGDSNode::operator<(const _dbGDSNode& rhs) const -{ - return true; -} - -void _dbGDSNode::differences(dbDiff& diff, - const char* field, - const _dbGDSNode& rhs) const -{ - DIFF_BEGIN - DIFF_FIELD(_layer); - DIFF_FIELD(_datatype); - DIFF_END -} - -void _dbGDSNode::out(dbDiff& diff, char side, const char* field) const -{ - DIFF_OUT_BEGIN - DIFF_OUT_FIELD(_layer); - DIFF_OUT_FIELD(_datatype); - - DIFF_END -} - -_dbGDSNode::_dbGDSNode(_dbDatabase* db) -{ - _layer = 0; - _datatype = 0; -} - -_dbGDSNode::_dbGDSNode(_dbDatabase* db, const _dbGDSNode& r) -{ - _layer = r._layer; - _datatype = r._datatype; -} - -dbIStream& operator>>(dbIStream& stream, _dbGDSNode& obj) -{ - stream >> obj._layer; - stream >> obj._datatype; - stream >> obj._xy; - stream >> obj._propattr; - return stream; -} - -dbOStream& operator<<(dbOStream& stream, const _dbGDSNode& obj) -{ - stream << obj._layer; - stream << obj._datatype; - stream << obj._xy; - stream << obj._propattr; - return stream; -} - -//////////////////////////////////////////////////////////////////// -// -// dbGDSNode - Methods -// -//////////////////////////////////////////////////////////////////// - -void dbGDSNode::setLayer(int16_t layer) -{ - _dbGDSNode* obj = (_dbGDSNode*) this; - - obj->_layer = layer; -} - -int16_t dbGDSNode::getLayer() const -{ - _dbGDSNode* obj = (_dbGDSNode*) this; - return obj->_layer; -} - -void dbGDSNode::setDatatype(int16_t datatype) -{ - _dbGDSNode* obj = (_dbGDSNode*) this; - - obj->_datatype = datatype; -} - -int16_t dbGDSNode::getDatatype() const -{ - _dbGDSNode* obj = (_dbGDSNode*) this; - return obj->_datatype; -} - -void dbGDSNode::setXy(const std::vector& xy) -{ - _dbGDSNode* obj = (_dbGDSNode*) this; - - obj->_xy = xy; -} - -void dbGDSNode::getXy(std::vector& tbl) const -{ - _dbGDSNode* obj = (_dbGDSNode*) this; - tbl = obj->_xy; -} - -// User Code Begin dbGDSNodePublicMethods -std::vector>& dbGDSNode::getPropattr() -{ - auto* obj = (_dbGDSNode*) this; - return obj->_propattr; -} - -const std::vector& dbGDSNode::getXY() -{ - auto obj = (_dbGDSNode*) this; - return obj->_xy; -} - -dbGDSNode* dbGDSNode::create(dbGDSStructure* structure) -{ - auto* obj = (_dbGDSStructure*) structure; - return (dbGDSNode*) obj->nodes_->create(); -} - -void dbGDSNode::destroy(dbGDSNode* node) -{ - auto* obj = (_dbGDSNode*) node; - auto* structure = (_dbGDSStructure*) obj->getOwner(); - structure->nodes_->destroy(obj); -} -// User Code End dbGDSNodePublicMethods -} // namespace odb - // Generator Code End Cpp diff --git a/src/odb/src/db/dbGDSNode.h b/src/odb/src/db/dbGDSNode.h deleted file mode 100644 index c744e4a2166..00000000000 --- a/src/odb/src/db/dbGDSNode.h +++ /dev/null @@ -1,70 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// BSD 3-Clause License -// -// Copyright (c) 2022, The Regents of the University of California -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -// Generator Code Begin Header -#pragma once - -#include "dbCore.h" -#include "dbGDSStructure.h" -#include "odb/odb.h" - -namespace odb { -class dbIStream; -class dbOStream; -class dbDiff; -class _dbDatabase; - -class _dbGDSNode : public _dbObject -{ - public: - _dbGDSNode(_dbDatabase*, const _dbGDSNode& r); - _dbGDSNode(_dbDatabase*); - - ~_dbGDSNode() = default; - - bool operator==(const _dbGDSNode& rhs) const; - bool operator!=(const _dbGDSNode& rhs) const { return !operator==(rhs); } - bool operator<(const _dbGDSNode& rhs) const; - void differences(dbDiff& diff, - const char* field, - const _dbGDSNode& rhs) const; - void out(dbDiff& diff, char side, const char* field) const; - - int16_t _layer; - int16_t _datatype; - std::vector _xy; - std::vector> _propattr; -}; -dbIStream& operator>>(dbIStream& stream, _dbGDSNode& obj); -dbOStream& operator<<(dbOStream& stream, const _dbGDSNode& obj); -} // namespace odb - // Generator Code End Header diff --git a/src/odb/src/db/dbGDSStructure.cpp b/src/odb/src/db/dbGDSStructure.cpp index 09714cfdd10..64e66376009 100644 --- a/src/odb/src/db/dbGDSStructure.cpp +++ b/src/odb/src/db/dbGDSStructure.cpp @@ -38,7 +38,6 @@ #include "dbGDSBoundary.h" #include "dbGDSBox.h" #include "dbGDSLib.h" -#include "dbGDSNode.h" #include "dbGDSPath.h" #include "dbGDSSRef.h" #include "dbGDSText.h" @@ -65,9 +64,6 @@ bool _dbGDSStructure::operator==(const _dbGDSStructure& rhs) const if (*boxes_ != *rhs.boxes_) { return false; } - if (*nodes_ != *rhs.nodes_) { - return false; - } if (*paths_ != *rhs.paths_) { return false; } @@ -95,7 +91,6 @@ void _dbGDSStructure::differences(dbDiff& diff, DIFF_FIELD(_next_entry); DIFF_TABLE(boundaries_); DIFF_TABLE(boxes_); - DIFF_TABLE(nodes_); DIFF_TABLE(paths_); DIFF_TABLE(srefs_); DIFF_TABLE(texts_); @@ -109,7 +104,6 @@ void _dbGDSStructure::out(dbDiff& diff, char side, const char* field) const DIFF_OUT_FIELD(_next_entry); DIFF_OUT_TABLE(boundaries_); DIFF_OUT_TABLE(boxes_); - DIFF_OUT_TABLE(nodes_); DIFF_OUT_TABLE(paths_); DIFF_OUT_TABLE(srefs_); DIFF_OUT_TABLE(texts_); @@ -127,8 +121,6 @@ _dbGDSStructure::_dbGDSStructure(_dbDatabase* db) dbGDSBoundaryObj); boxes_ = new dbTable<_dbGDSBox>( db, this, (GetObjTbl_t) &_dbGDSStructure::getObjectTable, dbGDSBoxObj); - nodes_ = new dbTable<_dbGDSNode>( - db, this, (GetObjTbl_t) &_dbGDSStructure::getObjectTable, dbGDSNodeObj); paths_ = new dbTable<_dbGDSPath>( db, this, (GetObjTbl_t) &_dbGDSStructure::getObjectTable, dbGDSPathObj); srefs_ = new dbTable<_dbGDSSRef>( @@ -143,7 +135,6 @@ _dbGDSStructure::_dbGDSStructure(_dbDatabase* db, const _dbGDSStructure& r) _next_entry = r._next_entry; boundaries_ = new dbTable<_dbGDSBoundary>(db, this, *r.boundaries_); boxes_ = new dbTable<_dbGDSBox>(db, this, *r.boxes_); - nodes_ = new dbTable<_dbGDSNode>(db, this, *r.nodes_); paths_ = new dbTable<_dbGDSPath>(db, this, *r.paths_); srefs_ = new dbTable<_dbGDSSRef>(db, this, *r.srefs_); texts_ = new dbTable<_dbGDSText>(db, this, *r.texts_); @@ -155,7 +146,6 @@ dbIStream& operator>>(dbIStream& stream, _dbGDSStructure& obj) stream >> obj._next_entry; stream >> *obj.boundaries_; stream >> *obj.boxes_; - stream >> *obj.nodes_; stream >> *obj.paths_; stream >> *obj.srefs_; stream >> *obj.texts_; @@ -168,7 +158,6 @@ dbOStream& operator<<(dbOStream& stream, const _dbGDSStructure& obj) stream << obj._next_entry; stream << *obj.boundaries_; stream << *obj.boxes_; - stream << *obj.nodes_; stream << *obj.paths_; stream << *obj.srefs_; stream << *obj.texts_; @@ -182,8 +171,6 @@ dbObjectTable* _dbGDSStructure::getObjectTable(dbObjectType type) return boundaries_; case dbGDSBoxObj: return boxes_; - case dbGDSNodeObj: - return nodes_; case dbGDSPathObj: return paths_; case dbGDSSRefObj: @@ -203,7 +190,6 @@ _dbGDSStructure::~_dbGDSStructure() } delete boundaries_; delete boxes_; - delete nodes_; delete paths_; delete srefs_; delete texts_; @@ -233,12 +219,6 @@ dbSet dbGDSStructure::getGDSBoxs() const return dbSet(obj, obj->boxes_); } -dbSet dbGDSStructure::getGDSNodes() const -{ - _dbGDSStructure* obj = (_dbGDSStructure*) this; - return dbSet(obj, obj->nodes_); -} - dbSet dbGDSStructure::getGDSPaths() const { _dbGDSStructure* obj = (_dbGDSStructure*) this; diff --git a/src/odb/src/db/dbGDSStructure.h b/src/odb/src/db/dbGDSStructure.h index e5f2f39d56f..b3345826d8e 100644 --- a/src/odb/src/db/dbGDSStructure.h +++ b/src/odb/src/db/dbGDSStructure.h @@ -48,7 +48,6 @@ class _dbGDSBoundary; template class dbTable; class _dbGDSBox; -class _dbGDSNode; class _dbGDSPath; class _dbGDSSRef; class _dbGDSText; @@ -77,8 +76,6 @@ class _dbGDSStructure : public _dbObject dbTable<_dbGDSBox>* boxes_; - dbTable<_dbGDSNode>* nodes_; - dbTable<_dbGDSPath>* paths_; dbTable<_dbGDSSRef>* srefs_; diff --git a/src/odb/src/db/dbObject.cpp b/src/odb/src/db/dbObject.cpp index bbfd8a02eb2..a9218fe46d5 100644 --- a/src/odb/src/db/dbObject.cpp +++ b/src/odb/src/db/dbObject.cpp @@ -97,7 +97,6 @@ static const char* name_tbl[] = {"dbDatabase", "dbGCellGrid", "dbGDSBoundary", "dbGDSBox", - "dbGDSNode", "dbGDSPath", "dbGDSSRef", "dbGDSStructure", diff --git a/src/odb/src/gdsin/gdsin.cpp b/src/odb/src/gdsin/gdsin.cpp index 82424d9cbb7..b836daa29f8 100644 --- a/src/odb/src/gdsin/gdsin.cpp +++ b/src/odb/src/gdsin/gdsin.cpp @@ -244,7 +244,9 @@ bool GDSReader::processXY(T* elem) for (int i = 0; i < _r.data32.size(); i += 2) { xy.emplace_back(_r.data32[i], _r.data32[i + 1]); } - elem->setXy(xy); + if (elem) { + elem->setXy(xy); + } return true; } @@ -263,7 +265,9 @@ void GDSReader::processPropAttr(T* elem) checkRType(RecordType::PROPVALUE); const std::string value = _r.data8; - elem->getPropattr().emplace_back(attr, value); + if (elem) { + elem->getPropattr().emplace_back(attr, value); + } } } @@ -297,8 +301,9 @@ bool GDSReader::processElement(dbGDSStructure* structure) break; } case RecordType::NODE: { - auto el = processNode(structure); - processPropAttr(el); + // Ignored - parse and discard + processNode(); + processPropAttr(nullptr); break; } default: { @@ -447,22 +452,16 @@ dbGDSBox* GDSReader::processBox(dbGDSStructure* structure) return box; } -dbGDSNode* GDSReader::processNode(dbGDSStructure* structure) +void GDSReader::processNode() { - auto* elem = dbGDSNode::create(structure); - readRecord(); checkRType(RecordType::LAYER); - elem->setLayer(_r.data16[0]); readRecord(); checkRType(RecordType::NODETYPE); - elem->setDatatype(_r.data16[0]); readRecord(); - processXY(elem); - - return elem; + processXY(nullptr); } dbGDSSTrans GDSReader::processSTrans() diff --git a/src/odb/src/gdsout/gdsout.cpp b/src/odb/src/gdsout/gdsout.cpp index e4445cbc705..1d8decbfa2b 100644 --- a/src/odb/src/gdsout/gdsout.cpp +++ b/src/odb/src/gdsout/gdsout.cpp @@ -235,10 +235,6 @@ void GDSWriter::writeStruct(dbGDSStructure* str) writeBox(box); } - for (auto node : str->getGDSNodes()) { - writeNode(node); - } - for (auto path : str->getGDSPaths()) { writePath(path); } @@ -459,27 +455,6 @@ void GDSWriter::writeBox(dbGDSBox* box) writeEndel(); } -void GDSWriter::writeNode(dbGDSNode* node) -{ - record_t r; - r.type = RecordType::NODE; - r.dataType = DataType::NO_DATA; - writeRecord(r); - - writeLayer(node->getLayer()); - - record_t r2; - r2.type = RecordType::NODETYPE; - r2.dataType = DataType::INT_2; - r2.data16 = {node->getDatatype()}; - writeRecord(r2); - - writeXY(node->getXY()); - - writePropAttr(node); - writeEndel(); -} - void GDSWriter::writeSTrans(const dbGDSSTrans& strans) { record_t r; diff --git a/src/odb/test/cpp/TestGDSIn.cpp b/src/odb/test/cpp/TestGDSIn.cpp index a2050f345af..55615b5cdd8 100644 --- a/src/odb/test/cpp/TestGDSIn.cpp +++ b/src/odb/test/cpp/TestGDSIn.cpp @@ -36,7 +36,6 @@ BOOST_AUTO_TEST_CASE(reader) BOOST_TEST(str->getGDSBoundarys().size() == 44); BOOST_TEST(str->getGDSBoxs().size() == 0); - BOOST_TEST(str->getGDSNodes().size() == 0); BOOST_TEST(str->getGDSPaths().size() == 2); BOOST_TEST(str->getGDSSRefs().size() == 0); BOOST_TEST(str->getGDSTexts().size() == 8); @@ -105,7 +104,6 @@ BOOST_AUTO_TEST_CASE(writer) BOOST_TEST(str->getGDSBoundarys().size() == 44); BOOST_TEST(str->getGDSBoxs().size() == 0); - BOOST_TEST(str->getGDSNodes().size() == 0); BOOST_TEST(str->getGDSPaths().size() == 2); BOOST_TEST(str->getGDSSRefs().size() == 0); BOOST_TEST(str->getGDSTexts().size() == 8); @@ -163,11 +161,6 @@ BOOST_AUTO_TEST_CASE(edit) box->getPropattr().emplace_back(12, "test"); - dbGDSNode* node = dbGDSNode::create(str1); - node->setLayer(6); - node->setDatatype(7); - node->setXy({{2, 3}, {4, 5}}); - dbGDSSRef* sref = dbGDSSRef::create(str3); sref->set_sName("str1"); sref->setTransform(dbGDSSTrans(false, false, false, 2.0, 90)); @@ -189,7 +182,6 @@ BOOST_AUTO_TEST_CASE(edit) dbGDSStructure* str1_read = lib2->findGDSStructure("str1"); BOOST_TEST(str1_read != nullptr); BOOST_TEST(str1_read->getGDSBoxs().size() == 1); - BOOST_TEST(str1_read->getGDSNodes().size() == 1); dbGDSBox* box_read = *str1_read->getGDSBoxs().begin(); BOOST_TEST(box_read->getLayer() == 3); @@ -199,10 +191,6 @@ BOOST_AUTO_TEST_CASE(edit) BOOST_TEST(box_read->getPropattr()[0].first == 12); BOOST_TEST(box_read->getPropattr()[0].second == "test"); - dbGDSNode* node_read = *str1_read->getGDSNodes().begin(); - BOOST_TEST(node_read->getLayer() == 6); - BOOST_TEST(node_read->getDatatype() == 7); - dbGDSStructure* str3_read = lib2->findGDSStructure("str3"); BOOST_TEST(str3_read != nullptr); BOOST_TEST(str3_read->getGDSSRefs().size() == 1); From 759927c0b2c08ae178dd266cd64bb59a9f9e3e2a Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Wed, 1 Jan 2025 07:20:56 +0000 Subject: [PATCH 02/15] odb: rm unused layer & datatype from dbGDSPath Signed-off-by: Matt Liberty --- src/odb/include/odb/db.h | 8 ---- .../codeGenerator/schema/gds/dbGDSSRef.json | 12 ----- src/odb/src/db/dbGDSSRef.cpp | 44 ------------------- src/odb/src/db/dbGDSSRef.h | 2 - 4 files changed, 66 deletions(-) diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index 4cd77d91fc9..d04c4e6933d 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -7539,14 +7539,6 @@ class dbGDSPath : public dbObject class dbGDSSRef : public dbObject { public: - void setLayer(int16_t layer); - - int16_t getLayer() const; - - void setDatatype(int16_t datatype); - - int16_t getDatatype() const; - void setXy(const std::vector& xy); void getXy(std::vector& tbl) const; diff --git a/src/odb/src/codeGenerator/schema/gds/dbGDSSRef.json b/src/odb/src/codeGenerator/schema/gds/dbGDSSRef.json index b282fc5d953..e894f15f4ef 100644 --- a/src/odb/src/codeGenerator/schema/gds/dbGDSSRef.json +++ b/src/odb/src/codeGenerator/schema/gds/dbGDSSRef.json @@ -2,18 +2,6 @@ "name":"dbGDSSRef", "type":"dbObject", "fields":[ - { - "name":"_layer", - "type":"int16_t", - "default":"0", - "flags":[] - }, - { - "name":"_datatype", - "type":"int16_t", - "default":"0", - "flags":[] - }, { "name":"_xy", "type":"std::vector", diff --git a/src/odb/src/db/dbGDSSRef.cpp b/src/odb/src/db/dbGDSSRef.cpp index d2b748245be..9d1629cfa0e 100644 --- a/src/odb/src/db/dbGDSSRef.cpp +++ b/src/odb/src/db/dbGDSSRef.cpp @@ -44,12 +44,6 @@ template class dbTable<_dbGDSSRef>; bool _dbGDSSRef::operator==(const _dbGDSSRef& rhs) const { - if (_layer != rhs._layer) { - return false; - } - if (_datatype != rhs._datatype) { - return false; - } if (_sName != rhs._sName) { return false; } @@ -67,8 +61,6 @@ void _dbGDSSRef::differences(dbDiff& diff, const _dbGDSSRef& rhs) const { DIFF_BEGIN - DIFF_FIELD(_layer); - DIFF_FIELD(_datatype); DIFF_FIELD(_sName); DIFF_END } @@ -76,8 +68,6 @@ void _dbGDSSRef::differences(dbDiff& diff, void _dbGDSSRef::out(dbDiff& diff, char side, const char* field) const { DIFF_OUT_BEGIN - DIFF_OUT_FIELD(_layer); - DIFF_OUT_FIELD(_datatype); DIFF_OUT_FIELD(_sName); DIFF_END @@ -85,21 +75,15 @@ void _dbGDSSRef::out(dbDiff& diff, char side, const char* field) const _dbGDSSRef::_dbGDSSRef(_dbDatabase* db) { - _layer = 0; - _datatype = 0; } _dbGDSSRef::_dbGDSSRef(_dbDatabase* db, const _dbGDSSRef& r) { - _layer = r._layer; - _datatype = r._datatype; _sName = r._sName; } dbIStream& operator>>(dbIStream& stream, _dbGDSSRef& obj) { - stream >> obj._layer; - stream >> obj._datatype; stream >> obj._xy; stream >> obj._propattr; stream >> obj._sName; @@ -110,8 +94,6 @@ dbIStream& operator>>(dbIStream& stream, _dbGDSSRef& obj) dbOStream& operator<<(dbOStream& stream, const _dbGDSSRef& obj) { - stream << obj._layer; - stream << obj._datatype; stream << obj._xy; stream << obj._propattr; stream << obj._sName; @@ -126,32 +108,6 @@ dbOStream& operator<<(dbOStream& stream, const _dbGDSSRef& obj) // //////////////////////////////////////////////////////////////////// -void dbGDSSRef::setLayer(int16_t layer) -{ - _dbGDSSRef* obj = (_dbGDSSRef*) this; - - obj->_layer = layer; -} - -int16_t dbGDSSRef::getLayer() const -{ - _dbGDSSRef* obj = (_dbGDSSRef*) this; - return obj->_layer; -} - -void dbGDSSRef::setDatatype(int16_t datatype) -{ - _dbGDSSRef* obj = (_dbGDSSRef*) this; - - obj->_datatype = datatype; -} - -int16_t dbGDSSRef::getDatatype() const -{ - _dbGDSSRef* obj = (_dbGDSSRef*) this; - return obj->_datatype; -} - void dbGDSSRef::setXy(const std::vector& xy) { _dbGDSSRef* obj = (_dbGDSSRef*) this; diff --git a/src/odb/src/db/dbGDSSRef.h b/src/odb/src/db/dbGDSSRef.h index 2cbbe36e529..3fea9a33a44 100644 --- a/src/odb/src/db/dbGDSSRef.h +++ b/src/odb/src/db/dbGDSSRef.h @@ -64,8 +64,6 @@ class _dbGDSSRef : public _dbObject // User Code End Methods - int16_t _layer; - int16_t _datatype; std::vector _xy; std::vector> _propattr; std::string _sName; From d3f5d4560b493066eea0967668412c450437c430 Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Wed, 1 Jan 2025 07:30:27 +0000 Subject: [PATCH 03/15] odb: rm unneeded width from dbGDSText Signed-off-by: Matt Liberty --- src/odb/include/odb/db.h | 4 ---- .../codeGenerator/schema/gds/dbGDSText.json | 6 ----- src/odb/src/db/dbGDSText.cpp | 22 ------------------- src/odb/src/db/dbGDSText.h | 1 - src/odb/src/gdsin/gdsin.cpp | 2 +- src/odb/src/gdsout/gdsout.cpp | 8 ------- 6 files changed, 1 insertion(+), 42 deletions(-) diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index d04c4e6933d..aa3ae6f9b53 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -7611,10 +7611,6 @@ class dbGDSText : public dbObject dbGDSTextPres getPresentation() const; - void setWidth(int width); - - int getWidth() const; - void setTransform(dbGDSSTrans transform); dbGDSSTrans getTransform() const; diff --git a/src/odb/src/codeGenerator/schema/gds/dbGDSText.json b/src/odb/src/codeGenerator/schema/gds/dbGDSText.json index f328775dead..6888ecef67d 100644 --- a/src/odb/src/codeGenerator/schema/gds/dbGDSText.json +++ b/src/odb/src/codeGenerator/schema/gds/dbGDSText.json @@ -29,12 +29,6 @@ "type":"dbGDSTextPres", "flags":[] }, - { - "name":"_width", - "type":"int", - "default":"0", - "flags":[] - }, { "name":"_transform", "type":"dbGDSSTrans", diff --git a/src/odb/src/db/dbGDSText.cpp b/src/odb/src/db/dbGDSText.cpp index 307035e90ed..20b16311cd7 100644 --- a/src/odb/src/db/dbGDSText.cpp +++ b/src/odb/src/db/dbGDSText.cpp @@ -50,9 +50,6 @@ bool _dbGDSText::operator==(const _dbGDSText& rhs) const if (_datatype != rhs._datatype) { return false; } - if (_width != rhs._width) { - return false; - } if (_text != rhs._text) { return false; } @@ -72,7 +69,6 @@ void _dbGDSText::differences(dbDiff& diff, DIFF_BEGIN DIFF_FIELD(_layer); DIFF_FIELD(_datatype); - DIFF_FIELD(_width); DIFF_FIELD(_text); DIFF_END } @@ -82,7 +78,6 @@ void _dbGDSText::out(dbDiff& diff, char side, const char* field) const DIFF_OUT_BEGIN DIFF_OUT_FIELD(_layer); DIFF_OUT_FIELD(_datatype); - DIFF_OUT_FIELD(_width); DIFF_OUT_FIELD(_text); DIFF_END @@ -92,14 +87,12 @@ _dbGDSText::_dbGDSText(_dbDatabase* db) { _layer = 0; _datatype = 0; - _width = 0; } _dbGDSText::_dbGDSText(_dbDatabase* db, const _dbGDSText& r) { _layer = r._layer; _datatype = r._datatype; - _width = r._width; _text = r._text; } @@ -110,7 +103,6 @@ dbIStream& operator>>(dbIStream& stream, _dbGDSText& obj) stream >> obj._xy; stream >> obj._propattr; stream >> obj._presentation; - stream >> obj._width; stream >> obj._transform; stream >> obj._text; return stream; @@ -123,7 +115,6 @@ dbOStream& operator<<(dbOStream& stream, const _dbGDSText& obj) stream << obj._xy; stream << obj._propattr; stream << obj._presentation; - stream << obj._width; stream << obj._transform; stream << obj._text; return stream; @@ -187,19 +178,6 @@ dbGDSTextPres dbGDSText::getPresentation() const return obj->_presentation; } -void dbGDSText::setWidth(int width) -{ - _dbGDSText* obj = (_dbGDSText*) this; - - obj->_width = width; -} - -int dbGDSText::getWidth() const -{ - _dbGDSText* obj = (_dbGDSText*) this; - return obj->_width; -} - void dbGDSText::setTransform(dbGDSSTrans transform) { _dbGDSText* obj = (_dbGDSText*) this; diff --git a/src/odb/src/db/dbGDSText.h b/src/odb/src/db/dbGDSText.h index 73d623c9ab3..9413264c649 100644 --- a/src/odb/src/db/dbGDSText.h +++ b/src/odb/src/db/dbGDSText.h @@ -64,7 +64,6 @@ class _dbGDSText : public _dbObject std::vector _xy; std::vector> _propattr; dbGDSTextPres _presentation; - int _width; dbGDSSTrans _transform; std::string _text; }; diff --git a/src/odb/src/gdsin/gdsin.cpp b/src/odb/src/gdsin/gdsin.cpp index b836daa29f8..8e7bc154a83 100644 --- a/src/odb/src/gdsin/gdsin.cpp +++ b/src/odb/src/gdsin/gdsin.cpp @@ -417,7 +417,7 @@ dbGDSText* GDSReader::processText(dbGDSStructure* structure) } if (_r.type == RecordType::WIDTH) { - text->setWidth(_r.data32[0]); + // ignored readRecord(); } diff --git a/src/odb/src/gdsout/gdsout.cpp b/src/odb/src/gdsout/gdsout.cpp index 1d8decbfa2b..3efea8132e9 100644 --- a/src/odb/src/gdsout/gdsout.cpp +++ b/src/odb/src/gdsout/gdsout.cpp @@ -410,14 +410,6 @@ void GDSWriter::writeText(dbGDSText* text) writeTextPres(text->getPresentation()); - if (text->getWidth() != 0) { - record_t r4; - r4.type = RecordType::WIDTH; - r4.dataType = DataType::INT_4; - r4.data32 = {text->getWidth()}; - writeRecord(r4); - } - if (!text->getTransform().identity()) { writeSTrans(text->getTransform()); } From d4eb8a5e41e052bfc93e68984866291a60a0bb45 Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Wed, 1 Jan 2025 07:53:06 +0000 Subject: [PATCH 04/15] odb: change dbGDSBox xy list to a rect More efficient and natural Signed-off-by: Matt Liberty --- src/odb/include/odb/db.h | 5 ++-- src/odb/include/odb/gdsin.h | 6 ++--- .../codeGenerator/schema/gds/dbGDSBox.json | 4 ++-- src/odb/src/db/dbGDSBox.cpp | 24 +++++++++---------- src/odb/src/db/dbGDSBox.h | 2 +- src/odb/src/gdsin/gdsin.cpp | 22 ++++++++--------- src/odb/src/gdsout/gdsout.cpp | 4 +++- src/odb/test/cpp/TestGDSIn.cpp | 3 +-- 8 files changed, 33 insertions(+), 37 deletions(-) diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index aa3ae6f9b53..f30f505f205 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -7491,12 +7491,11 @@ class dbGDSBox : public dbObject int16_t getDatatype() const; - void setXy(const std::vector& xy); + void setBounds(Rect bounds); - void getXy(std::vector& tbl) const; + Rect getBounds() const; // User Code Begin dbGDSBox - const std::vector& getXY(); std::vector>& getPropattr(); static dbGDSBox* create(dbGDSStructure* structure); diff --git a/src/odb/include/odb/gdsin.h b/src/odb/include/odb/gdsin.h index 573a523db7d..e909406d286 100644 --- a/src/odb/include/odb/gdsin.h +++ b/src/odb/include/odb/gdsin.h @@ -142,11 +142,9 @@ class GDSReader /** * Parses the XY data of a GDS Element * - * @param elem The GDS Element to add the XY data to - * @return true if the XY data was successfully read + * @return The XY data */ - template - bool processXY(T* elem); + std::vector processXY(); /** * Parses a GDS STrans from the GDS file diff --git a/src/odb/src/codeGenerator/schema/gds/dbGDSBox.json b/src/odb/src/codeGenerator/schema/gds/dbGDSBox.json index 6673888c2c3..7cb6e00d783 100644 --- a/src/odb/src/codeGenerator/schema/gds/dbGDSBox.json +++ b/src/odb/src/codeGenerator/schema/gds/dbGDSBox.json @@ -15,8 +15,8 @@ "flags":[] }, { - "name":"_xy", - "type":"std::vector", + "name":"_bounds", + "type":"Rect", "flags":["no-template"] }, { diff --git a/src/odb/src/db/dbGDSBox.cpp b/src/odb/src/db/dbGDSBox.cpp index 1eb0b67ba04..99edf5d5d31 100644 --- a/src/odb/src/db/dbGDSBox.cpp +++ b/src/odb/src/db/dbGDSBox.cpp @@ -50,6 +50,9 @@ bool _dbGDSBox::operator==(const _dbGDSBox& rhs) const if (_datatype != rhs._datatype) { return false; } + if (_bounds != rhs._bounds) { + return false; + } return true; } @@ -66,6 +69,7 @@ void _dbGDSBox::differences(dbDiff& diff, DIFF_BEGIN DIFF_FIELD(_layer); DIFF_FIELD(_datatype); + DIFF_FIELD(_bounds); DIFF_END } @@ -74,6 +78,7 @@ void _dbGDSBox::out(dbDiff& diff, char side, const char* field) const DIFF_OUT_BEGIN DIFF_OUT_FIELD(_layer); DIFF_OUT_FIELD(_datatype); + DIFF_OUT_FIELD(_bounds); DIFF_END } @@ -88,13 +93,14 @@ _dbGDSBox::_dbGDSBox(_dbDatabase* db, const _dbGDSBox& r) { _layer = r._layer; _datatype = r._datatype; + _bounds = r._bounds; } dbIStream& operator>>(dbIStream& stream, _dbGDSBox& obj) { stream >> obj._layer; stream >> obj._datatype; - stream >> obj._xy; + stream >> obj._bounds; stream >> obj._propattr; return stream; } @@ -103,7 +109,7 @@ dbOStream& operator<<(dbOStream& stream, const _dbGDSBox& obj) { stream << obj._layer; stream << obj._datatype; - stream << obj._xy; + stream << obj._bounds; stream << obj._propattr; return stream; } @@ -140,17 +146,17 @@ int16_t dbGDSBox::getDatatype() const return obj->_datatype; } -void dbGDSBox::setXy(const std::vector& xy) +void dbGDSBox::setBounds(Rect bounds) { _dbGDSBox* obj = (_dbGDSBox*) this; - obj->_xy = xy; + obj->_bounds = bounds; } -void dbGDSBox::getXy(std::vector& tbl) const +Rect dbGDSBox::getBounds() const { _dbGDSBox* obj = (_dbGDSBox*) this; - tbl = obj->_xy; + return obj->_bounds; } // User Code Begin dbGDSBoxPublicMethods @@ -160,12 +166,6 @@ std::vector>& dbGDSBox::getPropattr() return obj->_propattr; } -const std::vector& dbGDSBox::getXY() -{ - auto obj = (_dbGDSBox*) this; - return obj->_xy; -} - dbGDSBox* dbGDSBox::create(dbGDSStructure* structure) { auto* obj = (_dbGDSStructure*) structure; diff --git a/src/odb/src/db/dbGDSBox.h b/src/odb/src/db/dbGDSBox.h index 12a12a9396c..ad1b4f75142 100644 --- a/src/odb/src/db/dbGDSBox.h +++ b/src/odb/src/db/dbGDSBox.h @@ -59,7 +59,7 @@ class _dbGDSBox : public _dbObject int16_t _layer; int16_t _datatype; - std::vector _xy; + Rect _bounds; std::vector> _propattr; }; dbIStream& operator>>(dbIStream& stream, _dbGDSBox& obj); diff --git a/src/odb/src/gdsin/gdsin.cpp b/src/odb/src/gdsin/gdsin.cpp index 8e7bc154a83..d5125d7c426 100644 --- a/src/odb/src/gdsin/gdsin.cpp +++ b/src/odb/src/gdsin/gdsin.cpp @@ -232,8 +232,7 @@ bool GDSReader::processStruct() return false; } -template -bool GDSReader::processXY(T* elem) +std::vector GDSReader::processXY() { checkRType(RecordType::XY); if (_r.data32.size() % 2 != 0) { @@ -244,10 +243,7 @@ bool GDSReader::processXY(T* elem) for (int i = 0; i < _r.data32.size(); i += 2) { xy.emplace_back(_r.data32[i], _r.data32[i + 1]); } - if (elem) { - elem->setXy(xy); - } - return true; + return xy; } template @@ -346,7 +342,7 @@ dbGDSPath* GDSReader::processPath(dbGDSStructure* structure) path->setWidth(0); } - processXY(path); + path->setXy(processXY()); return path; } @@ -364,7 +360,7 @@ dbGDSBoundary* GDSReader::processBoundary(dbGDSStructure* structure) bdy->setDatatype(_r.data16[0]); readRecord(); - processXY(bdy); + bdy->setXy(processXY()); return bdy; } @@ -389,7 +385,7 @@ dbGDSSRef* GDSReader::processSRef(dbGDSStructure* structure) sref->set_colRow({1, 1}); } - processXY(sref); + sref->setXy(processXY()); return sref; } @@ -425,7 +421,7 @@ dbGDSText* GDSReader::processText(dbGDSStructure* structure) text->setTransform(processSTrans()); } - processXY(text); + text->setXy(processXY()); readRecord(); checkRType(RecordType::STRING); @@ -447,7 +443,9 @@ dbGDSBox* GDSReader::processBox(dbGDSStructure* structure) box->setDatatype(_r.data16[0]); readRecord(); - processXY(box); + std::vector points = processXY(); + Rect bounds(points[0], points[2]); + box->setBounds(bounds); return box; } @@ -461,7 +459,7 @@ void GDSReader::processNode() checkRType(RecordType::NODETYPE); readRecord(); - processXY(nullptr); + processXY(); } dbGDSSTrans GDSReader::processSTrans() diff --git a/src/odb/src/gdsout/gdsout.cpp b/src/odb/src/gdsout/gdsout.cpp index 3efea8132e9..a0f3fcf3eb1 100644 --- a/src/odb/src/gdsout/gdsout.cpp +++ b/src/odb/src/gdsout/gdsout.cpp @@ -441,7 +441,9 @@ void GDSWriter::writeBox(dbGDSBox* box) r2.data16 = {box->getDatatype()}; writeRecord(r2); - writeXY(box->getXY()); + const Rect b = box->getBounds(); + std::vector points({b.ll(), b.lr(), b.ur(), b.ul(), b.ll()}); + writeXY(points); writePropAttr(box); writeEndel(); diff --git a/src/odb/test/cpp/TestGDSIn.cpp b/src/odb/test/cpp/TestGDSIn.cpp index 55615b5cdd8..774b2b97f0c 100644 --- a/src/odb/test/cpp/TestGDSIn.cpp +++ b/src/odb/test/cpp/TestGDSIn.cpp @@ -157,7 +157,7 @@ BOOST_AUTO_TEST_CASE(edit) dbGDSBox* box = dbGDSBox::create(str1); box->setLayer(3); box->setDatatype(4); - box->setXy({{0, 0}, {0, 1000}, {1000, 1000}, {1000, 0}}); + box->setBounds({0, 0, 1000, 1000}); box->getPropattr().emplace_back(12, "test"); @@ -186,7 +186,6 @@ BOOST_AUTO_TEST_CASE(edit) dbGDSBox* box_read = *str1_read->getGDSBoxs().begin(); BOOST_TEST(box_read->getLayer() == 3); BOOST_TEST(box_read->getDatatype() == 4); - BOOST_TEST(box_read->getXY().size() == 4); BOOST_TEST(box_read->getPropattr().size() == 1); BOOST_TEST(box_read->getPropattr()[0].first == 12); BOOST_TEST(box_read->getPropattr()[0].second == "test"); From d79ea4c0a20f0ccfb736235ad5942bcd773b2351 Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Wed, 1 Jan 2025 08:07:48 +0000 Subject: [PATCH 05/15] odb: change dbGDSText field xy (Point vector) to origin (one Point) More efficient and natural Signed-off-by: Matt Liberty --- src/odb/include/odb/db.h | 5 ++-- .../codeGenerator/schema/gds/dbGDSText.json | 5 ++-- src/odb/src/db/dbGDSText.cpp | 24 +++++++++---------- src/odb/src/db/dbGDSText.h | 2 +- src/odb/src/gdsin/gdsin.cpp | 2 +- src/odb/src/gdsout/gdsout.cpp | 3 ++- 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index f30f505f205..5e500ce6470 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -7602,9 +7602,9 @@ class dbGDSText : public dbObject int16_t getDatatype() const; - void setXy(const std::vector& xy); + void setOrigin(Point origin); - void getXy(std::vector& tbl) const; + Point getOrigin() const; void setPresentation(dbGDSTextPres presentation); @@ -7619,7 +7619,6 @@ class dbGDSText : public dbObject std::string getText() const; // User Code Begin dbGDSText - const std::vector& getXY(); std::vector>& getPropattr(); static dbGDSText* create(dbGDSStructure* structure); diff --git a/src/odb/src/codeGenerator/schema/gds/dbGDSText.json b/src/odb/src/codeGenerator/schema/gds/dbGDSText.json index 6888ecef67d..b1fb32f0d8e 100644 --- a/src/odb/src/codeGenerator/schema/gds/dbGDSText.json +++ b/src/odb/src/codeGenerator/schema/gds/dbGDSText.json @@ -15,9 +15,8 @@ "flags":[] }, { - "name":"_xy", - "type":"std::vector", - "flags":["no-template"] + "name":"_origin", + "type":"Point" }, { "name":"_propattr", diff --git a/src/odb/src/db/dbGDSText.cpp b/src/odb/src/db/dbGDSText.cpp index 20b16311cd7..05db18bf8d4 100644 --- a/src/odb/src/db/dbGDSText.cpp +++ b/src/odb/src/db/dbGDSText.cpp @@ -50,6 +50,9 @@ bool _dbGDSText::operator==(const _dbGDSText& rhs) const if (_datatype != rhs._datatype) { return false; } + if (_origin != rhs._origin) { + return false; + } if (_text != rhs._text) { return false; } @@ -69,6 +72,7 @@ void _dbGDSText::differences(dbDiff& diff, DIFF_BEGIN DIFF_FIELD(_layer); DIFF_FIELD(_datatype); + DIFF_FIELD(_origin); DIFF_FIELD(_text); DIFF_END } @@ -78,6 +82,7 @@ void _dbGDSText::out(dbDiff& diff, char side, const char* field) const DIFF_OUT_BEGIN DIFF_OUT_FIELD(_layer); DIFF_OUT_FIELD(_datatype); + DIFF_OUT_FIELD(_origin); DIFF_OUT_FIELD(_text); DIFF_END @@ -93,6 +98,7 @@ _dbGDSText::_dbGDSText(_dbDatabase* db, const _dbGDSText& r) { _layer = r._layer; _datatype = r._datatype; + _origin = r._origin; _text = r._text; } @@ -100,7 +106,7 @@ dbIStream& operator>>(dbIStream& stream, _dbGDSText& obj) { stream >> obj._layer; stream >> obj._datatype; - stream >> obj._xy; + stream >> obj._origin; stream >> obj._propattr; stream >> obj._presentation; stream >> obj._transform; @@ -112,7 +118,7 @@ dbOStream& operator<<(dbOStream& stream, const _dbGDSText& obj) { stream << obj._layer; stream << obj._datatype; - stream << obj._xy; + stream << obj._origin; stream << obj._propattr; stream << obj._presentation; stream << obj._transform; @@ -152,17 +158,17 @@ int16_t dbGDSText::getDatatype() const return obj->_datatype; } -void dbGDSText::setXy(const std::vector& xy) +void dbGDSText::setOrigin(Point origin) { _dbGDSText* obj = (_dbGDSText*) this; - obj->_xy = xy; + obj->_origin = origin; } -void dbGDSText::getXy(std::vector& tbl) const +Point dbGDSText::getOrigin() const { _dbGDSText* obj = (_dbGDSText*) this; - tbl = obj->_xy; + return obj->_origin; } void dbGDSText::setPresentation(dbGDSTextPres presentation) @@ -211,12 +217,6 @@ std::vector>& dbGDSText::getPropattr() return obj->_propattr; } -const std::vector& dbGDSText::getXY() -{ - auto obj = (_dbGDSText*) this; - return obj->_xy; -} - dbGDSText* dbGDSText::create(dbGDSStructure* structure) { auto* obj = (_dbGDSStructure*) structure; diff --git a/src/odb/src/db/dbGDSText.h b/src/odb/src/db/dbGDSText.h index 9413264c649..5c67ac29320 100644 --- a/src/odb/src/db/dbGDSText.h +++ b/src/odb/src/db/dbGDSText.h @@ -61,7 +61,7 @@ class _dbGDSText : public _dbObject int16_t _layer; int16_t _datatype; - std::vector _xy; + Point _origin; std::vector> _propattr; dbGDSTextPres _presentation; dbGDSSTrans _transform; diff --git a/src/odb/src/gdsin/gdsin.cpp b/src/odb/src/gdsin/gdsin.cpp index d5125d7c426..aaffedfa724 100644 --- a/src/odb/src/gdsin/gdsin.cpp +++ b/src/odb/src/gdsin/gdsin.cpp @@ -421,7 +421,7 @@ dbGDSText* GDSReader::processText(dbGDSStructure* structure) text->setTransform(processSTrans()); } - text->setXy(processXY()); + text->setOrigin(processXY().at(0)); readRecord(); checkRType(RecordType::STRING); diff --git a/src/odb/src/gdsout/gdsout.cpp b/src/odb/src/gdsout/gdsout.cpp index a0f3fcf3eb1..7523d134c11 100644 --- a/src/odb/src/gdsout/gdsout.cpp +++ b/src/odb/src/gdsout/gdsout.cpp @@ -414,7 +414,8 @@ void GDSWriter::writeText(dbGDSText* text) writeSTrans(text->getTransform()); } - writeXY(text->getXY()); + std::vector origin({text->getOrigin()}); + writeXY(origin); record_t r5; r5.type = RecordType::STRING; From 978e115f83651bae2bf65da4ff31a5264624b8c3 Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Wed, 1 Jan 2025 20:16:48 +0000 Subject: [PATCH 06/15] odb: in GDSReader::processBox use the bbox instead of relying on ordering Signed-off-by: Matt Liberty --- src/odb/src/gdsin/gdsin.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/odb/src/gdsin/gdsin.cpp b/src/odb/src/gdsin/gdsin.cpp index aaffedfa724..6be574ef210 100644 --- a/src/odb/src/gdsin/gdsin.cpp +++ b/src/odb/src/gdsin/gdsin.cpp @@ -444,7 +444,11 @@ dbGDSBox* GDSReader::processBox(dbGDSStructure* structure) readRecord(); std::vector points = processXY(); - Rect bounds(points[0], points[2]); + Rect bounds; + bounds.mergeInit(); + for (const Point& point : points) { + bounds.merge(point); + } box->setBounds(bounds); return box; From 18e698071d3274c87f732dc80720f5f6951531ed Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Thu, 2 Jan 2025 02:36:46 +0000 Subject: [PATCH 07/15] odb: split dbGDSARef from dbGDSSRef Preparation to store each more efficiently. Signed-off-by: Matt Liberty --- src/odb/include/odb/db.h | 34 +++ src/odb/include/odb/dbCompare.h | 9 + src/odb/include/odb/dbObject.h | 1 + src/odb/include/odb/gdsin.h | 5 +- src/odb/include/odb/gdsout.h | 1 + src/odb/src/codeGenerator/schema.json | 6 + .../codeGenerator/schema/gds/dbGDSARef.json | 36 ++++ src/odb/src/db/CMakeLists.txt | 1 + src/odb/src/db/dbGDSARef.cpp | 203 ++++++++++++++++++ src/odb/src/db/dbGDSARef.h | 76 +++++++ src/odb/src/db/dbGDSStructure.cpp | 20 ++ src/odb/src/db/dbGDSStructure.h | 3 + src/odb/src/db/dbObject.cpp | 1 + src/odb/src/gdsin/gdsin.cpp | 44 +++- src/odb/src/gdsout/gdsout.cpp | 39 +++- 15 files changed, 465 insertions(+), 14 deletions(-) create mode 100644 src/odb/src/codeGenerator/schema/gds/dbGDSARef.json create mode 100644 src/odb/src/db/dbGDSARef.cpp create mode 100644 src/odb/src/db/dbGDSARef.h diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index 5e500ce6470..b561c04f3fc 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -132,6 +132,7 @@ class dbAccessPoint; class dbBusPort; class dbDft; class dbGCellGrid; +class dbGDSARef; class dbGDSBoundary; class dbGDSBox; class dbGDSPath; @@ -7456,6 +7457,37 @@ class dbGCellGrid : public dbObject // User Code End dbGCellGrid }; +class dbGDSARef : public dbObject +{ + public: + void setXy(const std::vector& xy); + + void getXy(std::vector& tbl) const; + + void set_sName(const std::string& sName); + + std::string get_sName() const; + + void setTransform(dbGDSSTrans transform); + + dbGDSSTrans getTransform() const; + + void set_colRow(const std::pair& colRow); + + std::pair get_colRow() const; + + // User Code Begin dbGDSARef + const std::vector& getXY(); + std::vector>& getPropattr(); + + dbGDSStructure* getStructure() const; + void setStructure(dbGDSStructure* structure) const; + + static dbGDSARef* create(dbGDSStructure* structure); + static void destroy(dbGDSARef* sref); + // User Code End dbGDSARef +}; + class dbGDSBoundary : public dbObject { public: @@ -7579,6 +7611,8 @@ class dbGDSStructure : public dbObject dbSet getGDSSRefs() const; + dbSet getGDSARefs() const; + dbSet getGDSTexts() const; // User Code Begin dbGDSStructure diff --git a/src/odb/include/odb/dbCompare.h b/src/odb/include/odb/dbCompare.h index a9cfe7faadd..d088968dcc6 100644 --- a/src/odb/include/odb/dbCompare.h +++ b/src/odb/include/odb/dbCompare.h @@ -526,6 +526,15 @@ struct less } }; +template <> +struct less +{ + bool operator()(const odb::dbGDSARef* lhs, const odb::dbGDSARef* rhs) const + { + return odb::compare_by_id(lhs, rhs); + } +}; + template <> struct less { diff --git a/src/odb/include/odb/dbObject.h b/src/odb/include/odb/dbObject.h index a3089e6df74..3cdaa0c8879 100644 --- a/src/odb/include/odb/dbObject.h +++ b/src/odb/include/odb/dbObject.h @@ -91,6 +91,7 @@ enum dbObjectType dbBusPortObj, dbDftObj, dbGCellGridObj, + dbGDSARefObj, dbGDSBoundaryObj, dbGDSBoxObj, dbGDSPathObj, diff --git a/src/odb/include/odb/gdsin.h b/src/odb/include/odb/gdsin.h index e909406d286..bfc4917a90c 100644 --- a/src/odb/include/odb/gdsin.h +++ b/src/odb/include/odb/gdsin.h @@ -127,6 +127,7 @@ class GDSReader dbGDSBoundary* processBoundary(dbGDSStructure* structure); dbGDSPath* processPath(dbGDSStructure* structure); dbGDSSRef* processSRef(dbGDSStructure* structure); + dbGDSARef* processARef(dbGDSStructure* structure); dbGDSText* processText(dbGDSStructure* structure); dbGDSBox* processBox(dbGDSStructure* structure); void processNode(); @@ -160,9 +161,9 @@ class GDSReader /** * This function is called after the entire GDS file has been read to bind all - * SRefs with the pointers to the referenced structures. + * SRefs and ARefs with the pointers to the referenced structures. */ - void bindAllSRefs(); + void bindAllRefs(); /** Current filestream */ std::ifstream _file; diff --git a/src/odb/include/odb/gdsout.h b/src/odb/include/odb/gdsout.h index f15935afd7c..a2d15ae1d73 100644 --- a/src/odb/include/odb/gdsout.h +++ b/src/odb/include/odb/gdsout.h @@ -110,6 +110,7 @@ class GDSWriter void writeBoundary(dbGDSBoundary* bnd); void writePath(dbGDSPath* path); void writeSRef(dbGDSSRef* sref); + void writeARef(dbGDSARef* aref); void writeText(dbGDSText* text); void writeBox(dbGDSBox* box); diff --git a/src/odb/src/codeGenerator/schema.json b/src/odb/src/codeGenerator/schema.json index 278de3d2647..f05f07ad362 100644 --- a/src/odb/src/codeGenerator/schema.json +++ b/src/odb/src/codeGenerator/schema.json @@ -336,6 +336,12 @@ "type": "1_n", "tbl_name": "srefs_" }, + { + "first": "dbGDSStructure", + "second": "dbGDSARef", + "type": "1_n", + "tbl_name": "arefs_" + }, { "first": "dbGDSStructure", "second": "dbGDSText", diff --git a/src/odb/src/codeGenerator/schema/gds/dbGDSARef.json b/src/odb/src/codeGenerator/schema/gds/dbGDSARef.json new file mode 100644 index 00000000000..b93a693bf95 --- /dev/null +++ b/src/odb/src/codeGenerator/schema/gds/dbGDSARef.json @@ -0,0 +1,36 @@ +{ + "name":"dbGDSARef", + "type":"dbObject", + "fields":[ + { + "name":"_xy", + "type":"std::vector", + "flags":["no-template"] + }, + { + "name":"_propattr", + "type":"std::vector>", + "flags":["no-template", "no-get", "no-set"] + }, + { + "name":"_sName", + "type":"std::string", + "flags":[] + }, + { + "name":"_transform", + "type":"dbGDSSTrans", + "flags":[] + }, + { + "name":"_colRow", + "type":"std::pair", + "flags":["no-template"] + } + ], + "h_includes": [ + "dbGDSStructure.h" + ], + "cpp_includes": ["odb/dbTypes.h"] + } + diff --git a/src/odb/src/db/CMakeLists.txt b/src/odb/src/db/CMakeLists.txt index 2c2d8639149..6e85fd816b2 100644 --- a/src/odb/src/db/CMakeLists.txt +++ b/src/odb/src/db/CMakeLists.txt @@ -91,6 +91,7 @@ add_library(db dbBusPort.cpp dbDft.cpp dbGCellGrid.cpp + dbGDSARef.cpp dbGDSBoundary.cpp dbGDSBox.cpp dbGDSPath.cpp diff --git a/src/odb/src/db/dbGDSARef.cpp b/src/odb/src/db/dbGDSARef.cpp new file mode 100644 index 00000000000..9c0e85705ba --- /dev/null +++ b/src/odb/src/db/dbGDSARef.cpp @@ -0,0 +1,203 @@ +/////////////////////////////////////////////////////////////////////////////// +// BSD 3-Clause License +// +// Copyright (c) 2022, The Regents of the University of California +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +// Generator Code Begin Cpp +#include "dbGDSARef.h" + +#include "dbDatabase.h" +#include "dbDiff.hpp" +#include "dbTable.h" +#include "dbTable.hpp" +#include "odb/db.h" +#include "odb/dbTypes.h" +namespace odb { +template class dbTable<_dbGDSARef>; + +bool _dbGDSARef::operator==(const _dbGDSARef& rhs) const +{ + if (_sName != rhs._sName) { + return false; + } + + return true; +} + +bool _dbGDSARef::operator<(const _dbGDSARef& rhs) const +{ + return true; +} + +void _dbGDSARef::differences(dbDiff& diff, + const char* field, + const _dbGDSARef& rhs) const +{ + DIFF_BEGIN + DIFF_FIELD(_sName); + DIFF_END +} + +void _dbGDSARef::out(dbDiff& diff, char side, const char* field) const +{ + DIFF_OUT_BEGIN + DIFF_OUT_FIELD(_sName); + + DIFF_END +} + +_dbGDSARef::_dbGDSARef(_dbDatabase* db) +{ +} + +_dbGDSARef::_dbGDSARef(_dbDatabase* db, const _dbGDSARef& r) +{ + _sName = r._sName; +} + +dbIStream& operator>>(dbIStream& stream, _dbGDSARef& obj) +{ + stream >> obj._xy; + stream >> obj._propattr; + stream >> obj._sName; + stream >> obj._transform; + stream >> obj._colRow; + return stream; +} + +dbOStream& operator<<(dbOStream& stream, const _dbGDSARef& obj) +{ + stream << obj._xy; + stream << obj._propattr; + stream << obj._sName; + stream << obj._transform; + stream << obj._colRow; + return stream; +} + +//////////////////////////////////////////////////////////////////// +// +// dbGDSARef - Methods +// +//////////////////////////////////////////////////////////////////// + +void dbGDSARef::setXy(const std::vector& xy) +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + + obj->_xy = xy; +} + +void dbGDSARef::getXy(std::vector& tbl) const +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + tbl = obj->_xy; +} + +void dbGDSARef::set_sName(const std::string& sName) +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + + obj->_sName = sName; +} + +std::string dbGDSARef::get_sName() const +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + return obj->_sName; +} + +void dbGDSARef::setTransform(dbGDSSTrans transform) +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + + obj->_transform = transform; +} + +dbGDSSTrans dbGDSARef::getTransform() const +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + return obj->_transform; +} + +void dbGDSARef::set_colRow(const std::pair& colRow) +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + + obj->_colRow = colRow; +} + +std::pair dbGDSARef::get_colRow() const +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + return obj->_colRow; +} + +// User Code Begin dbGDSARefPublicMethods + +std::vector>& dbGDSARef::getPropattr() +{ + auto* obj = (_dbGDSARef*) this; + return obj->_propattr; +} + +const std::vector& dbGDSARef::getXY() +{ + auto obj = (_dbGDSARef*) this; + return obj->_xy; +} + +dbGDSARef* dbGDSARef::create(dbGDSStructure* structure) +{ + auto* obj = (_dbGDSStructure*) structure; + return (dbGDSARef*) obj->arefs_->create(); +} + +void dbGDSARef::destroy(dbGDSARef* aref) +{ + auto* obj = (_dbGDSARef*) aref; + auto* structure = (_dbGDSStructure*) obj->getOwner(); + structure->arefs_->destroy(obj); +} + +dbGDSStructure* dbGDSARef::getStructure() const +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + return obj->_stucture; +} + +void dbGDSARef::setStructure(dbGDSStructure* structure) const +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + obj->_stucture = structure; +} +// User Code End dbGDSARefPublicMethods +} // namespace odb + // Generator Code End Cpp diff --git a/src/odb/src/db/dbGDSARef.h b/src/odb/src/db/dbGDSARef.h new file mode 100644 index 00000000000..f89466d9e34 --- /dev/null +++ b/src/odb/src/db/dbGDSARef.h @@ -0,0 +1,76 @@ +/////////////////////////////////////////////////////////////////////////////// +// BSD 3-Clause License +// +// Copyright (c) 2022, The Regents of the University of California +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +// Generator Code Begin Header +#pragma once + +#include "dbCore.h" +#include "dbGDSStructure.h" +#include "odb/odb.h" + +namespace odb { +class dbIStream; +class dbOStream; +class dbDiff; +class _dbDatabase; + +class _dbGDSARef : public _dbObject +{ + public: + _dbGDSARef(_dbDatabase*, const _dbGDSARef& r); + _dbGDSARef(_dbDatabase*); + + ~_dbGDSARef() = default; + + bool operator==(const _dbGDSARef& rhs) const; + bool operator!=(const _dbGDSARef& rhs) const { return !operator==(rhs); } + bool operator<(const _dbGDSARef& rhs) const; + void differences(dbDiff& diff, + const char* field, + const _dbGDSARef& rhs) const; + void out(dbDiff& diff, char side, const char* field) const; + // User Code Begin Methods + + dbGDSStructure* _stucture = nullptr; + + // User Code End Methods + + std::vector _xy; + std::vector> _propattr; + std::string _sName; + dbGDSSTrans _transform; + std::pair _colRow; +}; +dbIStream& operator>>(dbIStream& stream, _dbGDSARef& obj); +dbOStream& operator<<(dbOStream& stream, const _dbGDSARef& obj); +} // namespace odb + // Generator Code End Header diff --git a/src/odb/src/db/dbGDSStructure.cpp b/src/odb/src/db/dbGDSStructure.cpp index 64e66376009..41a54969abf 100644 --- a/src/odb/src/db/dbGDSStructure.cpp +++ b/src/odb/src/db/dbGDSStructure.cpp @@ -35,6 +35,7 @@ #include "dbDatabase.h" #include "dbDiff.hpp" +#include "dbGDSARef.h" #include "dbGDSBoundary.h" #include "dbGDSBox.h" #include "dbGDSLib.h" @@ -70,6 +71,9 @@ bool _dbGDSStructure::operator==(const _dbGDSStructure& rhs) const if (*srefs_ != *rhs.srefs_) { return false; } + if (*arefs_ != *rhs.arefs_) { + return false; + } if (*texts_ != *rhs.texts_) { return false; } @@ -93,6 +97,7 @@ void _dbGDSStructure::differences(dbDiff& diff, DIFF_TABLE(boxes_); DIFF_TABLE(paths_); DIFF_TABLE(srefs_); + DIFF_TABLE(arefs_); DIFF_TABLE(texts_); DIFF_END } @@ -106,6 +111,7 @@ void _dbGDSStructure::out(dbDiff& diff, char side, const char* field) const DIFF_OUT_TABLE(boxes_); DIFF_OUT_TABLE(paths_); DIFF_OUT_TABLE(srefs_); + DIFF_OUT_TABLE(arefs_); DIFF_OUT_TABLE(texts_); DIFF_END @@ -125,6 +131,8 @@ _dbGDSStructure::_dbGDSStructure(_dbDatabase* db) db, this, (GetObjTbl_t) &_dbGDSStructure::getObjectTable, dbGDSPathObj); srefs_ = new dbTable<_dbGDSSRef>( db, this, (GetObjTbl_t) &_dbGDSStructure::getObjectTable, dbGDSSRefObj); + arefs_ = new dbTable<_dbGDSARef>( + db, this, (GetObjTbl_t) &_dbGDSStructure::getObjectTable, dbGDSARefObj); texts_ = new dbTable<_dbGDSText>( db, this, (GetObjTbl_t) &_dbGDSStructure::getObjectTable, dbGDSTextObj); } @@ -137,6 +145,7 @@ _dbGDSStructure::_dbGDSStructure(_dbDatabase* db, const _dbGDSStructure& r) boxes_ = new dbTable<_dbGDSBox>(db, this, *r.boxes_); paths_ = new dbTable<_dbGDSPath>(db, this, *r.paths_); srefs_ = new dbTable<_dbGDSSRef>(db, this, *r.srefs_); + arefs_ = new dbTable<_dbGDSARef>(db, this, *r.arefs_); texts_ = new dbTable<_dbGDSText>(db, this, *r.texts_); } @@ -148,6 +157,7 @@ dbIStream& operator>>(dbIStream& stream, _dbGDSStructure& obj) stream >> *obj.boxes_; stream >> *obj.paths_; stream >> *obj.srefs_; + stream >> *obj.arefs_; stream >> *obj.texts_; return stream; } @@ -160,6 +170,7 @@ dbOStream& operator<<(dbOStream& stream, const _dbGDSStructure& obj) stream << *obj.boxes_; stream << *obj.paths_; stream << *obj.srefs_; + stream << *obj.arefs_; stream << *obj.texts_; return stream; } @@ -175,6 +186,8 @@ dbObjectTable* _dbGDSStructure::getObjectTable(dbObjectType type) return paths_; case dbGDSSRefObj: return srefs_; + case dbGDSARefObj: + return arefs_; case dbGDSTextObj: return texts_; default: @@ -192,6 +205,7 @@ _dbGDSStructure::~_dbGDSStructure() delete boxes_; delete paths_; delete srefs_; + delete arefs_; delete texts_; } @@ -231,6 +245,12 @@ dbSet dbGDSStructure::getGDSSRefs() const return dbSet(obj, obj->srefs_); } +dbSet dbGDSStructure::getGDSARefs() const +{ + _dbGDSStructure* obj = (_dbGDSStructure*) this; + return dbSet(obj, obj->arefs_); +} + dbSet dbGDSStructure::getGDSTexts() const { _dbGDSStructure* obj = (_dbGDSStructure*) this; diff --git a/src/odb/src/db/dbGDSStructure.h b/src/odb/src/db/dbGDSStructure.h index b3345826d8e..0348b00c17a 100644 --- a/src/odb/src/db/dbGDSStructure.h +++ b/src/odb/src/db/dbGDSStructure.h @@ -50,6 +50,7 @@ class dbTable; class _dbGDSBox; class _dbGDSPath; class _dbGDSSRef; +class _dbGDSARef; class _dbGDSText; class _dbGDSStructure : public _dbObject @@ -80,6 +81,8 @@ class _dbGDSStructure : public _dbObject dbTable<_dbGDSSRef>* srefs_; + dbTable<_dbGDSARef>* arefs_; + dbTable<_dbGDSText>* texts_; }; dbIStream& operator>>(dbIStream& stream, _dbGDSStructure& obj); diff --git a/src/odb/src/db/dbObject.cpp b/src/odb/src/db/dbObject.cpp index a9218fe46d5..87e34990437 100644 --- a/src/odb/src/db/dbObject.cpp +++ b/src/odb/src/db/dbObject.cpp @@ -95,6 +95,7 @@ static const char* name_tbl[] = {"dbDatabase", "dbBusPort", "dbDft", "dbGCellGrid", + "dbGDSARef", "dbGDSBoundary", "dbGDSBox", "dbGDSPath", diff --git a/src/odb/src/gdsin/gdsin.cpp b/src/odb/src/gdsin/gdsin.cpp index 6be574ef210..e6f14db637d 100644 --- a/src/odb/src/gdsin/gdsin.cpp +++ b/src/odb/src/gdsin/gdsin.cpp @@ -58,7 +58,7 @@ dbGDSLib* GDSReader::read_gds(const std::string& filename, dbDatabase* db) } _db = nullptr; - bindAllSRefs(); + bindAllRefs(); return _lib; } @@ -275,12 +275,16 @@ bool GDSReader::processElement(dbGDSStructure* structure) processPropAttr(el); break; } - case RecordType::SREF: - case RecordType::AREF: { + case RecordType::SREF: { auto el = processSRef(structure); processPropAttr(el); break; } + case RecordType::AREF: { + auto el = processARef(structure); + processPropAttr(el); + break; + } case RecordType::PATH: { auto el = processPath(structure); processPropAttr(el); @@ -390,6 +394,31 @@ dbGDSSRef* GDSReader::processSRef(dbGDSStructure* structure) return sref; } +dbGDSARef* GDSReader::processARef(dbGDSStructure* structure) +{ + auto* aref = dbGDSARef::create(structure); + + readRecord(); + checkRType(RecordType::SNAME); + aref->set_sName(std::string(_r.data8.begin(), _r.data8.end())); + + readRecord(); + if (_r.type == RecordType::STRANS) { + aref->setTransform(processSTrans()); + } + + if (_r.type == RecordType::COLROW) { + aref->set_colRow({_r.data16[0], _r.data16[1]}); + readRecord(); + } else { + aref->set_colRow({1, 1}); + } + + aref->setXy(processXY()); + + return aref; +} + dbGDSText* GDSReader::processText(dbGDSStructure* structure) { auto* text = dbGDSText::create(structure); @@ -500,7 +529,7 @@ dbGDSTextPres GDSReader::processTextPres() (dbGDSTextPres::HPres) hpres); } -void GDSReader::bindAllSRefs() +void GDSReader::bindAllRefs() { for (auto str : _lib->getGDSStructures()) { for (auto sref : str->getGDSSRefs()) { @@ -510,6 +539,13 @@ void GDSReader::bindAllSRefs() } sref->setStructure(ref); } + for (auto aref : str->getGDSARefs()) { + dbGDSStructure* ref = _lib->findGDSStructure(aref->get_sName().c_str()); + if (ref == nullptr) { + throw std::runtime_error("Corrupted GDS, ARef to non-existent struct"); + } + aref->setStructure(ref); + } } } diff --git a/src/odb/src/gdsout/gdsout.cpp b/src/odb/src/gdsout/gdsout.cpp index 7523d134c11..01af7922477 100644 --- a/src/odb/src/gdsout/gdsout.cpp +++ b/src/odb/src/gdsout/gdsout.cpp @@ -243,6 +243,10 @@ void GDSWriter::writeStruct(dbGDSStructure* str) writeSRef(sref); } + for (auto aref : str->getGDSARefs()) { + writeARef(aref); + } + for (auto text : str->getGDSTexts()) { writeText(text); } @@ -360,12 +364,7 @@ void GDSWriter::writePath(dbGDSPath* path) void GDSWriter::writeSRef(dbGDSSRef* sref) { record_t r; - auto colrow = sref->get_colRow(); - if (colrow.first == 1 && colrow.second == 1) { - r.type = RecordType::SREF; - } else { - r.type = RecordType::AREF; - } + r.type = RecordType::SREF; r.dataType = DataType::NO_DATA; writeRecord(r); @@ -379,6 +378,30 @@ void GDSWriter::writeSRef(dbGDSSRef* sref) writeSTrans(sref->getTransform()); } + writeXY(sref->getXY()); + + writePropAttr(sref); + writeEndel(); +} + +void GDSWriter::writeARef(dbGDSARef* aref) +{ + record_t r; + auto colrow = aref->get_colRow(); + r.type = RecordType::AREF; + r.dataType = DataType::NO_DATA; + writeRecord(r); + + record_t r2; + r2.type = RecordType::SNAME; + r2.dataType = DataType::ASCII_STRING; + r2.data8 = aref->get_sName(); + writeRecord(r2); + + if (!aref->getTransform().identity()) { + writeSTrans(aref->getTransform()); + } + if (colrow.first != 1 || colrow.second != 1) { record_t r4; r4.type = RecordType::COLROW; @@ -387,9 +410,9 @@ void GDSWriter::writeSRef(dbGDSSRef* sref) writeRecord(r4); } - writeXY(sref->getXY()); + writeXY(aref->getXY()); - writePropAttr(sref); + writePropAttr(aref); writeEndel(); } From 9f21aebf081ddb20db03fb1f6b3b28e63d25ee27 Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Thu, 2 Jan 2025 02:46:44 +0000 Subject: [PATCH 08/15] odb: change dbGDSSRef field xy (Point vector) to origin (one Point) Signed-off-by: Matt Liberty --- src/odb/include/odb/db.h | 11 ++---- .../codeGenerator/schema/gds/dbGDSSRef.json | 10 +---- src/odb/src/db/dbGDSSRef.cpp | 39 ++++++------------- src/odb/src/db/dbGDSSRef.h | 3 +- src/odb/src/gdsin/gdsin.cpp | 9 +---- src/odb/src/gdsout/gdsout.cpp | 3 +- 6 files changed, 21 insertions(+), 54 deletions(-) diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index b561c04f3fc..c007f84bdd4 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -7484,7 +7484,7 @@ class dbGDSARef : public dbObject void setStructure(dbGDSStructure* structure) const; static dbGDSARef* create(dbGDSStructure* structure); - static void destroy(dbGDSARef* sref); + static void destroy(dbGDSARef* aref); // User Code End dbGDSARef }; @@ -7570,9 +7570,9 @@ class dbGDSPath : public dbObject class dbGDSSRef : public dbObject { public: - void setXy(const std::vector& xy); + void setOrigin(Point origin); - void getXy(std::vector& tbl) const; + Point getOrigin() const; void set_sName(const std::string& sName); @@ -7582,12 +7582,7 @@ class dbGDSSRef : public dbObject dbGDSSTrans getTransform() const; - void set_colRow(const std::pair& colRow); - - std::pair get_colRow() const; - // User Code Begin dbGDSSRef - const std::vector& getXY(); std::vector>& getPropattr(); dbGDSStructure* getStructure() const; diff --git a/src/odb/src/codeGenerator/schema/gds/dbGDSSRef.json b/src/odb/src/codeGenerator/schema/gds/dbGDSSRef.json index e894f15f4ef..628e5f8271c 100644 --- a/src/odb/src/codeGenerator/schema/gds/dbGDSSRef.json +++ b/src/odb/src/codeGenerator/schema/gds/dbGDSSRef.json @@ -3,9 +3,8 @@ "type":"dbObject", "fields":[ { - "name":"_xy", - "type":"std::vector", - "flags":["no-template"] + "name":"_origin", + "type":"Point" }, { "name":"_propattr", @@ -21,11 +20,6 @@ "name":"_transform", "type":"dbGDSSTrans", "flags":[] - }, - { - "name":"_colRow", - "type":"std::pair", - "flags":["no-template"] } ], "h_includes": [ diff --git a/src/odb/src/db/dbGDSSRef.cpp b/src/odb/src/db/dbGDSSRef.cpp index 9d1629cfa0e..3cafb34001a 100644 --- a/src/odb/src/db/dbGDSSRef.cpp +++ b/src/odb/src/db/dbGDSSRef.cpp @@ -44,6 +44,9 @@ template class dbTable<_dbGDSSRef>; bool _dbGDSSRef::operator==(const _dbGDSSRef& rhs) const { + if (_origin != rhs._origin) { + return false; + } if (_sName != rhs._sName) { return false; } @@ -61,6 +64,7 @@ void _dbGDSSRef::differences(dbDiff& diff, const _dbGDSSRef& rhs) const { DIFF_BEGIN + DIFF_FIELD(_origin); DIFF_FIELD(_sName); DIFF_END } @@ -68,6 +72,7 @@ void _dbGDSSRef::differences(dbDiff& diff, void _dbGDSSRef::out(dbDiff& diff, char side, const char* field) const { DIFF_OUT_BEGIN + DIFF_OUT_FIELD(_origin); DIFF_OUT_FIELD(_sName); DIFF_END @@ -79,26 +84,25 @@ _dbGDSSRef::_dbGDSSRef(_dbDatabase* db) _dbGDSSRef::_dbGDSSRef(_dbDatabase* db, const _dbGDSSRef& r) { + _origin = r._origin; _sName = r._sName; } dbIStream& operator>>(dbIStream& stream, _dbGDSSRef& obj) { - stream >> obj._xy; + stream >> obj._origin; stream >> obj._propattr; stream >> obj._sName; stream >> obj._transform; - stream >> obj._colRow; return stream; } dbOStream& operator<<(dbOStream& stream, const _dbGDSSRef& obj) { - stream << obj._xy; + stream << obj._origin; stream << obj._propattr; stream << obj._sName; stream << obj._transform; - stream << obj._colRow; return stream; } @@ -108,17 +112,17 @@ dbOStream& operator<<(dbOStream& stream, const _dbGDSSRef& obj) // //////////////////////////////////////////////////////////////////// -void dbGDSSRef::setXy(const std::vector& xy) +void dbGDSSRef::setOrigin(Point origin) { _dbGDSSRef* obj = (_dbGDSSRef*) this; - obj->_xy = xy; + obj->_origin = origin; } -void dbGDSSRef::getXy(std::vector& tbl) const +Point dbGDSSRef::getOrigin() const { _dbGDSSRef* obj = (_dbGDSSRef*) this; - tbl = obj->_xy; + return obj->_origin; } void dbGDSSRef::set_sName(const std::string& sName) @@ -147,19 +151,6 @@ dbGDSSTrans dbGDSSRef::getTransform() const return obj->_transform; } -void dbGDSSRef::set_colRow(const std::pair& colRow) -{ - _dbGDSSRef* obj = (_dbGDSSRef*) this; - - obj->_colRow = colRow; -} - -std::pair dbGDSSRef::get_colRow() const -{ - _dbGDSSRef* obj = (_dbGDSSRef*) this; - return obj->_colRow; -} - // User Code Begin dbGDSSRefPublicMethods std::vector>& dbGDSSRef::getPropattr() @@ -168,12 +159,6 @@ std::vector>& dbGDSSRef::getPropattr() return obj->_propattr; } -const std::vector& dbGDSSRef::getXY() -{ - auto obj = (_dbGDSSRef*) this; - return obj->_xy; -} - dbGDSSRef* dbGDSSRef::create(dbGDSStructure* structure) { auto* obj = (_dbGDSStructure*) structure; diff --git a/src/odb/src/db/dbGDSSRef.h b/src/odb/src/db/dbGDSSRef.h index 3fea9a33a44..5e1a13897f0 100644 --- a/src/odb/src/db/dbGDSSRef.h +++ b/src/odb/src/db/dbGDSSRef.h @@ -64,11 +64,10 @@ class _dbGDSSRef : public _dbObject // User Code End Methods - std::vector _xy; + Point _origin; std::vector> _propattr; std::string _sName; dbGDSSTrans _transform; - std::pair _colRow; }; dbIStream& operator>>(dbIStream& stream, _dbGDSSRef& obj); dbOStream& operator<<(dbOStream& stream, const _dbGDSSRef& obj); diff --git a/src/odb/src/gdsin/gdsin.cpp b/src/odb/src/gdsin/gdsin.cpp index e6f14db637d..5c8ed19277c 100644 --- a/src/odb/src/gdsin/gdsin.cpp +++ b/src/odb/src/gdsin/gdsin.cpp @@ -382,14 +382,7 @@ dbGDSSRef* GDSReader::processSRef(dbGDSStructure* structure) sref->setTransform(processSTrans()); } - if (_r.type == RecordType::COLROW) { - sref->set_colRow({_r.data16[0], _r.data16[1]}); - readRecord(); - } else { - sref->set_colRow({1, 1}); - } - - sref->setXy(processXY()); + sref->setOrigin(processXY().at(0)); return sref; } diff --git a/src/odb/src/gdsout/gdsout.cpp b/src/odb/src/gdsout/gdsout.cpp index 01af7922477..99a0628b6b8 100644 --- a/src/odb/src/gdsout/gdsout.cpp +++ b/src/odb/src/gdsout/gdsout.cpp @@ -378,7 +378,8 @@ void GDSWriter::writeSRef(dbGDSSRef* sref) writeSTrans(sref->getTransform()); } - writeXY(sref->getXY()); + std::vector origin({sref->getOrigin()}); + writeXY(origin); writePropAttr(sref); writeEndel(); From c58b32c070e1800bfb830035c8c95c70a295e12e Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Thu, 2 Jan 2025 05:26:33 +0000 Subject: [PATCH 09/15] odb: rm obsolete absolute angle and magnitude from dbGDSSTrans Signed-off-by: Matt Liberty --- src/odb/include/odb/dbTypes.h | 3 +-- src/odb/src/db/dbTypes.cpp | 27 ++++++--------------------- src/odb/src/gdsin/gdsin.cpp | 5 ++--- src/odb/src/gdsout/gdsout.cpp | 3 +-- src/odb/test/cpp/TestGDSIn.cpp | 2 +- 5 files changed, 11 insertions(+), 29 deletions(-) diff --git a/src/odb/include/odb/dbTypes.h b/src/odb/include/odb/dbTypes.h index b76070ae9d3..4abb59cf3b7 100644 --- a/src/odb/include/odb/dbTypes.h +++ b/src/odb/include/odb/dbTypes.h @@ -130,12 +130,11 @@ class dbGDSSTrans { public: bool _flipX; - bool _absMag, _absAngle; double _mag, _angle; dbGDSSTrans(); - dbGDSSTrans(bool flipX, bool absMag, bool absAngle, double mag, double angle); + dbGDSSTrans(bool flipX, double mag, double angle); bool operator==(const dbGDSSTrans& rhs) const; diff --git a/src/odb/src/db/dbTypes.cpp b/src/odb/src/db/dbTypes.cpp index 9c405ac7da6..ff856b47d11 100644 --- a/src/odb/src/db/dbTypes.cpp +++ b/src/odb/src/db/dbTypes.cpp @@ -229,30 +229,20 @@ bool dbOrientType::isRightAngleRotation() const dbGDSSTrans::dbGDSSTrans() { _flipX = false; - _absMag = false; - _absAngle = false; _mag = 1.0; _angle = 0.0; } -dbGDSSTrans::dbGDSSTrans(bool flipX, - bool absMag, - bool absAngle, - double mag, - double angle) +dbGDSSTrans::dbGDSSTrans(bool flipX, double mag, double angle) { _flipX = flipX; - _absMag = absMag; - _absAngle = absAngle; _mag = mag; _angle = angle; } bool dbGDSSTrans::operator==(const dbGDSSTrans& rhs) const { - return (_flipX == rhs._flipX) && (_absMag == rhs._absMag) - && (_absAngle == rhs._absAngle) && (_mag == rhs._mag) - && (_angle == rhs._angle); + return (_flipX == rhs._flipX) && (_mag == rhs._mag) && (_angle == rhs._angle); } std::string dbGDSSTrans::to_string() const @@ -261,9 +251,9 @@ std::string dbGDSSTrans::to_string() const if (_flipX) { s += std::string("FLIP_X "); } - s += (_absMag) ? std::string("ABS_MAG ") : std::string("MAG "); - s += std::to_string(_mag) + " "; - s += (_absAngle) ? std::string("ABS_ANGLE ") : std::string("ANGLE "); + s += "MAG "; + s += std::to_string(_mag); + s += " ANGLE "; s += std::to_string(_angle); s += " "; return s; @@ -271,8 +261,7 @@ std::string dbGDSSTrans::to_string() const bool dbGDSSTrans::identity() const { - return (!_flipX) && (!_absMag) && (!_absAngle) && (_mag == 1.0) - && (_angle == 0.0); + return (!_flipX) && (_mag == 1.0) && (_angle == 0.0); } dbGDSTextPres::dbGDSTextPres() @@ -307,8 +296,6 @@ std::string dbGDSTextPres::to_string() const dbIStream& operator>>(dbIStream& stream, dbGDSSTrans& t) { stream >> t._flipX; - stream >> t._absMag; - stream >> t._absAngle; stream >> t._mag; stream >> t._angle; return stream; @@ -317,8 +304,6 @@ dbIStream& operator>>(dbIStream& stream, dbGDSSTrans& t) dbOStream& operator<<(dbOStream& stream, const dbGDSSTrans t) { stream << t._flipX; - stream << t._absMag; - stream << t._absAngle; stream << t._mag; stream << t._angle; return stream; diff --git a/src/odb/src/gdsin/gdsin.cpp b/src/odb/src/gdsin/gdsin.cpp index 5c8ed19277c..8b09bd006cb 100644 --- a/src/odb/src/gdsin/gdsin.cpp +++ b/src/odb/src/gdsin/gdsin.cpp @@ -493,8 +493,7 @@ dbGDSSTrans GDSReader::processSTrans() checkRType(RecordType::STRANS); const bool flipX = _r.data8[0] & 0x80; - const bool absMag = _r.data8[1] & 0x04; - const bool absAngle = _r.data8[1] & 0x02; + // absolute magnification and angle are obsolete and ignored readRecord(); @@ -509,7 +508,7 @@ dbGDSSTrans GDSReader::processSTrans() readRecord(); } - return dbGDSSTrans(flipX, absMag, absAngle, mag, angle); + return dbGDSSTrans(flipX, mag, angle); } dbGDSTextPres GDSReader::processTextPres() diff --git a/src/odb/src/gdsout/gdsout.cpp b/src/odb/src/gdsout/gdsout.cpp index 99a0628b6b8..3976e6769ae 100644 --- a/src/odb/src/gdsout/gdsout.cpp +++ b/src/odb/src/gdsout/gdsout.cpp @@ -481,8 +481,7 @@ void GDSWriter::writeSTrans(const dbGDSSTrans& strans) r.dataType = DataType::BIT_ARRAY; char data0 = strans._flipX << 7; - char data1 = strans._absAngle << 2 | strans._absMag << 1; - r.data8 = {data0, data1}; + r.data8 = {data0, 0}; writeRecord(r); if (strans._mag != 1.0) { diff --git a/src/odb/test/cpp/TestGDSIn.cpp b/src/odb/test/cpp/TestGDSIn.cpp index 774b2b97f0c..980f6f71f14 100644 --- a/src/odb/test/cpp/TestGDSIn.cpp +++ b/src/odb/test/cpp/TestGDSIn.cpp @@ -163,7 +163,7 @@ BOOST_AUTO_TEST_CASE(edit) dbGDSSRef* sref = dbGDSSRef::create(str3); sref->set_sName("str1"); - sref->setTransform(dbGDSSTrans(false, false, false, 2.0, 90)); + sref->setTransform(dbGDSSTrans(false, 2.0, 90)); std::string outpath = testTmpPath("results", "edit_test_out.gds"); From a73a5285d335f532ecba732e514822b3316c7413 Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Thu, 2 Jan 2025 05:40:40 +0000 Subject: [PATCH 10/15] odb: remove obsolete timestamps and unused srfName from dbGDSLib Signed-off-by: Matt Liberty --- src/odb/include/odb/db.h | 16 ----- src/odb/include/odb/gdsUtil.h | 5 -- src/odb/src/db/dbGDSLib.cpp | 105 --------------------------------- src/odb/src/db/dbGDSLib.h | 8 +-- src/odb/src/gdsin/gdsUtil.cpp | 11 ---- src/odb/src/gdsin/gdsin.cpp | 20 ------- src/odb/test/cpp/TestGDSIn.cpp | 2 - 7 files changed, 2 insertions(+), 165 deletions(-) diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index c007f84bdd4..265350f3463 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -5827,22 +5827,6 @@ class dbGDSLib : public dbObject std::string getLibname() const; - void set_lastAccessed(std::tm lastAccessed); - - std::tm get_lastAccessed() const; - - void set_lastModified(std::tm lastModified); - - std::tm get_lastModified() const; - - void set_libDirSize(int16_t libDirSize); - - int16_t get_libDirSize() const; - - void set_srfName(std::string srfName); - - std::string get_srfName() const; - void setUnits(double uu_per_dbu, double dbu_per_meter); std::pair getUnits() const; diff --git a/src/odb/include/odb/gdsUtil.h b/src/odb/include/odb/gdsUtil.h index c3698ac813b..2df8c827959 100644 --- a/src/odb/include/odb/gdsUtil.h +++ b/src/odb/include/odb/gdsUtil.h @@ -217,10 +217,5 @@ std::map, std::string> getLayerMap( */ dbGDSLib* createEmptyGDSLib(dbDatabase* db, const std::string& libname); -/** - * Sets timestamp on a GDSII library object to the current time - */ -void stampGDSLib(dbGDSLib* lib, bool modified = true); - } // namespace gds } // namespace odb diff --git a/src/odb/src/db/dbGDSLib.cpp b/src/odb/src/db/dbGDSLib.cpp index 670ebf4481d..c05cd5016a5 100644 --- a/src/odb/src/db/dbGDSLib.cpp +++ b/src/odb/src/db/dbGDSLib.cpp @@ -45,12 +45,6 @@ bool _dbGDSLib::operator==(const _dbGDSLib& rhs) const if (_libname != rhs._libname) { return false; } - if (_libDirSize != rhs._libDirSize) { - return false; - } - if (_srfName != rhs._srfName) { - return false; - } if (_uu_per_dbu != rhs._uu_per_dbu) { return false; } @@ -78,8 +72,6 @@ void _dbGDSLib::differences(dbDiff& diff, { DIFF_BEGIN DIFF_FIELD(_libname); - DIFF_FIELD(_libDirSize); - DIFF_FIELD(_srfName); DIFF_FIELD(_uu_per_dbu); DIFF_FIELD(_dbu_per_meter); DIFF_HASH_TABLE(_structure_hash); @@ -91,8 +83,6 @@ void _dbGDSLib::out(dbDiff& diff, char side, const char* field) const { DIFF_OUT_BEGIN DIFF_OUT_FIELD(_libname); - DIFF_OUT_FIELD(_libDirSize); - DIFF_OUT_FIELD(_srfName); DIFF_OUT_FIELD(_uu_per_dbu); DIFF_OUT_FIELD(_dbu_per_meter); DIFF_OUT_HASH_TABLE(_structure_hash); @@ -113,7 +103,6 @@ dbObjectTable* _dbGDSLib::getObjectTable(dbObjectType type) _dbGDSLib::_dbGDSLib(_dbDatabase* db) { - _libDirSize = 0; _uu_per_dbu = 1.0; _dbu_per_meter = 1e9; @@ -121,16 +110,10 @@ _dbGDSLib::_dbGDSLib(_dbDatabase* db) db, this, (GetObjTbl_t) &_dbGDSLib::getObjectTable, dbGDSStructureObj); _structure_hash.setTable(_structure_tbl); - std::mktime(&_lastAccessed); - std::mktime(&_lastModified); } _dbGDSLib::_dbGDSLib(_dbDatabase* db, const _dbGDSLib& r) : _libname(r._libname), - _lastAccessed(r._lastAccessed), - _lastModified(r._lastModified), - _libDirSize(r._libDirSize), - _srfName(r._srfName), _uu_per_dbu(r._uu_per_dbu), _dbu_per_meter(r._dbu_per_meter), _structure_hash(r._structure_hash), @@ -143,41 +126,9 @@ _dbGDSLib::~_dbGDSLib() delete _structure_tbl; } -dbIStream& operator>>(dbIStream& stream, std::tm& tm) -{ - stream >> tm.tm_sec; - stream >> tm.tm_min; - stream >> tm.tm_hour; - stream >> tm.tm_mday; - stream >> tm.tm_mon; - stream >> tm.tm_year; - stream >> tm.tm_wday; - stream >> tm.tm_yday; - stream >> tm.tm_isdst; - return stream; -} - -dbOStream& operator<<(dbOStream& stream, const std::tm& tm) -{ - stream << tm.tm_sec; - stream << tm.tm_min; - stream << tm.tm_hour; - stream << tm.tm_mday; - stream << tm.tm_mon; - stream << tm.tm_year; - stream << tm.tm_wday; - stream << tm.tm_yday; - stream << tm.tm_isdst; - return stream; -} - dbIStream& operator>>(dbIStream& stream, _dbGDSLib& obj) { stream >> obj._libname; - stream >> obj._lastAccessed; - stream >> obj._lastModified; - stream >> obj._libDirSize; - stream >> obj._srfName; stream >> obj._uu_per_dbu; stream >> obj._dbu_per_meter; stream >> *obj._structure_tbl; @@ -188,10 +139,6 @@ dbIStream& operator>>(dbIStream& stream, _dbGDSLib& obj) dbOStream& operator<<(dbOStream& stream, const _dbGDSLib& obj) { stream << obj._libname; - stream << obj._lastAccessed; - stream << obj._lastModified; - stream << obj._libDirSize; - stream << obj._srfName; stream << obj._uu_per_dbu; stream << obj._dbu_per_meter; stream << NamedTable("_structure_tbl", obj._structure_tbl); @@ -223,58 +170,6 @@ std::string dbGDSLib::getLibname() const return obj->_libname; } -void dbGDSLib::set_lastAccessed(std::tm lastAccessed) -{ - _dbGDSLib* obj = (_dbGDSLib*) this; - - obj->_lastAccessed = lastAccessed; -} - -std::tm dbGDSLib::get_lastAccessed() const -{ - _dbGDSLib* obj = (_dbGDSLib*) this; - return obj->_lastAccessed; -} - -void dbGDSLib::set_lastModified(std::tm lastModified) -{ - _dbGDSLib* obj = (_dbGDSLib*) this; - - obj->_lastModified = lastModified; -} - -std::tm dbGDSLib::get_lastModified() const -{ - _dbGDSLib* obj = (_dbGDSLib*) this; - return obj->_lastModified; -} - -void dbGDSLib::set_libDirSize(int16_t libDirSize) -{ - _dbGDSLib* obj = (_dbGDSLib*) this; - - obj->_libDirSize = libDirSize; -} - -int16_t dbGDSLib::get_libDirSize() const -{ - _dbGDSLib* obj = (_dbGDSLib*) this; - return obj->_libDirSize; -} - -void dbGDSLib::set_srfName(std::string srfName) -{ - _dbGDSLib* obj = (_dbGDSLib*) this; - - obj->_srfName = std::move(srfName); -} - -std::string dbGDSLib::get_srfName() const -{ - _dbGDSLib* obj = (_dbGDSLib*) this; - return obj->_srfName; -} - void dbGDSLib::setUnits(double uu_per_dbu, double dbu_per_meter) { _dbGDSLib* obj = (_dbGDSLib*) this; diff --git a/src/odb/src/db/dbGDSLib.h b/src/odb/src/db/dbGDSLib.h index 37d822e84a5..861be5d6418 100644 --- a/src/odb/src/db/dbGDSLib.h +++ b/src/odb/src/db/dbGDSLib.h @@ -52,13 +52,9 @@ class _dbGDSLib : public _dbObject { public: std::string _libname; - std::tm _lastAccessed; - std::tm _lastModified; - int16_t _libDirSize; - std::string _srfName; - double _uu_per_dbu, _dbu_per_meter; + double _uu_per_dbu; + double _dbu_per_meter; dbHashTable<_dbGDSStructure> _structure_hash; - dbTable<_dbGDSStructure>* _structure_tbl; _dbGDSLib(_dbDatabase*, const _dbGDSLib& r); diff --git a/src/odb/src/gdsin/gdsUtil.cpp b/src/odb/src/gdsin/gdsUtil.cpp index 10db99422a3..7f30a989f56 100644 --- a/src/odb/src/gdsin/gdsUtil.cpp +++ b/src/odb/src/gdsin/gdsUtil.cpp @@ -162,18 +162,7 @@ std::map, std::string> getLayerMap( dbGDSLib* createEmptyGDSLib(dbDatabase* db, const std::string& libname) { dbGDSLib* lib = dbGDSLib::create(db, libname); - stampGDSLib(lib, true); return lib; } -void stampGDSLib(dbGDSLib* lib, bool modified) -{ - const time_t now = std::time(nullptr); - const std::tm now_tm = *std::localtime(&now); - lib->set_lastAccessed(now_tm); - if (modified) { - lib->set_lastModified(now_tm); - } -} - } // namespace odb::gds diff --git a/src/odb/src/gdsin/gdsin.cpp b/src/odb/src/gdsin/gdsin.cpp index 8b09bd006cb..36826c0855b 100644 --- a/src/odb/src/gdsin/gdsin.cpp +++ b/src/odb/src/gdsin/gdsin.cpp @@ -163,26 +163,6 @@ bool GDSReader::processLib() "Corrupted GDS, BGNLIB record length is not 28 bytes"); } - std::tm lastMT; - lastMT.tm_year = _r.data16[0]; - lastMT.tm_mon = _r.data16[1]; - lastMT.tm_mday = _r.data16[2]; - lastMT.tm_hour = _r.data16[3]; - lastMT.tm_min = _r.data16[4]; - lastMT.tm_sec = _r.data16[5]; - - _lib->set_lastModified(lastMT); - - std::tm lastAT; - lastAT.tm_year = _r.data16[6]; - lastAT.tm_mon = _r.data16[7]; - lastAT.tm_mday = _r.data16[8]; - lastAT.tm_hour = _r.data16[9]; - lastAT.tm_min = _r.data16[10]; - lastAT.tm_sec = _r.data16[11]; - - _lib->set_lastAccessed(lastAT); - readRecord(); checkRType(RecordType::LIBNAME); _lib->setLibname(_r.data8); diff --git a/src/odb/test/cpp/TestGDSIn.cpp b/src/odb/test/cpp/TestGDSIn.cpp index 980f6f71f14..d363f3863fb 100644 --- a/src/odb/test/cpp/TestGDSIn.cpp +++ b/src/odb/test/cpp/TestGDSIn.cpp @@ -167,8 +167,6 @@ BOOST_AUTO_TEST_CASE(edit) std::string outpath = testTmpPath("results", "edit_test_out.gds"); - stampGDSLib(lib); - auto logger = std::make_unique(); GDSWriter writer(logger.get()); writer.write_gds(lib, outpath); From 375688bebe83264dc6f1d1c9e51d56c579da48b2 Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Thu, 2 Jan 2025 06:07:35 +0000 Subject: [PATCH 11/15] odb: change dbGDASRef field xy (Point vector) to origin/lr/ul (3 Points) Signed-off-by: Matt Liberty --- src/odb/include/odb/db.h | 13 +++- .../codeGenerator/schema/gds/dbGDSARef.json | 13 +++- src/odb/src/db/dbGDSARef.cpp | 66 +++++++++++++++---- src/odb/src/db/dbGDSARef.h | 4 +- src/odb/src/gdsin/gdsin.cpp | 5 +- src/odb/src/gdsout/gdsout.cpp | 3 +- 6 files changed, 83 insertions(+), 21 deletions(-) diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index 265350f3463..e31f53ad8fd 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -7444,9 +7444,17 @@ class dbGCellGrid : public dbObject class dbGDSARef : public dbObject { public: - void setXy(const std::vector& xy); + void setOrigin(Point origin); - void getXy(std::vector& tbl) const; + Point getOrigin() const; + + void setLr(Point lr); + + Point getLr() const; + + void setUl(Point ul); + + Point getUl() const; void set_sName(const std::string& sName); @@ -7461,7 +7469,6 @@ class dbGDSARef : public dbObject std::pair get_colRow() const; // User Code Begin dbGDSARef - const std::vector& getXY(); std::vector>& getPropattr(); dbGDSStructure* getStructure() const; diff --git a/src/odb/src/codeGenerator/schema/gds/dbGDSARef.json b/src/odb/src/codeGenerator/schema/gds/dbGDSARef.json index b93a693bf95..14a37370b93 100644 --- a/src/odb/src/codeGenerator/schema/gds/dbGDSARef.json +++ b/src/odb/src/codeGenerator/schema/gds/dbGDSARef.json @@ -3,9 +3,16 @@ "type":"dbObject", "fields":[ { - "name":"_xy", - "type":"std::vector", - "flags":["no-template"] + "name":"_origin", + "type":"Point" + }, + { + "name":"_lr", + "type":"Point" + }, + { + "name":"_ul", + "type":"Point" }, { "name":"_propattr", diff --git a/src/odb/src/db/dbGDSARef.cpp b/src/odb/src/db/dbGDSARef.cpp index 9c0e85705ba..04e3bd198a5 100644 --- a/src/odb/src/db/dbGDSARef.cpp +++ b/src/odb/src/db/dbGDSARef.cpp @@ -44,6 +44,15 @@ template class dbTable<_dbGDSARef>; bool _dbGDSARef::operator==(const _dbGDSARef& rhs) const { + if (_origin != rhs._origin) { + return false; + } + if (_lr != rhs._lr) { + return false; + } + if (_ul != rhs._ul) { + return false; + } if (_sName != rhs._sName) { return false; } @@ -61,6 +70,9 @@ void _dbGDSARef::differences(dbDiff& diff, const _dbGDSARef& rhs) const { DIFF_BEGIN + DIFF_FIELD(_origin); + DIFF_FIELD(_lr); + DIFF_FIELD(_ul); DIFF_FIELD(_sName); DIFF_END } @@ -68,6 +80,9 @@ void _dbGDSARef::differences(dbDiff& diff, void _dbGDSARef::out(dbDiff& diff, char side, const char* field) const { DIFF_OUT_BEGIN + DIFF_OUT_FIELD(_origin); + DIFF_OUT_FIELD(_lr); + DIFF_OUT_FIELD(_ul); DIFF_OUT_FIELD(_sName); DIFF_END @@ -79,12 +94,17 @@ _dbGDSARef::_dbGDSARef(_dbDatabase* db) _dbGDSARef::_dbGDSARef(_dbDatabase* db, const _dbGDSARef& r) { + _origin = r._origin; + _lr = r._lr; + _ul = r._ul; _sName = r._sName; } dbIStream& operator>>(dbIStream& stream, _dbGDSARef& obj) { - stream >> obj._xy; + stream >> obj._origin; + stream >> obj._lr; + stream >> obj._ul; stream >> obj._propattr; stream >> obj._sName; stream >> obj._transform; @@ -94,7 +114,9 @@ dbIStream& operator>>(dbIStream& stream, _dbGDSARef& obj) dbOStream& operator<<(dbOStream& stream, const _dbGDSARef& obj) { - stream << obj._xy; + stream << obj._origin; + stream << obj._lr; + stream << obj._ul; stream << obj._propattr; stream << obj._sName; stream << obj._transform; @@ -108,17 +130,43 @@ dbOStream& operator<<(dbOStream& stream, const _dbGDSARef& obj) // //////////////////////////////////////////////////////////////////// -void dbGDSARef::setXy(const std::vector& xy) +void dbGDSARef::setOrigin(Point origin) { _dbGDSARef* obj = (_dbGDSARef*) this; - obj->_xy = xy; + obj->_origin = origin; +} + +Point dbGDSARef::getOrigin() const +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + return obj->_origin; } -void dbGDSARef::getXy(std::vector& tbl) const +void dbGDSARef::setLr(Point lr) { _dbGDSARef* obj = (_dbGDSARef*) this; - tbl = obj->_xy; + + obj->_lr = lr; +} + +Point dbGDSARef::getLr() const +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + return obj->_lr; +} + +void dbGDSARef::setUl(Point ul) +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + + obj->_ul = ul; +} + +Point dbGDSARef::getUl() const +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + return obj->_ul; } void dbGDSARef::set_sName(const std::string& sName) @@ -168,12 +216,6 @@ std::vector>& dbGDSARef::getPropattr() return obj->_propattr; } -const std::vector& dbGDSARef::getXY() -{ - auto obj = (_dbGDSARef*) this; - return obj->_xy; -} - dbGDSARef* dbGDSARef::create(dbGDSStructure* structure) { auto* obj = (_dbGDSStructure*) structure; diff --git a/src/odb/src/db/dbGDSARef.h b/src/odb/src/db/dbGDSARef.h index f89466d9e34..8986a7cae38 100644 --- a/src/odb/src/db/dbGDSARef.h +++ b/src/odb/src/db/dbGDSARef.h @@ -64,7 +64,9 @@ class _dbGDSARef : public _dbObject // User Code End Methods - std::vector _xy; + Point _origin; + Point _lr; + Point _ul; std::vector> _propattr; std::string _sName; dbGDSSTrans _transform; diff --git a/src/odb/src/gdsin/gdsin.cpp b/src/odb/src/gdsin/gdsin.cpp index 36826c0855b..e9613481b5c 100644 --- a/src/odb/src/gdsin/gdsin.cpp +++ b/src/odb/src/gdsin/gdsin.cpp @@ -387,7 +387,10 @@ dbGDSARef* GDSReader::processARef(dbGDSStructure* structure) aref->set_colRow({1, 1}); } - aref->setXy(processXY()); + std::vector points = processXY(); + aref->setOrigin(points.at(0)); + aref->setLr(points.at(1)); + aref->setUl(points.at(2)); return aref; } diff --git a/src/odb/src/gdsout/gdsout.cpp b/src/odb/src/gdsout/gdsout.cpp index 3976e6769ae..a885713ca27 100644 --- a/src/odb/src/gdsout/gdsout.cpp +++ b/src/odb/src/gdsout/gdsout.cpp @@ -411,7 +411,8 @@ void GDSWriter::writeARef(dbGDSARef* aref) writeRecord(r4); } - writeXY(aref->getXY()); + std::vector points({aref->getOrigin(), aref->getLr(), aref->getUl()}); + writeXY(points); writePropAttr(aref); writeEndel(); From 2abfce52b82f60a77dec9cb406e4f46dece760a5 Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Thu, 2 Jan 2025 17:37:26 +0000 Subject: [PATCH 12/15] odb: change delayed gds binding of sref/aref to at construction Avoids storing the structure name on the [as]ref. gdsin creates empty structures if used before defined Signed-off-by: Matt Liberty --- src/odb/include/odb/db.h | 20 ++---- src/odb/include/odb/gdsin.h | 11 ++-- .../codeGenerator/schema/gds/dbGDSARef.json | 11 ++-- .../codeGenerator/schema/gds/dbGDSSRef.json | 11 ++-- src/odb/src/db/dbGDSARef.cpp | 58 ++++++++---------- src/odb/src/db/dbGDSARef.h | 3 +- src/odb/src/db/dbGDSLib.cpp | 38 ++++++------ src/odb/src/db/dbGDSLib.h | 4 +- src/odb/src/db/dbGDSSRef.cpp | 58 ++++++++---------- src/odb/src/db/dbGDSSRef.h | 8 +-- src/odb/src/db/dbGDSStructure.cpp | 8 +-- src/odb/src/gdsin/gdsin.cpp | 61 +++++++++---------- src/odb/src/gdsout/gdsout.cpp | 4 +- src/odb/test/cpp/TestGDSIn.cpp | 5 +- 14 files changed, 133 insertions(+), 167 deletions(-) diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index e31f53ad8fd..bf2d747c1d6 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -7456,10 +7456,6 @@ class dbGDSARef : public dbObject Point getUl() const; - void set_sName(const std::string& sName); - - std::string get_sName() const; - void setTransform(dbGDSSTrans transform); dbGDSSTrans getTransform() const; @@ -7469,12 +7465,10 @@ class dbGDSARef : public dbObject std::pair get_colRow() const; // User Code Begin dbGDSARef - std::vector>& getPropattr(); - dbGDSStructure* getStructure() const; - void setStructure(dbGDSStructure* structure) const; + std::vector>& getPropattr(); - static dbGDSARef* create(dbGDSStructure* structure); + static dbGDSARef* create(dbGDSStructure* parent, dbGDSStructure* child); static void destroy(dbGDSARef* aref); // User Code End dbGDSARef }; @@ -7565,21 +7559,15 @@ class dbGDSSRef : public dbObject Point getOrigin() const; - void set_sName(const std::string& sName); - - std::string get_sName() const; - void setTransform(dbGDSSTrans transform); dbGDSSTrans getTransform() const; // User Code Begin dbGDSSRef - std::vector>& getPropattr(); - dbGDSStructure* getStructure() const; - void setStructure(dbGDSStructure* structure) const; + std::vector>& getPropattr(); - static dbGDSSRef* create(dbGDSStructure* structure); + static dbGDSSRef* create(dbGDSStructure* parent, dbGDSStructure* child); static void destroy(dbGDSSRef* sref); // User Code End dbGDSSRef }; diff --git a/src/odb/include/odb/gdsin.h b/src/odb/include/odb/gdsin.h index bfc4917a90c..eaf221b30e6 100644 --- a/src/odb/include/odb/gdsin.h +++ b/src/odb/include/odb/gdsin.h @@ -159,12 +159,6 @@ class GDSReader */ dbGDSTextPres processTextPres(); - /** - * This function is called after the entire GDS file has been read to bind all - * SRefs and ARefs with the pointers to the referenced structures. - */ - void bindAllRefs(); - /** Current filestream */ std::ifstream _file; /** Most recently read record */ @@ -173,6 +167,11 @@ class GDSReader dbDatabase* _db = nullptr; /** Current GDS Lib object */ dbGDSLib* _lib = nullptr; + /** An sref may refer to a structure that isn't yet built while + reading the gds. We will make an empty structure but it isn't + yet defined. We keep track of defined structures to catch any + duplicates.*/ + std::set _defined; utl::Logger* _logger{nullptr}; }; diff --git a/src/odb/src/codeGenerator/schema/gds/dbGDSARef.json b/src/odb/src/codeGenerator/schema/gds/dbGDSARef.json index 14a37370b93..fef1666f796 100644 --- a/src/odb/src/codeGenerator/schema/gds/dbGDSARef.json +++ b/src/odb/src/codeGenerator/schema/gds/dbGDSARef.json @@ -19,11 +19,6 @@ "type":"std::vector>", "flags":["no-template", "no-get", "no-set"] }, - { - "name":"_sName", - "type":"std::string", - "flags":[] - }, { "name":"_transform", "type":"dbGDSSTrans", @@ -33,6 +28,12 @@ "name":"_colRow", "type":"std::pair", "flags":["no-template"] + }, + { + "name":"_structure", + "type":"dbId<_dbGDSStructure>", + "parent":"dbGDSStructure", + "flags":["no-get", "no-set"] } ], "h_includes": [ diff --git a/src/odb/src/codeGenerator/schema/gds/dbGDSSRef.json b/src/odb/src/codeGenerator/schema/gds/dbGDSSRef.json index 628e5f8271c..23ffc45396b 100644 --- a/src/odb/src/codeGenerator/schema/gds/dbGDSSRef.json +++ b/src/odb/src/codeGenerator/schema/gds/dbGDSSRef.json @@ -11,15 +11,16 @@ "type":"std::vector>", "flags":["no-template", "no-get", "no-set"] }, - { - "name":"_sName", - "type":"std::string", - "flags":[] - }, { "name":"_transform", "type":"dbGDSSTrans", "flags":[] + }, + { + "name":"_structure", + "type":"dbId<_dbGDSStructure>", + "parent":"dbGDSStructure", + "flags":["no-get", "no-set"] } ], "h_includes": [ diff --git a/src/odb/src/db/dbGDSARef.cpp b/src/odb/src/db/dbGDSARef.cpp index 04e3bd198a5..dff706aafac 100644 --- a/src/odb/src/db/dbGDSARef.cpp +++ b/src/odb/src/db/dbGDSARef.cpp @@ -39,6 +39,9 @@ #include "dbTable.hpp" #include "odb/db.h" #include "odb/dbTypes.h" +// User Code Begin Includes +#include "dbGDSLib.h" +// User Code End Includes namespace odb { template class dbTable<_dbGDSARef>; @@ -53,7 +56,7 @@ bool _dbGDSARef::operator==(const _dbGDSARef& rhs) const if (_ul != rhs._ul) { return false; } - if (_sName != rhs._sName) { + if (_structure != rhs._structure) { return false; } @@ -73,7 +76,7 @@ void _dbGDSARef::differences(dbDiff& diff, DIFF_FIELD(_origin); DIFF_FIELD(_lr); DIFF_FIELD(_ul); - DIFF_FIELD(_sName); + DIFF_FIELD(_structure); DIFF_END } @@ -83,7 +86,7 @@ void _dbGDSARef::out(dbDiff& diff, char side, const char* field) const DIFF_OUT_FIELD(_origin); DIFF_OUT_FIELD(_lr); DIFF_OUT_FIELD(_ul); - DIFF_OUT_FIELD(_sName); + DIFF_OUT_FIELD(_structure); DIFF_END } @@ -97,7 +100,7 @@ _dbGDSARef::_dbGDSARef(_dbDatabase* db, const _dbGDSARef& r) _origin = r._origin; _lr = r._lr; _ul = r._ul; - _sName = r._sName; + _structure = r._structure; } dbIStream& operator>>(dbIStream& stream, _dbGDSARef& obj) @@ -106,9 +109,9 @@ dbIStream& operator>>(dbIStream& stream, _dbGDSARef& obj) stream >> obj._lr; stream >> obj._ul; stream >> obj._propattr; - stream >> obj._sName; stream >> obj._transform; stream >> obj._colRow; + stream >> obj._structure; return stream; } @@ -118,9 +121,9 @@ dbOStream& operator<<(dbOStream& stream, const _dbGDSARef& obj) stream << obj._lr; stream << obj._ul; stream << obj._propattr; - stream << obj._sName; stream << obj._transform; stream << obj._colRow; + stream << obj._structure; return stream; } @@ -169,19 +172,6 @@ Point dbGDSARef::getUl() const return obj->_ul; } -void dbGDSARef::set_sName(const std::string& sName) -{ - _dbGDSARef* obj = (_dbGDSARef*) this; - - obj->_sName = sName; -} - -std::string dbGDSARef::get_sName() const -{ - _dbGDSARef* obj = (_dbGDSARef*) this; - return obj->_sName; -} - void dbGDSARef::setTransform(dbGDSSTrans transform) { _dbGDSARef* obj = (_dbGDSARef*) this; @@ -210,16 +200,29 @@ std::pair dbGDSARef::get_colRow() const // User Code Begin dbGDSARefPublicMethods +dbGDSStructure* dbGDSARef::getStructure() const +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + if (obj->_structure == 0) { + return nullptr; + } + _dbGDSStructure* parent = (_dbGDSStructure*) obj->getOwner(); + _dbGDSLib* lib = (_dbGDSLib*) parent->getOwner(); + return (dbGDSStructure*) lib->_gdsstructure_tbl->getPtr(obj->_structure); +} + std::vector>& dbGDSARef::getPropattr() { auto* obj = (_dbGDSARef*) this; return obj->_propattr; } -dbGDSARef* dbGDSARef::create(dbGDSStructure* structure) +dbGDSARef* dbGDSARef::create(dbGDSStructure* parent, dbGDSStructure* child) { - auto* obj = (_dbGDSStructure*) structure; - return (dbGDSARef*) obj->arefs_->create(); + auto* obj = (_dbGDSStructure*) parent; + _dbGDSARef* aref = obj->arefs_->create(); + aref->_structure = child->getImpl()->getOID(); + return (dbGDSARef*) aref; } void dbGDSARef::destroy(dbGDSARef* aref) @@ -229,17 +232,6 @@ void dbGDSARef::destroy(dbGDSARef* aref) structure->arefs_->destroy(obj); } -dbGDSStructure* dbGDSARef::getStructure() const -{ - _dbGDSARef* obj = (_dbGDSARef*) this; - return obj->_stucture; -} - -void dbGDSARef::setStructure(dbGDSStructure* structure) const -{ - _dbGDSARef* obj = (_dbGDSARef*) this; - obj->_stucture = structure; -} // User Code End dbGDSARefPublicMethods } // namespace odb // Generator Code End Cpp diff --git a/src/odb/src/db/dbGDSARef.h b/src/odb/src/db/dbGDSARef.h index 8986a7cae38..5258d8c719e 100644 --- a/src/odb/src/db/dbGDSARef.h +++ b/src/odb/src/db/dbGDSARef.h @@ -42,6 +42,7 @@ class dbIStream; class dbOStream; class dbDiff; class _dbDatabase; +class _dbGDSStructure; class _dbGDSARef : public _dbObject { @@ -68,9 +69,9 @@ class _dbGDSARef : public _dbObject Point _lr; Point _ul; std::vector> _propattr; - std::string _sName; dbGDSSTrans _transform; std::pair _colRow; + dbId<_dbGDSStructure> _structure; }; dbIStream& operator>>(dbIStream& stream, _dbGDSARef& obj); dbOStream& operator<<(dbOStream& stream, const _dbGDSARef& obj); diff --git a/src/odb/src/db/dbGDSLib.cpp b/src/odb/src/db/dbGDSLib.cpp index c05cd5016a5..16b67c8d814 100644 --- a/src/odb/src/db/dbGDSLib.cpp +++ b/src/odb/src/db/dbGDSLib.cpp @@ -51,10 +51,10 @@ bool _dbGDSLib::operator==(const _dbGDSLib& rhs) const if (_dbu_per_meter != rhs._dbu_per_meter) { return false; } - if (*_structure_tbl != *rhs._structure_tbl) { + if (*_gdsstructure_tbl != *rhs._gdsstructure_tbl) { return false; } - if (_structure_hash != rhs._structure_hash) { + if (_gdsstructure_hash != rhs._gdsstructure_hash) { return false; } return true; @@ -74,8 +74,8 @@ void _dbGDSLib::differences(dbDiff& diff, DIFF_FIELD(_libname); DIFF_FIELD(_uu_per_dbu); DIFF_FIELD(_dbu_per_meter); - DIFF_HASH_TABLE(_structure_hash); - DIFF_TABLE_NO_DEEP(_structure_tbl); + DIFF_HASH_TABLE(_gdsstructure_hash); + DIFF_TABLE_NO_DEEP(_gdsstructure_tbl); DIFF_END } @@ -85,8 +85,8 @@ void _dbGDSLib::out(dbDiff& diff, char side, const char* field) const DIFF_OUT_FIELD(_libname); DIFF_OUT_FIELD(_uu_per_dbu); DIFF_OUT_FIELD(_dbu_per_meter); - DIFF_OUT_HASH_TABLE(_structure_hash); - DIFF_OUT_TABLE_NO_DEEP(_structure_tbl); + DIFF_OUT_HASH_TABLE(_gdsstructure_hash); + DIFF_OUT_TABLE_NO_DEEP(_gdsstructure_tbl); DIFF_END } @@ -94,7 +94,7 @@ dbObjectTable* _dbGDSLib::getObjectTable(dbObjectType type) { switch (type) { case dbGDSStructureObj: - return _structure_tbl; + return _gdsstructure_tbl; default: break; } @@ -106,24 +106,24 @@ _dbGDSLib::_dbGDSLib(_dbDatabase* db) _uu_per_dbu = 1.0; _dbu_per_meter = 1e9; - _structure_tbl = new dbTable<_dbGDSStructure>( + _gdsstructure_tbl = new dbTable<_dbGDSStructure>( db, this, (GetObjTbl_t) &_dbGDSLib::getObjectTable, dbGDSStructureObj); - _structure_hash.setTable(_structure_tbl); + _gdsstructure_hash.setTable(_gdsstructure_tbl); } _dbGDSLib::_dbGDSLib(_dbDatabase* db, const _dbGDSLib& r) : _libname(r._libname), _uu_per_dbu(r._uu_per_dbu), _dbu_per_meter(r._dbu_per_meter), - _structure_hash(r._structure_hash), - _structure_tbl(r._structure_tbl) + _gdsstructure_hash(r._gdsstructure_hash), + _gdsstructure_tbl(r._gdsstructure_tbl) { } _dbGDSLib::~_dbGDSLib() { - delete _structure_tbl; + delete _gdsstructure_tbl; } dbIStream& operator>>(dbIStream& stream, _dbGDSLib& obj) @@ -131,8 +131,8 @@ dbIStream& operator>>(dbIStream& stream, _dbGDSLib& obj) stream >> obj._libname; stream >> obj._uu_per_dbu; stream >> obj._dbu_per_meter; - stream >> *obj._structure_tbl; - stream >> obj._structure_hash; + stream >> *obj._gdsstructure_tbl; + stream >> obj._gdsstructure_hash; return stream; } @@ -141,14 +141,14 @@ dbOStream& operator<<(dbOStream& stream, const _dbGDSLib& obj) stream << obj._libname; stream << obj._uu_per_dbu; stream << obj._dbu_per_meter; - stream << NamedTable("_structure_tbl", obj._structure_tbl); - stream << obj._structure_hash; + stream << NamedTable("_structure_tbl", obj._gdsstructure_tbl); + stream << obj._gdsstructure_hash; return stream; } _dbGDSStructure* _dbGDSLib::findStructure(const char* name) { - return _structure_hash.find(name); + return _gdsstructure_hash.find(name); } //////////////////////////////////////////////////////////////////// @@ -187,13 +187,13 @@ std::pair dbGDSLib::getUnits() const dbGDSStructure* dbGDSLib::findGDSStructure(const char* name) const { _dbGDSLib* obj = (_dbGDSLib*) this; - return (dbGDSStructure*) obj->_structure_hash.find(name); + return (dbGDSStructure*) obj->_gdsstructure_hash.find(name); } dbSet dbGDSLib::getGDSStructures() { _dbGDSLib* obj = (_dbGDSLib*) this; - return dbSet(obj, obj->_structure_tbl); + return dbSet(obj, obj->_gdsstructure_tbl); } dbGDSLib* dbGDSLib::create(dbDatabase* db, const std::string& name) diff --git a/src/odb/src/db/dbGDSLib.h b/src/odb/src/db/dbGDSLib.h index 861be5d6418..4893a37d4e7 100644 --- a/src/odb/src/db/dbGDSLib.h +++ b/src/odb/src/db/dbGDSLib.h @@ -54,8 +54,8 @@ class _dbGDSLib : public _dbObject std::string _libname; double _uu_per_dbu; double _dbu_per_meter; - dbHashTable<_dbGDSStructure> _structure_hash; - dbTable<_dbGDSStructure>* _structure_tbl; + dbHashTable<_dbGDSStructure> _gdsstructure_hash; + dbTable<_dbGDSStructure>* _gdsstructure_tbl; _dbGDSLib(_dbDatabase*, const _dbGDSLib& r); _dbGDSLib(_dbDatabase*); diff --git a/src/odb/src/db/dbGDSSRef.cpp b/src/odb/src/db/dbGDSSRef.cpp index 3cafb34001a..fc5f9f48725 100644 --- a/src/odb/src/db/dbGDSSRef.cpp +++ b/src/odb/src/db/dbGDSSRef.cpp @@ -39,6 +39,9 @@ #include "dbTable.hpp" #include "odb/db.h" #include "odb/dbTypes.h" +// User Code Begin Includes +#include "dbGDSLib.h" +// User Code End Includes namespace odb { template class dbTable<_dbGDSSRef>; @@ -47,7 +50,7 @@ bool _dbGDSSRef::operator==(const _dbGDSSRef& rhs) const if (_origin != rhs._origin) { return false; } - if (_sName != rhs._sName) { + if (_structure != rhs._structure) { return false; } @@ -65,7 +68,7 @@ void _dbGDSSRef::differences(dbDiff& diff, { DIFF_BEGIN DIFF_FIELD(_origin); - DIFF_FIELD(_sName); + DIFF_FIELD(_structure); DIFF_END } @@ -73,7 +76,7 @@ void _dbGDSSRef::out(dbDiff& diff, char side, const char* field) const { DIFF_OUT_BEGIN DIFF_OUT_FIELD(_origin); - DIFF_OUT_FIELD(_sName); + DIFF_OUT_FIELD(_structure); DIFF_END } @@ -85,15 +88,15 @@ _dbGDSSRef::_dbGDSSRef(_dbDatabase* db) _dbGDSSRef::_dbGDSSRef(_dbDatabase* db, const _dbGDSSRef& r) { _origin = r._origin; - _sName = r._sName; + _structure = r._structure; } dbIStream& operator>>(dbIStream& stream, _dbGDSSRef& obj) { stream >> obj._origin; stream >> obj._propattr; - stream >> obj._sName; stream >> obj._transform; + stream >> obj._structure; return stream; } @@ -101,8 +104,8 @@ dbOStream& operator<<(dbOStream& stream, const _dbGDSSRef& obj) { stream << obj._origin; stream << obj._propattr; - stream << obj._sName; stream << obj._transform; + stream << obj._structure; return stream; } @@ -125,19 +128,6 @@ Point dbGDSSRef::getOrigin() const return obj->_origin; } -void dbGDSSRef::set_sName(const std::string& sName) -{ - _dbGDSSRef* obj = (_dbGDSSRef*) this; - - obj->_sName = sName; -} - -std::string dbGDSSRef::get_sName() const -{ - _dbGDSSRef* obj = (_dbGDSSRef*) this; - return obj->_sName; -} - void dbGDSSRef::setTransform(dbGDSSTrans transform) { _dbGDSSRef* obj = (_dbGDSSRef*) this; @@ -153,16 +143,29 @@ dbGDSSTrans dbGDSSRef::getTransform() const // User Code Begin dbGDSSRefPublicMethods +dbGDSStructure* dbGDSSRef::getStructure() const +{ + _dbGDSSRef* obj = (_dbGDSSRef*) this; + if (obj->_structure == 0) { + return nullptr; + } + _dbGDSStructure* parent = (_dbGDSStructure*) obj->getOwner(); + _dbGDSLib* lib = (_dbGDSLib*) parent->getOwner(); + return (dbGDSStructure*) lib->_gdsstructure_tbl->getPtr(obj->_structure); +} + std::vector>& dbGDSSRef::getPropattr() { auto* obj = (_dbGDSSRef*) this; return obj->_propattr; } -dbGDSSRef* dbGDSSRef::create(dbGDSStructure* structure) +dbGDSSRef* dbGDSSRef::create(dbGDSStructure* parent, dbGDSStructure* child) { - auto* obj = (_dbGDSStructure*) structure; - return (dbGDSSRef*) obj->srefs_->create(); + auto* obj = (_dbGDSStructure*) parent; + _dbGDSSRef* sref = obj->srefs_->create(); + sref->_structure = child->getImpl()->getOID(); + return (dbGDSSRef*) sref; } void dbGDSSRef::destroy(dbGDSSRef* sRef) @@ -172,17 +175,6 @@ void dbGDSSRef::destroy(dbGDSSRef* sRef) structure->srefs_->destroy(obj); } -dbGDSStructure* dbGDSSRef::getStructure() const -{ - _dbGDSSRef* obj = (_dbGDSSRef*) this; - return obj->_stucture; -} - -void dbGDSSRef::setStructure(dbGDSStructure* structure) const -{ - _dbGDSSRef* obj = (_dbGDSSRef*) this; - obj->_stucture = structure; -} // User Code End dbGDSSRefPublicMethods } // namespace odb // Generator Code End Cpp diff --git a/src/odb/src/db/dbGDSSRef.h b/src/odb/src/db/dbGDSSRef.h index 5e1a13897f0..852c095c27d 100644 --- a/src/odb/src/db/dbGDSSRef.h +++ b/src/odb/src/db/dbGDSSRef.h @@ -42,6 +42,7 @@ class dbIStream; class dbOStream; class dbDiff; class _dbDatabase; +class _dbGDSStructure; class _dbGDSSRef : public _dbObject { @@ -58,16 +59,11 @@ class _dbGDSSRef : public _dbObject const char* field, const _dbGDSSRef& rhs) const; void out(dbDiff& diff, char side, const char* field) const; - // User Code Begin Methods - - dbGDSStructure* _stucture = nullptr; - - // User Code End Methods Point _origin; std::vector> _propattr; - std::string _sName; dbGDSSTrans _transform; + dbId<_dbGDSStructure> _structure; }; dbIStream& operator>>(dbIStream& stream, _dbGDSSRef& obj); dbOStream& operator<<(dbOStream& stream, const _dbGDSSRef& obj); diff --git a/src/odb/src/db/dbGDSStructure.cpp b/src/odb/src/db/dbGDSStructure.cpp index 41a54969abf..a2ff02d8824 100644 --- a/src/odb/src/db/dbGDSStructure.cpp +++ b/src/odb/src/db/dbGDSStructure.cpp @@ -266,13 +266,13 @@ dbGDSStructure* dbGDSStructure::create(dbGDSLib* lib_, const char* name_) } _dbGDSLib* lib = (_dbGDSLib*) lib_; - _dbGDSStructure* structure = lib->_structure_tbl->create(); + _dbGDSStructure* structure = lib->_gdsstructure_tbl->create(); structure->_name = strdup(name_); ZALLOCATED(structure->_name); // TODO: ID for structure - lib->_structure_hash.insert(structure); + lib->_gdsstructure_hash.insert(structure); return (dbGDSStructure*) structure; } @@ -280,8 +280,8 @@ void dbGDSStructure::destroy(dbGDSStructure* structure) { _dbGDSStructure* str_impl = (_dbGDSStructure*) structure; _dbGDSLib* lib = (_dbGDSLib*) structure->getGDSLib(); - lib->_structure_hash.remove(str_impl); - lib->_structure_tbl->destroy(str_impl); + lib->_gdsstructure_hash.remove(str_impl); + lib->_gdsstructure_tbl->destroy(str_impl); } dbGDSLib* dbGDSStructure::getGDSLib() diff --git a/src/odb/src/gdsin/gdsin.cpp b/src/odb/src/gdsin/gdsin.cpp index e9613481b5c..cedfddb4fce 100644 --- a/src/odb/src/gdsin/gdsin.cpp +++ b/src/odb/src/gdsin/gdsin.cpp @@ -58,7 +58,6 @@ dbGDSLib* GDSReader::read_gds(const std::string& filename, dbDatabase* db) } _db = nullptr; - bindAllRefs(); return _lib; } @@ -194,17 +193,21 @@ bool GDSReader::processStruct() const std::string name(_r.data8.begin(), _r.data8.end()); - if (_lib->findGDSStructure(name.c_str()) != nullptr) { - throw std::runtime_error("Corrupted GDS, Duplicate structure name"); + dbGDSStructure* structure = _lib->findGDSStructure(name.c_str()); + if (structure) { + if (_defined.find(structure) != _defined.end()) { + throw std::runtime_error("Corrupted GDS, Duplicate structure name"); + } + } else { + structure = dbGDSStructure::create(_lib, name.c_str()); } - - dbGDSStructure* str = dbGDSStructure::create(_lib, name.c_str()); + _defined.insert(structure); while (readRecord()) { if (_r.type == RecordType::ENDSTR) { return true; } - if (!processElement(str)) { + if (!processElement(structure)) { break; } } @@ -351,11 +354,18 @@ dbGDSBoundary* GDSReader::processBoundary(dbGDSStructure* structure) dbGDSSRef* GDSReader::processSRef(dbGDSStructure* structure) { - auto* sref = dbGDSSRef::create(structure); - readRecord(); checkRType(RecordType::SNAME); - sref->set_sName(std::string(_r.data8.begin(), _r.data8.end())); + + const std::string name(_r.data8.begin(), _r.data8.end()); + + dbGDSStructure* referenced = _lib->findGDSStructure(name.c_str()); + if (!referenced) { + // Empty structure just to reference not yet defined. + referenced = dbGDSStructure::create(_lib, name.c_str()); + } + + auto* sref = dbGDSSRef::create(structure, referenced); readRecord(); if (_r.type == RecordType::STRANS) { @@ -369,11 +379,18 @@ dbGDSSRef* GDSReader::processSRef(dbGDSStructure* structure) dbGDSARef* GDSReader::processARef(dbGDSStructure* structure) { - auto* aref = dbGDSARef::create(structure); - readRecord(); checkRType(RecordType::SNAME); - aref->set_sName(std::string(_r.data8.begin(), _r.data8.end())); + + const std::string name(_r.data8.begin(), _r.data8.end()); + + dbGDSStructure* referenced = _lib->findGDSStructure(name.c_str()); + if (!referenced) { + // Empty structure just to reference not yet defined. + referenced = dbGDSStructure::create(_lib, name.c_str()); + } + + auto* aref = dbGDSARef::create(structure, referenced); readRecord(); if (_r.type == RecordType::STRANS) { @@ -504,24 +521,4 @@ dbGDSTextPres GDSReader::processTextPres() (dbGDSTextPres::HPres) hpres); } -void GDSReader::bindAllRefs() -{ - for (auto str : _lib->getGDSStructures()) { - for (auto sref : str->getGDSSRefs()) { - dbGDSStructure* ref = _lib->findGDSStructure(sref->get_sName().c_str()); - if (ref == nullptr) { - throw std::runtime_error("Corrupted GDS, SRef to non-existent struct"); - } - sref->setStructure(ref); - } - for (auto aref : str->getGDSARefs()) { - dbGDSStructure* ref = _lib->findGDSStructure(aref->get_sName().c_str()); - if (ref == nullptr) { - throw std::runtime_error("Corrupted GDS, ARef to non-existent struct"); - } - aref->setStructure(ref); - } - } -} - } // namespace odb::gds diff --git a/src/odb/src/gdsout/gdsout.cpp b/src/odb/src/gdsout/gdsout.cpp index a885713ca27..07ca6cab2b7 100644 --- a/src/odb/src/gdsout/gdsout.cpp +++ b/src/odb/src/gdsout/gdsout.cpp @@ -371,7 +371,7 @@ void GDSWriter::writeSRef(dbGDSSRef* sref) record_t r2; r2.type = RecordType::SNAME; r2.dataType = DataType::ASCII_STRING; - r2.data8 = sref->get_sName(); + r2.data8 = sref->getStructure()->getName(); writeRecord(r2); if (!sref->getTransform().identity()) { @@ -396,7 +396,7 @@ void GDSWriter::writeARef(dbGDSARef* aref) record_t r2; r2.type = RecordType::SNAME; r2.dataType = DataType::ASCII_STRING; - r2.data8 = aref->get_sName(); + r2.data8 = aref->getStructure()->getName(); writeRecord(r2); if (!aref->getTransform().identity()) { diff --git a/src/odb/test/cpp/TestGDSIn.cpp b/src/odb/test/cpp/TestGDSIn.cpp index d363f3863fb..2451a755d37 100644 --- a/src/odb/test/cpp/TestGDSIn.cpp +++ b/src/odb/test/cpp/TestGDSIn.cpp @@ -161,8 +161,7 @@ BOOST_AUTO_TEST_CASE(edit) box->getPropattr().emplace_back(12, "test"); - dbGDSSRef* sref = dbGDSSRef::create(str3); - sref->set_sName("str1"); + dbGDSSRef* sref = dbGDSSRef::create(str3, str1); sref->setTransform(dbGDSSTrans(false, 2.0, 90)); std::string outpath = testTmpPath("results", "edit_test_out.gds"); @@ -193,7 +192,7 @@ BOOST_AUTO_TEST_CASE(edit) BOOST_TEST(str3_read->getGDSSRefs().size() == 1); dbGDSSRef* sref_read = *str3_read->getGDSSRefs().begin(); - BOOST_TEST(sref_read->get_sName() == "str1"); + BOOST_TEST(sref_read->getStructure()->getName() == "str1"); BOOST_TEST(sref_read->getTransform()._mag == 2.0); BOOST_TEST(sref_read->getTransform()._angle == 90); From c6aeb06566cb51a00eb83df2c4e574dfd6daf26e Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Thu, 2 Jan 2025 17:39:57 +0000 Subject: [PATCH 13/15] odb: clang-format gdsin.cpp Signed-off-by: Matt Liberty --- src/odb/src/gdsin/gdsin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/odb/src/gdsin/gdsin.cpp b/src/odb/src/gdsin/gdsin.cpp index cedfddb4fce..eb612dcd5d1 100644 --- a/src/odb/src/gdsin/gdsin.cpp +++ b/src/odb/src/gdsin/gdsin.cpp @@ -358,13 +358,13 @@ dbGDSSRef* GDSReader::processSRef(dbGDSStructure* structure) checkRType(RecordType::SNAME); const std::string name(_r.data8.begin(), _r.data8.end()); - + dbGDSStructure* referenced = _lib->findGDSStructure(name.c_str()); if (!referenced) { // Empty structure just to reference not yet defined. referenced = dbGDSStructure::create(_lib, name.c_str()); } - + auto* sref = dbGDSSRef::create(structure, referenced); readRecord(); From dc393fd28b65524b83164d5e1d4bf0f544269ac9 Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Thu, 2 Jan 2025 18:31:52 +0000 Subject: [PATCH 14/15] odb: split row and column in dbGDSARef into separate fields/methods Signed-off-by: Matt Liberty --- src/odb/include/odb/db.h | 8 +++- .../codeGenerator/schema/gds/dbGDSARef.json | 11 +++-- src/odb/src/db/dbGDSARef.cpp | 41 ++++++++++++++++--- src/odb/src/db/dbGDSARef.h | 3 +- src/odb/src/gdsin/gdsin.cpp | 5 +-- src/odb/src/gdsout/gdsout.cpp | 7 ++-- 6 files changed, 57 insertions(+), 18 deletions(-) diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index bf2d747c1d6..53ea8f98d46 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -7460,9 +7460,13 @@ class dbGDSARef : public dbObject dbGDSSTrans getTransform() const; - void set_colRow(const std::pair& colRow); + void setNumRows(int16_t num_rows); - std::pair get_colRow() const; + int16_t getNumRows() const; + + void setNumColumns(int16_t num_columns); + + int16_t getNumColumns() const; // User Code Begin dbGDSARef dbGDSStructure* getStructure() const; diff --git a/src/odb/src/codeGenerator/schema/gds/dbGDSARef.json b/src/odb/src/codeGenerator/schema/gds/dbGDSARef.json index fef1666f796..d129c3c9346 100644 --- a/src/odb/src/codeGenerator/schema/gds/dbGDSARef.json +++ b/src/odb/src/codeGenerator/schema/gds/dbGDSARef.json @@ -25,9 +25,14 @@ "flags":[] }, { - "name":"_colRow", - "type":"std::pair", - "flags":["no-template"] + "name":"_num_rows", + "type":"int16_t", + "default":"1" + }, + { + "name":"_num_columns", + "type":"int16_t", + "default":"1" }, { "name":"_structure", diff --git a/src/odb/src/db/dbGDSARef.cpp b/src/odb/src/db/dbGDSARef.cpp index dff706aafac..8cabe3f9ce8 100644 --- a/src/odb/src/db/dbGDSARef.cpp +++ b/src/odb/src/db/dbGDSARef.cpp @@ -56,6 +56,12 @@ bool _dbGDSARef::operator==(const _dbGDSARef& rhs) const if (_ul != rhs._ul) { return false; } + if (_num_rows != rhs._num_rows) { + return false; + } + if (_num_columns != rhs._num_columns) { + return false; + } if (_structure != rhs._structure) { return false; } @@ -76,6 +82,8 @@ void _dbGDSARef::differences(dbDiff& diff, DIFF_FIELD(_origin); DIFF_FIELD(_lr); DIFF_FIELD(_ul); + DIFF_FIELD(_num_rows); + DIFF_FIELD(_num_columns); DIFF_FIELD(_structure); DIFF_END } @@ -86,6 +94,8 @@ void _dbGDSARef::out(dbDiff& diff, char side, const char* field) const DIFF_OUT_FIELD(_origin); DIFF_OUT_FIELD(_lr); DIFF_OUT_FIELD(_ul); + DIFF_OUT_FIELD(_num_rows); + DIFF_OUT_FIELD(_num_columns); DIFF_OUT_FIELD(_structure); DIFF_END @@ -93,6 +103,8 @@ void _dbGDSARef::out(dbDiff& diff, char side, const char* field) const _dbGDSARef::_dbGDSARef(_dbDatabase* db) { + _num_rows = 1; + _num_columns = 1; } _dbGDSARef::_dbGDSARef(_dbDatabase* db, const _dbGDSARef& r) @@ -100,6 +112,8 @@ _dbGDSARef::_dbGDSARef(_dbDatabase* db, const _dbGDSARef& r) _origin = r._origin; _lr = r._lr; _ul = r._ul; + _num_rows = r._num_rows; + _num_columns = r._num_columns; _structure = r._structure; } @@ -110,7 +124,8 @@ dbIStream& operator>>(dbIStream& stream, _dbGDSARef& obj) stream >> obj._ul; stream >> obj._propattr; stream >> obj._transform; - stream >> obj._colRow; + stream >> obj._num_rows; + stream >> obj._num_columns; stream >> obj._structure; return stream; } @@ -122,7 +137,8 @@ dbOStream& operator<<(dbOStream& stream, const _dbGDSARef& obj) stream << obj._ul; stream << obj._propattr; stream << obj._transform; - stream << obj._colRow; + stream << obj._num_rows; + stream << obj._num_columns; stream << obj._structure; return stream; } @@ -185,17 +201,30 @@ dbGDSSTrans dbGDSARef::getTransform() const return obj->_transform; } -void dbGDSARef::set_colRow(const std::pair& colRow) +void dbGDSARef::setNumRows(int16_t num_rows) +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + + obj->_num_rows = num_rows; +} + +int16_t dbGDSARef::getNumRows() const +{ + _dbGDSARef* obj = (_dbGDSARef*) this; + return obj->_num_rows; +} + +void dbGDSARef::setNumColumns(int16_t num_columns) { _dbGDSARef* obj = (_dbGDSARef*) this; - obj->_colRow = colRow; + obj->_num_columns = num_columns; } -std::pair dbGDSARef::get_colRow() const +int16_t dbGDSARef::getNumColumns() const { _dbGDSARef* obj = (_dbGDSARef*) this; - return obj->_colRow; + return obj->_num_columns; } // User Code Begin dbGDSARefPublicMethods diff --git a/src/odb/src/db/dbGDSARef.h b/src/odb/src/db/dbGDSARef.h index 5258d8c719e..e97c132eb8d 100644 --- a/src/odb/src/db/dbGDSARef.h +++ b/src/odb/src/db/dbGDSARef.h @@ -70,7 +70,8 @@ class _dbGDSARef : public _dbObject Point _ul; std::vector> _propattr; dbGDSSTrans _transform; - std::pair _colRow; + int16_t _num_rows; + int16_t _num_columns; dbId<_dbGDSStructure> _structure; }; dbIStream& operator>>(dbIStream& stream, _dbGDSARef& obj); diff --git a/src/odb/src/gdsin/gdsin.cpp b/src/odb/src/gdsin/gdsin.cpp index eb612dcd5d1..0fc3b0a02d4 100644 --- a/src/odb/src/gdsin/gdsin.cpp +++ b/src/odb/src/gdsin/gdsin.cpp @@ -398,10 +398,9 @@ dbGDSARef* GDSReader::processARef(dbGDSStructure* structure) } if (_r.type == RecordType::COLROW) { - aref->set_colRow({_r.data16[0], _r.data16[1]}); + aref->setNumColumns(_r.data16[0]); + aref->setNumRows(_r.data16[1]); readRecord(); - } else { - aref->set_colRow({1, 1}); } std::vector points = processXY(); diff --git a/src/odb/src/gdsout/gdsout.cpp b/src/odb/src/gdsout/gdsout.cpp index 07ca6cab2b7..b354293e666 100644 --- a/src/odb/src/gdsout/gdsout.cpp +++ b/src/odb/src/gdsout/gdsout.cpp @@ -388,7 +388,6 @@ void GDSWriter::writeSRef(dbGDSSRef* sref) void GDSWriter::writeARef(dbGDSARef* aref) { record_t r; - auto colrow = aref->get_colRow(); r.type = RecordType::AREF; r.dataType = DataType::NO_DATA; writeRecord(r); @@ -403,11 +402,13 @@ void GDSWriter::writeARef(dbGDSARef* aref) writeSTrans(aref->getTransform()); } - if (colrow.first != 1 || colrow.second != 1) { + const int16_t cols = aref->getNumColumns(); + const int16_t rows = aref->getNumRows(); + if (cols != 1 || rows != 1) { record_t r4; r4.type = RecordType::COLROW; r4.dataType = DataType::INT_2; - r4.data16 = {colrow.first, colrow.second}; + r4.data16 = {cols, rows}; writeRecord(r4); } From 90c47d3dfd451ff254491cdf4fbe4b0df29cf452 Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Thu, 2 Jan 2025 18:53:40 +0000 Subject: [PATCH 15/15] odb: in dbGDSPath fix the path_type name Signed-off-by: Matt Liberty --- src/odb/include/odb/db.h | 4 ++-- .../codeGenerator/schema/gds/dbGDSPath.json | 2 +- src/odb/src/db/dbGDSPath.cpp | 22 +++++++++---------- src/odb/src/db/dbGDSPath.h | 2 +- src/odb/src/gdsin/gdsin.cpp | 6 +---- src/odb/src/gdsout/gdsout.cpp | 4 ++-- 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index 53ea8f98d46..e654ab2e49a 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -7543,9 +7543,9 @@ class dbGDSPath : public dbObject int getWidth() const; - void set_pathType(int16_t pathType); + void setPathType(int16_t path_type); - int16_t get_pathType() const; + int16_t getPathType() const; // User Code Begin dbGDSPath const std::vector& getXY(); diff --git a/src/odb/src/codeGenerator/schema/gds/dbGDSPath.json b/src/odb/src/codeGenerator/schema/gds/dbGDSPath.json index d9b553bdfd6..95a420a1ba9 100644 --- a/src/odb/src/codeGenerator/schema/gds/dbGDSPath.json +++ b/src/odb/src/codeGenerator/schema/gds/dbGDSPath.json @@ -31,7 +31,7 @@ "flags":[] }, { - "name":"_pathType", + "name":"_path_type", "type":"int16_t", "default":"0", "flags":[] diff --git a/src/odb/src/db/dbGDSPath.cpp b/src/odb/src/db/dbGDSPath.cpp index 55bb18f6f5c..7e313d783cc 100644 --- a/src/odb/src/db/dbGDSPath.cpp +++ b/src/odb/src/db/dbGDSPath.cpp @@ -54,7 +54,7 @@ bool _dbGDSPath::operator==(const _dbGDSPath& rhs) const if (_width != rhs._width) { return false; } - if (_pathType != rhs._pathType) { + if (_path_type != rhs._path_type) { return false; } @@ -74,7 +74,7 @@ void _dbGDSPath::differences(dbDiff& diff, DIFF_FIELD(_layer); DIFF_FIELD(_datatype); DIFF_FIELD(_width); - DIFF_FIELD(_pathType); + DIFF_FIELD(_path_type); DIFF_END } @@ -84,7 +84,7 @@ void _dbGDSPath::out(dbDiff& diff, char side, const char* field) const DIFF_OUT_FIELD(_layer); DIFF_OUT_FIELD(_datatype); DIFF_OUT_FIELD(_width); - DIFF_OUT_FIELD(_pathType); + DIFF_OUT_FIELD(_path_type); DIFF_END } @@ -94,7 +94,7 @@ _dbGDSPath::_dbGDSPath(_dbDatabase* db) _layer = 0; _datatype = 0; _width = 0; - _pathType = 0; + _path_type = 0; } _dbGDSPath::_dbGDSPath(_dbDatabase* db, const _dbGDSPath& r) @@ -102,7 +102,7 @@ _dbGDSPath::_dbGDSPath(_dbDatabase* db, const _dbGDSPath& r) _layer = r._layer; _datatype = r._datatype; _width = r._width; - _pathType = r._pathType; + _path_type = r._path_type; } dbIStream& operator>>(dbIStream& stream, _dbGDSPath& obj) @@ -112,7 +112,7 @@ dbIStream& operator>>(dbIStream& stream, _dbGDSPath& obj) stream >> obj._xy; stream >> obj._propattr; stream >> obj._width; - stream >> obj._pathType; + stream >> obj._path_type; return stream; } @@ -123,7 +123,7 @@ dbOStream& operator<<(dbOStream& stream, const _dbGDSPath& obj) stream << obj._xy; stream << obj._propattr; stream << obj._width; - stream << obj._pathType; + stream << obj._path_type; return stream; } @@ -185,17 +185,17 @@ int dbGDSPath::getWidth() const return obj->_width; } -void dbGDSPath::set_pathType(int16_t pathType) +void dbGDSPath::setPathType(int16_t path_type) { _dbGDSPath* obj = (_dbGDSPath*) this; - obj->_pathType = pathType; + obj->_path_type = path_type; } -int16_t dbGDSPath::get_pathType() const +int16_t dbGDSPath::getPathType() const { _dbGDSPath* obj = (_dbGDSPath*) this; - return obj->_pathType; + return obj->_path_type; } // User Code Begin dbGDSPathPublicMethods diff --git a/src/odb/src/db/dbGDSPath.h b/src/odb/src/db/dbGDSPath.h index 77168b0e512..34841bf8c64 100644 --- a/src/odb/src/db/dbGDSPath.h +++ b/src/odb/src/db/dbGDSPath.h @@ -64,7 +64,7 @@ class _dbGDSPath : public _dbObject std::vector _xy; std::vector> _propattr; int _width; - int16_t _pathType; + int16_t _path_type; }; dbIStream& operator>>(dbIStream& stream, _dbGDSPath& obj); dbOStream& operator<<(dbOStream& stream, const _dbGDSPath& obj); diff --git a/src/odb/src/gdsin/gdsin.cpp b/src/odb/src/gdsin/gdsin.cpp index 0fc3b0a02d4..a4bf6e41634 100644 --- a/src/odb/src/gdsin/gdsin.cpp +++ b/src/odb/src/gdsin/gdsin.cpp @@ -316,17 +316,13 @@ dbGDSPath* GDSReader::processPath(dbGDSStructure* structure) readRecord(); if (_r.type == RecordType::PATHTYPE) { - path->set_pathType(_r.data16[0]); + path->setPathType(_r.data16[0]); readRecord(); - } else { - path->set_pathType(0); } if (_r.type == RecordType::WIDTH) { path->setWidth(_r.data32[0]); readRecord(); - } else { - path->setWidth(0); } path->setXy(processXY()); diff --git a/src/odb/src/gdsout/gdsout.cpp b/src/odb/src/gdsout/gdsout.cpp index b354293e666..5f7e5e2287a 100644 --- a/src/odb/src/gdsout/gdsout.cpp +++ b/src/odb/src/gdsout/gdsout.cpp @@ -339,11 +339,11 @@ void GDSWriter::writePath(dbGDSPath* path) writeLayer(path->getLayer()); writeDataType(path->getDatatype()); - if (path->get_pathType() != 0) { + if (path->getPathType() != 0) { record_t r2; r2.type = RecordType::PATHTYPE; r2.dataType = DataType::INT_2; - r2.data16 = {path->get_pathType()}; + r2.data16 = {path->getPathType()}; writeRecord(r2); }