Skip to content

Commit

Permalink
gui: const-ify
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Gadfort <[email protected]>
  • Loading branch information
gadfort committed May 5, 2024
1 parent 4e84afe commit d1c745d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
28 changes: 14 additions & 14 deletions src/gui/src/dbDescriptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static odb::dbTechLayer* getLayerSelection(odb::dbTech* tech,
std::vector<Descriptor::EditorOption> options;
addLayersToOptions(tech, options);
QStringList layers;
for (auto& [name, layer] : options) {
for (const auto& [name, layer] : options) {
layers.append(QString::fromStdString(name));
}
bool okay;
Expand Down Expand Up @@ -1391,8 +1391,8 @@ void DbNetDescriptor::highlight(std::any object, Painter& painter) const
auto color = painter.getPenColor();
color.a = 255;
painter.setPen(color, true);
for (auto& driver : driver_locs) {
for (auto& sink : sink_locs) {
for (const auto& driver : driver_locs) {
for (const auto& sink : sink_locs) {
painter.drawLine(driver, sink);
}
}
Expand Down Expand Up @@ -1596,18 +1596,18 @@ bool DbNetDescriptor::getAllObjects(SelectionSet& objects) const
return true;
}

odb::dbNet* DbNetDescriptor::getNet(std::any& object) const
odb::dbNet* DbNetDescriptor::getNet(const std::any& object) const
{
odb::dbNet** net = std::any_cast<odb::dbNet*>(&object);
odb::dbNet* const* net = std::any_cast<odb::dbNet*>(&object);
if (net != nullptr) {
return *net;
}
return std::any_cast<NetWithSink>(object).net;
}

odb::dbObject* DbNetDescriptor::getSink(std::any& object) const
odb::dbObject* DbNetDescriptor::getSink(const std::any& object) const
{
NetWithSink* net_sink = std::any_cast<NetWithSink>(&object);
const NetWithSink* net_sink = std::any_cast<NetWithSink>(&object);
if (net_sink != nullptr) {
return net_sink->sink;
}
Expand Down Expand Up @@ -1679,8 +1679,8 @@ Descriptor::Properties DbITermDescriptor::getProperties(std::any object) const
net_value = "<none>";
}
SelectionSet aps;
for (auto& [mpin, ap_vec] : iterm->getAccessPoints()) {
for (auto ap : ap_vec) {
for (const auto& [mpin, ap_vec] : iterm->getAccessPoints()) {
for (const auto& ap : ap_vec) {
DbTermAccessPoint iap{ap, iterm};
aps.insert(gui->makeSelected(iap));
}
Expand Down Expand Up @@ -3880,26 +3880,26 @@ bool DbSiteDescriptor::getAllObjects(SelectionSet& objects) const
return true;
}

odb::dbSite* DbSiteDescriptor::getSite(std::any& object) const
odb::dbSite* DbSiteDescriptor::getSite(const std::any& object) const
{
odb::dbSite** site = std::any_cast<odb::dbSite*>(&object);
odb::dbSite* const* site = std::any_cast<odb::dbSite*>(&object);
if (site != nullptr) {
return *site;
}
SpecificSite ss = std::any_cast<SpecificSite>(object);
return ss.site;
}

odb::Rect DbSiteDescriptor::getRect(std::any& object) const
odb::Rect DbSiteDescriptor::getRect(const std::any& object) const
{
SpecificSite* ss = std::any_cast<SpecificSite>(&object);
const SpecificSite* ss = std::any_cast<SpecificSite>(&object);
if (ss != nullptr) {
return ss->rect;
}
return odb::Rect();
}

bool DbSiteDescriptor::isSpecificSite(std::any& object) const
bool DbSiteDescriptor::isSpecificSite(const std::any& object) const
{
return std::any_cast<SpecificSite>(&object) != nullptr;
}
Expand Down
10 changes: 5 additions & 5 deletions src/gui/src/dbDescriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ class DbNetDescriptor : public Descriptor
const std::set<odb::dbNet*>& guide_nets_;
const std::set<odb::dbNet*>& tracks_nets_;

odb::dbNet* getNet(std::any& object) const;
odb::dbObject* getSink(std::any& object) const;
odb::dbNet* getNet(const std::any& object) const;
odb::dbObject* getSink(const std::any& object) const;

static const int max_iterms_ = 10000;
};
Expand Down Expand Up @@ -660,9 +660,9 @@ class DbSiteDescriptor : public Descriptor
private:
odb::dbDatabase* db_;

odb::dbSite* getSite(std::any& object) const;
odb::Rect getRect(std::any& object) const;
bool isSpecificSite(std::any& object) const;
odb::dbSite* getSite(const std::any& object) const;
odb::Rect getRect(const std::any& object) const;
bool isSpecificSite(const std::any& object) const;
};

class DbRowDescriptor : public Descriptor
Expand Down
8 changes: 4 additions & 4 deletions src/gui/src/heatMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,10 @@ Renderer::Settings HeatMapDataSource::getSettings() const

for (const auto& setting : settings_) {
if (std::holds_alternative<MapSettingBoolean>(setting)) {
auto& set = std::get<MapSettingBoolean>(setting);
const auto& set = std::get<MapSettingBoolean>(setting);
settings[set.name] = set.getter();
} else if (std::holds_alternative<MapSettingMultiChoice>(setting)) {
auto& set = std::get<MapSettingMultiChoice>(setting);
const auto& set = std::get<MapSettingMultiChoice>(setting);
settings[set.name] = set.getter();
}
}
Expand All @@ -321,12 +321,12 @@ void HeatMapDataSource::setSettings(const Renderer::Settings& settings)

for (const auto& setting : settings_) {
if (std::holds_alternative<MapSettingBoolean>(setting)) {
auto& set = std::get<MapSettingBoolean>(setting);
const auto& set = std::get<MapSettingBoolean>(setting);
bool temp_value = set.getter();
Renderer::setSetting<bool>(settings, set.name, temp_value);
set.setter(temp_value);
} else if (std::holds_alternative<MapSettingMultiChoice>(setting)) {
auto& set = std::get<MapSettingMultiChoice>(setting);
const auto& set = std::get<MapSettingMultiChoice>(setting);
std::string temp_value = set.getter();
Renderer::setSetting<std::string>(settings, set.name, temp_value);
set.setter(temp_value);
Expand Down

0 comments on commit d1c745d

Please sign in to comment.