Program Listing for File IsotopeTable.hpp
↰ Return to documentation for file (src/elem/IsotopeTable.hpp)
#ifndef ISOTOPETABLE_HPP
#define ISOTOPETABLE_HPP
#include "ElemCommons.hpp"
#include "IsotopeData.hpp"
#include <cstddef>
#include <cstdlib>
#include <exception>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
namespace elem
{
class IsotopeTable
{
public:
explicit IsotopeTable(const std::string& fileName = "data/elem/isotopes.h5");
[[nodiscard]] auto table() const noexcept
-> const std::map<std::pair<unsigned int, unsigned int>, IsotopeData>&
{ return table_; }
[[nodiscard]] auto size() const noexcept -> std::size_t { return table_.size(); }
private:
std::map<std::pair<unsigned int, unsigned int>, IsotopeData> table_;
};
inline auto isotopeTable() -> IsotopeTable&
{
try
{
static IsotopeTable instance;
return instance;
}
catch (const std::exception& error)
{
std::cerr << "FATAL: isotope table initialization failed: "
<< error.what() << "\n";
std::exit(1); // NOLINT(concurrency-mt-unsafe) -- the program is terminating regardless; thread-safety of the shutdown path doesn't matter
}
}
inline auto isotopeTable(unsigned int z, unsigned int a) -> const IsotopeData&
{
return isotopeTable().table().at({z, a});
}
[[nodiscard]] auto effectiveDaughters(const IsotopeData& parent,
const IsotopeList& skippedIsotopes) -> std::vector<IsotopeDecayData>;
} // namespace elem
#endif // ISOTOPETABLE_HPP