Skip to content

Commit 4571b9b

Browse files
committed
gui: implement visitAllObjects
Signed-off-by: LucasYuki <[email protected]>
1 parent 067eb47 commit 4571b9b

File tree

2 files changed

+77
-10
lines changed

2 files changed

+77
-10
lines changed

src/gui/src/dbDescriptors.cpp

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3551,6 +3551,7 @@ Descriptor::Properties DbModuleDescriptor::getDBProperties(
35513551

35523552
Properties props;
35533553
if (mod_inst != nullptr) {
3554+
props.push_back({"ModInst", gui->makeSelected(mod_inst)});
35543555
auto* parent = mod_inst->getParent();
35553556
if (parent != nullptr) {
35563557
props.push_back({"Parent", gui->makeSelected(parent)});
@@ -3562,10 +3563,9 @@ Descriptor::Properties DbModuleDescriptor::getDBProperties(
35623563
}
35633564
}
35643565

3565-
Descriptor::PropertyList children;
3566+
SelectionSet children;
35663567
for (auto* child : module->getChildren()) {
3567-
children.push_back(
3568-
{gui->makeSelected(child->getMaster()), gui->makeSelected(child)});
3568+
children.insert(gui->makeSelected(child->getMaster()));
35693569
}
35703570
if (!children.empty()) {
35713571
props.push_back({"Children", children});
@@ -3721,7 +3721,20 @@ void DbModBTermDescriptor::visitAllObjects(
37213721
return;
37223722
}
37233723

3724-
// getModules(block->getTopModule(), func);
3724+
getModBTerms(block->getTopModule(), func);
3725+
}
3726+
3727+
void DbModBTermDescriptor::getModBTerms(
3728+
odb::dbModule* module,
3729+
const std::function<void(const Selected&)>& func) const
3730+
{
3731+
for (auto* modbterm : module->getModBTerms()) {
3732+
func({modbterm, this});
3733+
}
3734+
3735+
for (auto* mod_inst : module->getChildren()) {
3736+
getModBTerms(mod_inst->getMaster(), func);
3737+
}
37253738
}
37263739

37273740
//////////////////////////////////////////////////
@@ -3795,7 +3808,23 @@ void DbModITermDescriptor::visitAllObjects(
37953808
return;
37963809
}
37973810

3798-
// getModules(block->getTopModule(), func);
3811+
getModITerms(block->getTopModule(), func);
3812+
}
3813+
3814+
void DbModITermDescriptor::getModITerms(
3815+
odb::dbModule* module,
3816+
const std::function<void(const Selected&)>& func) const
3817+
{
3818+
auto mod_inst = module->getModInst();
3819+
if (mod_inst) {
3820+
for (auto* modbterm : mod_inst->getModITerms()) {
3821+
func({modbterm, this});
3822+
}
3823+
}
3824+
3825+
for (auto* mod_inst : module->getChildren()) {
3826+
getModITerms(mod_inst->getMaster(), func);
3827+
}
37993828
}
38003829

38013830
//////////////////////////////////////////////////
@@ -3874,9 +3903,22 @@ void DbModInstDescriptor::visitAllObjects(
38743903
return;
38753904
}
38763905

3877-
// getModules(block->getTopModule(), func);
3906+
getModInsts(block->getTopModule(), func);
38783907
}
38793908

3909+
void DbModInstDescriptor::getModInsts(
3910+
odb::dbModule* module,
3911+
const std::function<void(const Selected&)>& func) const
3912+
{
3913+
auto mod_inst = module->getModInst();
3914+
if (mod_inst) {
3915+
func({mod_inst, this});
3916+
}
3917+
3918+
for (auto* mod_inst : module->getChildren()) {
3919+
getModInsts(mod_inst->getMaster(), func);
3920+
}
3921+
}
38803922
//////////////////////////////////////////////////
38813923

38823924
DbModNetDescriptor::DbModNetDescriptor(odb::dbDatabase* db)
@@ -3961,7 +4003,20 @@ void DbModNetDescriptor::visitAllObjects(
39614003
return;
39624004
}
39634005

3964-
// getModules(block->getTopModule(), func);
4006+
getModNets(block->getTopModule(), func);
4007+
}
4008+
4009+
void DbModNetDescriptor::getModNets(
4010+
odb::dbModule* module,
4011+
const std::function<void(const Selected&)>& func) const
4012+
{
4013+
for (auto* modnet : module->getModNets()) {
4014+
func({modnet, this});
4015+
}
4016+
4017+
for (auto* mod_inst : module->getChildren()) {
4018+
getModNets(mod_inst->getMaster(), func);
4019+
}
39654020
}
39664021

39674022
//////////////////////////////////////////////////

src/gui/src/dbDescriptors.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,9 @@ class DbModBTermDescriptor : public BaseDbDescriptor<odb::dbModBTerm>
556556
protected:
557557
Properties getDBProperties(odb::dbModBTerm* modbterm) const override;
558558

559-
// private:
560-
// void getModules(odb::dbModBTerm* module,
561-
// const std::function<void(const Selected&)>& func) const;
559+
private:
560+
void getModBTerms(odb::dbModule* module,
561+
const std::function<void(const Selected&)>& func) const;
562562
};
563563

564564
class DbModITermDescriptor : public BaseDbDescriptor<odb::dbModITerm>
@@ -578,6 +578,10 @@ class DbModITermDescriptor : public BaseDbDescriptor<odb::dbModITerm>
578578

579579
protected:
580580
Properties getDBProperties(odb::dbModITerm* moditerm) const override;
581+
582+
private:
583+
void getModITerms(odb::dbModule* module,
584+
const std::function<void(const Selected&)>& func) const;
581585
};
582586

583587
class DbModInstDescriptor : public BaseDbDescriptor<odb::dbModInst>
@@ -597,6 +601,10 @@ class DbModInstDescriptor : public BaseDbDescriptor<odb::dbModInst>
597601

598602
protected:
599603
Properties getDBProperties(odb::dbModInst* modinst) const override;
604+
605+
private:
606+
void getModInsts(odb::dbModule* module,
607+
const std::function<void(const Selected&)>& func) const;
600608
};
601609

602610
class DbModNetDescriptor : public BaseDbDescriptor<odb::dbModNet>
@@ -616,6 +624,10 @@ class DbModNetDescriptor : public BaseDbDescriptor<odb::dbModNet>
616624

617625
protected:
618626
Properties getDBProperties(odb::dbModNet* modnet) const override;
627+
628+
private:
629+
void getModNets(odb::dbModule* module,
630+
const std::function<void(const Selected&)>& func) const;
619631
};
620632

621633
class DbTechViaDescriptor : public BaseDbDescriptor<odb::dbTechVia>

0 commit comments

Comments
 (0)