Skip to content

Commit

Permalink
Merge pull request cyclus#1699 from nuclearkatie/getpackageid
Browse files Browse the repository at this point in the history
  • Loading branch information
gonuke authored Mar 14, 2024
2 parents 998ca06 + 1b1b5aa commit 26f05e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Since last release
* Adds support for Cython3 (#1636)
* Adds TotalInvTracker, which allows an inventory cap to be set for multiple resource buffers, and is now required for material buy policy (#1646)
* AddMutalReqs and AddReciepe functions and exclusive bids in python API of DRE (#1584)
* Created Package class and optional declaration of packages in input files (#1673), package id is a member of resources (materials/products) (#1675)
* Created Package class and optional declaration of packages in input files (#1673, #1699), package id is a member of resources (materials/products) (#1675)
* CI support for Rocky Linux (#1691)

**Changed:**
Expand Down
4 changes: 4 additions & 0 deletions src/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,17 @@ Package::Ptr Context::GetPackageByName(std::string name) {
}

Package::Ptr Context::GetPackageById(int id) {
if (id < 0) {
throw ValueError("Invalid package id " + std::to_string(id));
}
// iterate through the list of packages to get the one package with the correct id
std::map<std::string, Package::Ptr>::iterator it;
for (it = packages_.begin(); it != packages_.end(); ++it) {
if (it->second->id() == id) {
return it->second;
}
}
throw ValueError("Invalid package id " + std::to_string(id));
}

void Context::InitSim(SimInfo si) {
Expand Down

0 comments on commit 26f05e6

Please sign in to comment.