35 template <
typename value_t>
47 throw std::invalid_argument(
"Value identifier must be non-empty");
65 static constexpr
const char*
const kHeaderKey =
"acts-geometry-hierarchy-map";
77 encoded[
"volume"] =
id.volume();
80 encoded[
"boundary"] =
id.boundary();
83 encoded[
"layer"] =
id.layer();
86 encoded[
"approach"] =
id.approach();
89 encoded[
"sensitive"] =
id.sensitive();
106 template <
typename value_t>
111 encoded[kHeaderKey] = {
112 {
"format-version", kFormatVersion},
113 {
"value-identifier", m_valueIdentifier},
117 for (std::size_t i = 0; i < container.
size(); ++i) {
118 auto entry = encodeIdentifier(container.
idAt(i));
122 encoded[kEntriesKey] = std::move(entries);
126 template <
typename value_t>
130 auto header = encoded.
find(kHeaderKey);
131 if (header == encoded.end()) {
132 throw std::invalid_argument(
133 "Missing header entry in json geometry hierarchy map");
135 if (header->at(
"format-version").get<
int>() != kFormatVersion) {
136 throw std::invalid_argument(
137 "Invalid format version in json geometry hierarchy map");
139 if (header->at(
"value-identifier").get<std::string>() != m_valueIdentifier) {
140 throw std::invalid_argument(
141 "Inconsistent value identifier in Json geometry hierarchy map");
144 if (not encoded.contains(kEntriesKey)) {
145 throw std::invalid_argument(
146 "Missing entries in json geometry hierarchy map");
148 std::vector<std::pair<GeometryIdentifier, Value>> elements;
149 for (
const auto& entry : encoded.at(kEntriesKey)) {
150 auto id = decodeIdentifier(entry);
152 elements.emplace_back(std::move(
id), std::move(
value));