diff --git a/include/opendb/db.h b/include/opendb/db.h index 2d51684..e7ac4fc 100644 --- a/include/opendb/db.h +++ b/include/opendb/db.h @@ -3896,6 +3896,11 @@ class dbTrackGrid : public dbObject /// Translate a database-id back to a pointer. /// static dbTrackGrid* getTrackGrid(dbBlock* block, uint oid); + + /// + /// destroy a grid + /// + static void destroy(dbTrackGrid* grid_); }; /////////////////////////////////////////////////////////////////////////////// diff --git a/src/db/dbTrackGrid.cpp b/src/db/dbTrackGrid.cpp index 81b49f6..f697e92 100644 --- a/src/db/dbTrackGrid.cpp +++ b/src/db/dbTrackGrid.cpp @@ -263,5 +263,12 @@ dbTrackGrid* dbTrackGrid::getTrackGrid(dbBlock* block_, uint dbid_) _dbBlock* block = (_dbBlock*) block_; return (dbTrackGrid*) block->_track_grid_tbl->getPtr(dbid_); } +void dbTrackGrid::destroy(dbTrackGrid* grid_) +{ + _dbTrackGrid* grid = (_dbTrackGrid*) grid_; + _dbBlock* block = (_dbBlock*) grid->getOwner(); + dbProperty::destroyProperties(grid); + block->_track_grid_tbl->destroy(grid); +} } // namespace odb diff --git a/tests/unitTestsPython/TestDestroy.py b/tests/unitTestsPython/TestDestroy.py index 8f09f37..758fa1f 100644 --- a/tests/unitTestsPython/TestDestroy.py +++ b/tests/unitTestsPython/TestDestroy.py @@ -83,10 +83,7 @@ class TestDestroy(odbUnitTest.TestCase): self.assertEqual(len(self.parentBlock.getChildren()), 2) _block.destroy(_block) self.assertEqual(len(self.parentBlock.getChildren()), 1) - #destroying parent block -# _block = helper.create1LevelBlock(self.db, self.db.getLibs()[0], self.parentBlock) - odb.dbBlock_destroy(self.parentBlock) - self.assertIsNone(self.db.getChip().getBlock()) + def test_destroy_bpin(self): IN1 = self.block.findBTerm('IN1') self.assertEqual(len(IN1.getBPins()), 1) @@ -162,7 +159,16 @@ class TestDestroy(odbUnitTest.TestCase): parentRegion, childRegion = self.setup_regions() parentRegion.destroy(parentRegion) self.assertEqual(len(self.block.getRegions()), 0) + + def test_destroy_trackgrid(self): + tech = self.db.getLibs()[0].getTech() + L1 = tech.findLayer("L1") + grid = odb.dbTrackGrid_create(self.block,L1) + self.assertIsNone(odb.dbTrackGrid_create(self.block,L1)) + grid = grid.destroy(grid) + self.assertIsNotNone(odb.dbTrackGrid_create(self.block,L1)) + if __name__=='__main__': odbUnitTest.mainParallel(TestDestroy) # odbUnitTest.main() - \ No newline at end of file +