Warning, file /include/celeritas/ext/detail/AllElementReader.hh was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <map>
0010 #include <vector>
0011
0012 #include "celeritas/io/ImportElement.hh"
0013
0014 namespace celeritas
0015 {
0016 namespace detail
0017 {
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 class AllElementReader
0028 {
0029 public:
0030
0031
0032 using VecElements = std::vector<ImportElement>;
0033
0034
0035 public:
0036
0037 explicit AllElementReader(VecElements const& els) : elements_(els)
0038 {
0039 CELER_EXPECT(!elements_.empty());
0040 }
0041
0042
0043 template<class ReadOneElement>
0044 auto operator()(ReadOneElement&& read_el) const -> decltype(auto)
0045 {
0046 using result_type = typename ReadOneElement::result_type;
0047
0048 std::map<int, result_type> result_map;
0049
0050 for (ImportElement const& element : elements_)
0051 {
0052 AtomicNumber z{element.atomic_number};
0053 CELER_ASSERT(z);
0054 result_map.insert({z.unchecked_get(), read_el(z)});
0055 }
0056 return result_map;
0057 }
0058
0059 private:
0060 std::vector<ImportElement> const& elements_;
0061 };
0062
0063
0064 }
0065 }