Throw an exception if a shared region is not found
This commit is contained in:
parent
ae805f9ec8
commit
8adbfe06ed
@ -46,33 +46,39 @@ class SharedDataIndex
|
|||||||
|
|
||||||
template <typename T> auto GetBlockPtr(const std::string &name) const
|
template <typename T> auto GetBlockPtr(const std::string &name) const
|
||||||
{
|
{
|
||||||
const auto index_iter = block_to_region.find(name);
|
const auto ®ion = GetBlockRegion(name);
|
||||||
const auto ®ion = regions[index_iter->second];
|
|
||||||
return region.layout.GetBlockPtr<T>(region.memory_ptr, name);
|
return region.layout.GetBlockPtr<T>(region.memory_ptr, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> auto GetBlockPtr(const std::string &name)
|
template <typename T> auto GetBlockPtr(const std::string &name)
|
||||||
{
|
{
|
||||||
const auto index_iter = block_to_region.find(name);
|
const auto ®ion = GetBlockRegion(name);
|
||||||
const auto ®ion = regions[index_iter->second];
|
|
||||||
return region.layout.GetBlockPtr<T>(region.memory_ptr, name);
|
return region.layout.GetBlockPtr<T>(region.memory_ptr, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t GetBlockEntries(const std::string &name) const
|
std::size_t GetBlockEntries(const std::string &name) const
|
||||||
{
|
{
|
||||||
const auto index_iter = block_to_region.find(name);
|
const auto ®ion = GetBlockRegion(name);
|
||||||
const auto ®ion = regions[index_iter->second];
|
|
||||||
return region.layout.GetBlockEntries(name);
|
return region.layout.GetBlockEntries(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t GetBlockSize(const std::string &name) const
|
std::size_t GetBlockSize(const std::string &name) const
|
||||||
{
|
{
|
||||||
const auto index_iter = block_to_region.find(name);
|
const auto ®ion = GetBlockRegion(name);
|
||||||
const auto ®ion = regions[index_iter->second];
|
|
||||||
return region.layout.GetBlockSize(name);
|
return region.layout.GetBlockSize(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const AllocatedRegion &GetBlockRegion(const std::string &name) const
|
||||||
|
{
|
||||||
|
const auto index_iter = block_to_region.find(name);
|
||||||
|
if (index_iter == block_to_region.end())
|
||||||
|
{
|
||||||
|
throw util::exception("data block " + name + " not found " + SOURCE_REF);
|
||||||
|
}
|
||||||
|
return regions[index_iter->second];
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<AllocatedRegion> regions;
|
std::vector<AllocatedRegion> regions;
|
||||||
std::unordered_map<std::string, std::uint32_t> block_to_region;
|
std::unordered_map<std::string, std::uint32_t> block_to_region;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user