12#include "detray/definitions/detail/qualifiers.hpp"
13#include "detray/definitions/indexing.hpp"
18#include <unordered_map>
36 DETRAY_HOST
bool empty()
const {
37 assert(index_to_name.size() == name_to_index.size());
38 return index_to_name.empty();
44 return index_to_name.contains(idx);
49 DETRAY_HOST
bool contains(std::string_view name)
const {
50 return name_to_index.contains(name);
57 index_to_name.try_emplace(idx, name);
58 name_to_index.try_emplace(index_to_name.at(idx), idx);
64 DETRAY_HOST
decltype(
auto)
at(
dindex idx)
const {
65 return index_to_name.at(idx);
71 DETRAY_HOST
decltype(
auto)
at(
dindex idx) {
return index_to_name.at(idx); }
76 DETRAY_HOST
decltype(
auto)
at(
const std::string& name)
const {
77 return name_to_index.at(name);
83 DETRAY_HOST
decltype(
auto)
at(
const std::string_view name)
const {
84 return name_to_index.at(name);
90 index_to_name.clear();
91 name_to_index.clear();
96 index_to_name.clear();
97 name_to_index.clear();
102 std::string detector_name{};
106 std::unordered_map<dindex, std::string> index_to_name{};
107 std::unordered_map<std::string_view, dindex> name_to_index{};
Detray include(s).
Definition array_operators.hpp:18
unsigned int dindex
Default index type.
Definition indexing.hpp:18
Map volume indices to volume names and vice versa.
Definition name_map.hpp:23
decltype(auto) at(dindex idx) const
Returns the name associated with a volume index.
Definition name_map.hpp:64
void set_detector_name(const std::string_view name)
set the name of the detector
Definition name_map.hpp:26
void emplace(dindex idx, const std::string &name)
emplace a new index <-> name mapping
Definition name_map.hpp:56
decltype(auto) at(const std::string_view name) const
Returns the index associated with a volume name.
Definition name_map.hpp:83
const std::string & get_detector_name() const
Definition name_map.hpp:31
decltype(auto) at(dindex idx)
Returns the name associated with a volume index.
Definition name_map.hpp:71
bool contains(std::string_view name) const
Definition name_map.hpp:49
void clear_names()
Clears the volume name mapping, but keeps detector name.
Definition name_map.hpp:95
bool contains(dindex idx) const
Definition name_map.hpp:43
decltype(auto) at(const std::string &name) const
Returns the index associated with a volume name.
Definition name_map.hpp:76
bool empty() const
Definition name_map.hpp:36
void clear()
Clears the name map.
Definition name_map.hpp:88