Skip to content

Commit 5afb39e

Browse files
Merge pull request #8003 from osamahammad21/odb-database-prop
ODB: database prop
2 parents 5fc6951 + 22024ef commit 5afb39e

File tree

12 files changed

+59
-34
lines changed

12 files changed

+59
-34
lines changed

src/gui/src/dbDescriptors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4431,7 +4431,7 @@ Descriptor::Properties DbMarkerCategoryDescriptor::getDBProperties(
44314431
}
44324432

44334433
SelectionSet subcategories;
4434-
for (odb::dbMarkerCategory* subcat : category->getMarkerCategorys()) {
4434+
for (odb::dbMarkerCategory* subcat : category->getMarkerCategories()) {
44354435
subcategories.insert(gui->makeSelected(subcat));
44364436
}
44374437
if (!subcategories.empty()) {

src/gui/src/drcWidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void DRCWidget::updateModel()
253253
model_->removeRows(0, model_->rowCount());
254254

255255
if (category != nullptr) {
256-
for (odb::dbMarkerCategory* subcategory : category->getMarkerCategorys()) {
256+
for (odb::dbMarkerCategory* subcategory : category->getMarkerCategories()) {
257257
populateCategory(subcategory, model_->invisibleRootItem());
258258
}
259259
}
@@ -280,7 +280,7 @@ void DRCWidget::populateCategory(odb::dbMarkerCategory* category,
280280
type_group->setCheckable(true);
281281
type_group->setCheckState(Qt::Checked);
282282

283-
for (odb::dbMarkerCategory* subcategory : category->getMarkerCategorys()) {
283+
for (odb::dbMarkerCategory* subcategory : category->getMarkerCategories()) {
284284
populateCategory(subcategory, type_group);
285285
}
286286

src/odb/include/odb/db.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7029,6 +7029,8 @@ class dbDatabase : public dbObject
70297029

70307030
dbChip* findChip(const char* name) const;
70317031

7032+
dbSet<dbProperty> getProperties() const;
7033+
70327034
// User Code Begin dbDatabase
70337035

70347036
void setTopChip(dbChip* chip);
@@ -7448,7 +7450,7 @@ class dbGDSStructure : public dbObject
74487450
public:
74497451
char* getName() const;
74507452

7451-
dbSet<dbGDSBoundary> getGDSBoundarys() const;
7453+
dbSet<dbGDSBoundary> getGDSBoundaries() const;
74527454

74537455
dbSet<dbGDSBox> getGDSBoxs() const;
74547456

@@ -7849,7 +7851,7 @@ class dbMarkerCategory : public dbObject
78497851

78507852
dbSet<dbMarker> getMarkers() const;
78517853

7852-
dbSet<dbMarkerCategory> getMarkerCategorys() const;
7854+
dbSet<dbMarkerCategory> getMarkerCategories() const;
78537855

78547856
dbMarkerCategory* findMarkerCategory(const char* name) const;
78557857

src/odb/src/codeGenerator/gen.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
components,
1818
get_class,
1919
get_functional_name,
20+
get_plural_name,
2021
get_hash_table_type,
2122
get_ref_type,
2223
get_table_name,
@@ -160,12 +161,12 @@ def add_field_attributes(field, klass, flags_struct, schema):
160161
if field.get("table", False):
161162
klass["hasTables"] = True
162163
if field["type"].startswith("db"):
163-
field["functional_name"] = f"{field['type'][2:]}s"
164+
field["functional_name"] = get_plural_name(field["type"][2:])
164165
else:
165-
field["functional_name"] = f"{field['type']}s"
166+
field["functional_name"] = get_plural_name(field["type"])
166167
field["components"] = [field["name"]]
167168
elif field["isHashTable"]:
168-
field["functional_name"] = f"{field['type'][2:]}s"
169+
field["functional_name"] = get_plural_name(field["type"][2:])
169170
else:
170171
field["functional_name"] = get_functional_name(field["name"])
171172
field["components"] = components(klass["structs"], field["name"], field["type"])

src/odb/src/codeGenerator/helper.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ def is_bit_fields(field, structs):
100100
return False
101101

102102

103+
def get_plural_name(name):
104+
# if name ends with y, replace it with ies
105+
if name.endswith("y"):
106+
return name[:-1] + "ies"
107+
# if name ends with s, add es
108+
elif name.endswith("s"):
109+
return name + "es"
110+
return name + "s"
111+
112+
103113
def get_functional_name(name):
104114
if name.islower():
105115
return "".join(

src/odb/src/codeGenerator/schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,13 @@
380380
"flags": ["no-serial"],
381381
"page_size": 2,
382382
"hash": true
383+
},
384+
{
385+
"parent":"dbDatabase",
386+
"child":"dbProperty",
387+
"type":"1_n",
388+
"tbl_name":"_prop_tbl",
389+
"flags": ["no-serial"]
383390
}
384391
]
385392
}

src/odb/src/db/dbDatabase.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "dbDatabase.h"
66

77
#include "dbChip.h"
8+
#include "dbProperty.h"
89
#include "dbTable.h"
910
#include "dbTable.hpp"
1011
#include "odb/db.h"
@@ -68,6 +69,9 @@ bool _dbDatabase::operator==(const _dbDatabase& rhs) const
6869
if (chip_hash_ != rhs.chip_hash_) {
6970
return false;
7071
}
72+
if (*_prop_tbl != *rhs._prop_tbl) {
73+
return false;
74+
}
7175

7276
// User Code Begin ==
7377
//
@@ -87,10 +91,6 @@ bool _dbDatabase::operator==(const _dbDatabase& rhs) const
8791
return false;
8892
}
8993

90-
if (*_prop_tbl != *rhs._prop_tbl) {
91-
return false;
92-
}
93-
9494
if (*_name_cache != *rhs._name_cache) {
9595
return false;
9696
}
@@ -116,6 +116,8 @@ _dbDatabase::_dbDatabase(_dbDatabase* db)
116116
chip_tbl_ = new dbTable<_dbChip, 2>(
117117
this, this, (GetObjTbl_t) &_dbDatabase::getObjectTable, dbChipObj);
118118
chip_hash_.setTable(chip_tbl_);
119+
_prop_tbl = new dbTable<_dbProperty>(
120+
this, this, (GetObjTbl_t) &_dbDatabase::getObjectTable, dbPropertyObj);
119121
// User Code Begin Constructor
120122
_magic1 = DB_MAGIC1;
121123
_magic2 = DB_MAGIC2;
@@ -134,9 +136,6 @@ _dbDatabase::_dbDatabase(_dbDatabase* db)
134136
_lib_tbl = new dbTable<_dbLib>(
135137
this, this, (GetObjTbl_t) &_dbDatabase::getObjectTable, dbLibObj);
136138

137-
_prop_tbl = new dbTable<_dbProperty>(
138-
this, this, (GetObjTbl_t) &_dbDatabase::getObjectTable, dbPropertyObj);
139-
140139
_name_cache = new _dbNameCache(
141140
this, this, (GetObjTbl_t) &_dbDatabase::getObjectTable);
142141

@@ -255,6 +254,8 @@ dbObjectTable* _dbDatabase::getObjectTable(dbObjectType type)
255254
switch (type) {
256255
case dbChipObj:
257256
return chip_tbl_;
257+
case dbPropertyObj:
258+
return _prop_tbl;
258259
// User Code Begin getObjectTable
259260
case dbTechObj:
260261
return _tech_tbl;
@@ -264,9 +265,6 @@ dbObjectTable* _dbDatabase::getObjectTable(dbObjectType type)
264265

265266
case dbGdsLibObj:
266267
return _gds_lib_tbl;
267-
268-
case dbPropertyObj:
269-
return _prop_tbl;
270268
// User Code End getObjectTable
271269
default:
272270
break;
@@ -280,23 +278,24 @@ void _dbDatabase::collectMemInfo(MemInfo& info)
280278

281279
chip_tbl_->collectMemInfo(info.children_["chip_tbl_"]);
282280

281+
_prop_tbl->collectMemInfo(info.children_["_prop_tbl"]);
282+
283283
// User Code Begin collectMemInfo
284284
_tech_tbl->collectMemInfo(info.children_["tech"]);
285285
_lib_tbl->collectMemInfo(info.children_["lib"]);
286286
_gds_lib_tbl->collectMemInfo(info.children_["gds_lib"]);
287-
_prop_tbl->collectMemInfo(info.children_["prop"]);
288287
_name_cache->collectMemInfo(info.children_["name_cache"]);
289288
// User Code End collectMemInfo
290289
}
291290

292291
_dbDatabase::~_dbDatabase()
293292
{
294293
delete chip_tbl_;
294+
delete _prop_tbl;
295295
// User Code Begin Destructor
296296
delete _tech_tbl;
297297
delete _lib_tbl;
298298
delete _gds_lib_tbl;
299-
delete _prop_tbl;
300299
delete _name_cache;
301300
delete _prop_itr;
302301
// User Code End Destructor
@@ -373,6 +372,12 @@ dbChip* dbDatabase::findChip(const char* name) const
373372
return (dbChip*) obj->chip_hash_.find(name);
374373
}
375374

375+
dbSet<dbProperty> dbDatabase::getProperties() const
376+
{
377+
_dbDatabase* obj = (_dbDatabase*) this;
378+
return dbSet<dbProperty>(obj, obj->_prop_tbl);
379+
}
380+
376381
// User Code Begin dbDatabasePublicMethods
377382

378383
void dbDatabase::setTopChip(dbChip* chip)

src/odb/src/db/dbDatabase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ const uint db_schema_add_global_connect = 58;
225225
class dbIStream;
226226
class dbOStream;
227227
class _dbChip;
228-
// User Code Begin Classes
229228
class _dbProperty;
229+
// User Code Begin Classes
230230
class dbPropertyItr;
231231
class _dbNameCache;
232232
class _dbTech;
@@ -261,12 +261,12 @@ class _dbDatabase : public _dbObject
261261
dbId<_dbChip> _chip;
262262
dbTable<_dbChip, 2>* chip_tbl_;
263263
dbHashTable<_dbChip, 2> chip_hash_;
264+
dbTable<_dbProperty>* _prop_tbl;
264265

265266
// User Code Begin Fields
266267
dbTable<_dbTech, 2>* _tech_tbl;
267268
dbTable<_dbLib>* _lib_tbl;
268269
dbTable<_dbGDSLib, 2>* _gds_lib_tbl;
269-
dbTable<_dbProperty>* _prop_tbl;
270270
_dbNameCache* _name_cache;
271271
dbPropertyItr* _prop_itr;
272272
int _unique_id;

src/odb/src/db/dbGDSStructure.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ char* dbGDSStructure::getName() const
169169
return obj->_name;
170170
}
171171

172-
dbSet<dbGDSBoundary> dbGDSStructure::getGDSBoundarys() const
172+
dbSet<dbGDSBoundary> dbGDSStructure::getGDSBoundaries() const
173173
{
174174
_dbGDSStructure* obj = (_dbGDSStructure*) this;
175175
return dbSet<dbGDSBoundary>(obj, obj->boundaries_);

src/odb/src/db/dbMarkerCategory.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,11 @@ void _dbMarkerCategory::populatePTree(
169169
}
170170

171171
_dbMarkerCategory::PropertyTree subcategory_tree;
172-
for (dbMarkerCategory* category : category->getMarkerCategorys()) {
172+
for (dbMarkerCategory* category : category->getMarkerCategories()) {
173173
_dbMarkerCategory* category_ = (_dbMarkerCategory*) category;
174174
category_->populatePTree(subcategory_tree);
175175
}
176-
if (!category->getMarkerCategorys().empty()) {
176+
if (!category->getMarkerCategories().empty()) {
177177
category_tree.add_child("category", subcategory_tree);
178178
}
179179

@@ -267,7 +267,7 @@ void _dbMarkerCategory::writeTR(std::ofstream& report) const
267267
marker_->writeTR(report);
268268
}
269269

270-
for (dbMarkerCategory* category : marker_category->getMarkerCategorys()) {
270+
for (dbMarkerCategory* category : marker_category->getMarkerCategories()) {
271271
_dbMarkerCategory* category_ = (_dbMarkerCategory*) category;
272272
category_->writeTR(report);
273273
}
@@ -326,7 +326,7 @@ dbSet<dbMarker> dbMarkerCategory::getMarkers() const
326326
return dbSet<dbMarker>(obj, obj->marker_tbl_);
327327
}
328328

329-
dbSet<dbMarkerCategory> dbMarkerCategory::getMarkerCategorys() const
329+
dbSet<dbMarkerCategory> dbMarkerCategory::getMarkerCategories() const
330330
{
331331
_dbMarkerCategory* obj = (_dbMarkerCategory*) this;
332332
return dbSet<dbMarkerCategory>(obj, obj->categories_tbl_);
@@ -345,7 +345,7 @@ int dbMarkerCategory::getMarkerCount() const
345345
_dbMarkerCategory* obj = (_dbMarkerCategory*) this;
346346
int count = obj->marker_tbl_->size();
347347

348-
for (dbMarkerCategory* category : getMarkerCategorys()) {
348+
for (dbMarkerCategory* category : getMarkerCategories()) {
349349
count += category->getMarkerCount();
350350
}
351351

@@ -745,7 +745,7 @@ std::set<dbMarker*> dbMarkerCategory::getAllMarkers() const
745745
{
746746
std::set<dbMarker*> markers;
747747

748-
for (dbMarkerCategory* category : getMarkerCategorys()) {
748+
for (dbMarkerCategory* category : getMarkerCategories()) {
749749
const std::set<dbMarker*> category_markers = category->getAllMarkers();
750750
markers.insert(category_markers.begin(), category_markers.end());
751751
}

0 commit comments

Comments
 (0)