.. _program_listing_file_src_elem_IsotopeData.hpp: Program Listing for File IsotopeData.hpp ======================================== |exhale_lsh| :ref:`Return to documentation for file ` (``src/elem/IsotopeData.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #ifndef ISOTOPEDATA_HPP #define ISOTOPEDATA_HPP #include "ElemData.hpp" #include #include #include #include #include namespace elem { struct IsotopeDecayData { unsigned int Z_; // NOLINT(readability-identifier-naming) -- physics naming convention unsigned int A_; // NOLINT(readability-identifier-naming) -- physics naming convention double branchingRatio_; }; class IsotopeData : public ElemData { public: IsotopeData(std::array symbol, unsigned int z, unsigned int a, double lifetime = 0.0, std::vector daughters = {}) : ElemData(symbol, z), A_(a), lifetime_(lifetime), daughters_(std::move(daughters)) { if (lifetime_ < 0.0) { throw std::runtime_error( "IsotopeData: lifetime must be non-negative, got " + std::to_string(lifetime_)); } } IsotopeData(const IsotopeData&) = default; auto operator=(const IsotopeData&) -> IsotopeData& = default; IsotopeData(IsotopeData&&) = default; auto operator=(IsotopeData&&) -> IsotopeData& = default; ~IsotopeData() = default; [[nodiscard]] auto A() const noexcept // NOLINT(readability-identifier-naming) -> unsigned int { return A_; } [[nodiscard]] auto label() const -> std::string { const auto& sym = symbol(); std::string result(1, sym[0]); if (sym[1] != '\0') { result += sym[1]; } result += std::to_string(A_); return result; } [[nodiscard]] auto lifetime() const noexcept -> double { return lifetime_; } [[nodiscard]] auto daughters() const noexcept -> const std::vector& { return daughters_; } [[nodiscard]] auto stable() const noexcept -> bool { return lifetime_ == 0.0; } [[nodiscard]] auto operator==(const IsotopeData& o) const noexcept -> bool { return Z_ == o.Z_ && A_ == o.A_; } [[nodiscard]] auto operator!=(const IsotopeData& o) const noexcept -> bool { return !(*this == o); } [[nodiscard]] auto operator<(const IsotopeData& o) const noexcept -> bool { return Z_ != o.Z_ ? Z_ < o.Z_ : A_ < o.A_; } [[nodiscard]] auto operator>(const IsotopeData& o) const noexcept -> bool { return Z_ != o.Z_ ? Z_ > o.Z_ : A_ > o.A_; } [[nodiscard]] auto operator<=(const IsotopeData& o) const noexcept -> bool { return Z_ != o.Z_ ? Z_ < o.Z_ : A_ <= o.A_; } [[nodiscard]] auto operator>=(const IsotopeData& o) const noexcept -> bool { return Z_ != o.Z_ ? Z_ > o.Z_ : A_ >= o.A_; } protected: unsigned int A_; // NOLINT(readability-identifier-naming) -- physics naming convention double lifetime_; std::vector daughters_; }; } // namespace elem #endif // ISOTOPEDATA_HPP