feat(CompositionAbstract): added clone and iterator methods to the CompositionAbstract Interface
This commit is contained in:
2
Doxyfile
2
Doxyfile
@@ -48,7 +48,7 @@ PROJECT_NAME = fourdst::libcomposition
|
|||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
# control system is used.
|
# control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = v2.0.3
|
PROJECT_NUMBER = v2.0.4
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||||
# for a project that appears at the top of each page and should give viewers a
|
# for a project that appears at the top of each page and should give viewers a
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
# *********************************************************************** #
|
# *********************************************************************** #
|
||||||
project('libcomposition', 'cpp', version: 'v2.0.3', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0')
|
project('libcomposition', 'cpp', version: 'v2.0.4', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0')
|
||||||
|
|
||||||
# Add default visibility for all C++ targets
|
# Add default visibility for all C++ targets
|
||||||
add_project_arguments('-fvisibility=default', language: 'cpp')
|
add_project_arguments('-fvisibility=default', language: 'cpp')
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace fourdst::composition {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
// ReSharper disable once CppClassCanBeFinal
|
// ReSharper disable once CppClassCanBeFinal
|
||||||
class Composition : public CompositionAbstract {
|
class Composition final : public CompositionAbstract {
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @struct CompositionCache
|
* @struct CompositionCache
|
||||||
@@ -725,6 +725,8 @@ namespace fourdst::composition {
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] atomic::Species getSpeciesAtIndex(size_t index) const override;
|
[[nodiscard]] atomic::Species getSpeciesAtIndex(size_t index) const override;
|
||||||
|
|
||||||
|
[[nodiscard]] std::unique_ptr<CompositionAbstract> clone() const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Overloaded output stream operator for Composition.
|
* @brief Overloaded output stream operator for Composition.
|
||||||
* @param os The output stream.
|
* @param os The output stream.
|
||||||
@@ -750,7 +752,7 @@ namespace fourdst::composition {
|
|||||||
* for species are defined based on their atomic mass. When iterating over the molar abundance map, species will be
|
* for species are defined based on their atomic mass. When iterating over the molar abundance map, species will be
|
||||||
* seen in order from lightest to heaviest.
|
* seen in order from lightest to heaviest.
|
||||||
*/
|
*/
|
||||||
auto begin() {
|
[[nodiscard]] std::map<atomic::Species, double>::iterator begin() override {
|
||||||
return m_molarAbundances.begin();
|
return m_molarAbundances.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -771,7 +773,7 @@ namespace fourdst::composition {
|
|||||||
* for species are defined based on their atomic mass. When iterating over the molar abundance map, species will be
|
* for species are defined based on their atomic mass. When iterating over the molar abundance map, species will be
|
||||||
* seen in order from lightest to heaviest.
|
* seen in order from lightest to heaviest.
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] auto begin() const {
|
[[nodiscard]] std::map<atomic::Species, double>::const_iterator begin() const override {
|
||||||
return m_molarAbundances.cbegin();
|
return m_molarAbundances.cbegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -792,7 +794,7 @@ namespace fourdst::composition {
|
|||||||
* for species are defined based on their atomic mass. When iterating over the molar abundance map, species will be
|
* for species are defined based on their atomic mass. When iterating over the molar abundance map, species will be
|
||||||
* seen in order from lightest to heaviest.
|
* seen in order from lightest to heaviest.
|
||||||
*/
|
*/
|
||||||
auto end() {
|
[[nodiscard]] std::map<atomic::Species, double>::iterator end() override {
|
||||||
return m_molarAbundances.end();
|
return m_molarAbundances.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -813,7 +815,7 @@ namespace fourdst::composition {
|
|||||||
* for species are defined based on their atomic mass. When iterating over the molar abundance map, species will be
|
* for species are defined based on their atomic mass. When iterating over the molar abundance map, species will be
|
||||||
* seen in order from lightest to heaviest.
|
* seen in order from lightest to heaviest.
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] auto end() const {
|
[[nodiscard]] std::map<atomic::Species, double>::const_iterator end() const override {
|
||||||
return m_molarAbundances.cend();
|
return m_molarAbundances.cend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,14 @@ namespace fourdst::composition {
|
|||||||
* @param index The index of the species.
|
* @param index The index of the species.
|
||||||
* @return The atomic species at the specified index.
|
* @return The atomic species at the specified index.
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] virtual fourdst::atomic::Species getSpeciesAtIndex(size_t index) const = 0;
|
[[nodiscard]] virtual atomic::Species getSpeciesAtIndex(size_t index) const = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual std::unique_ptr<CompositionAbstract> clone() const = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual std::map<atomic::Species, double>::iterator begin() = 0;
|
||||||
|
[[nodiscard]] virtual std::map<atomic::Species, double>::iterator end() = 0;
|
||||||
|
[[nodiscard]] virtual std::map<atomic::Species, double>::const_iterator begin() const = 0;
|
||||||
|
[[nodiscard]] virtual std::map<atomic::Species, double>::const_iterator end() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ReSharper disable once CppClassCanBeFinal
|
// ReSharper disable once CppClassCanBeFinal
|
||||||
@@ -197,6 +204,21 @@ namespace fourdst::composition {
|
|||||||
[[nodiscard]] size_t getSpeciesIndex(const std::string& symbol) const override { return m_base_composition->getSpeciesIndex(symbol); };
|
[[nodiscard]] size_t getSpeciesIndex(const std::string& symbol) const override { return m_base_composition->getSpeciesIndex(symbol); };
|
||||||
[[nodiscard]] size_t getSpeciesIndex(const atomic::Species& species) const override { return m_base_composition->getSpeciesIndex(species); };
|
[[nodiscard]] size_t getSpeciesIndex(const atomic::Species& species) const override { return m_base_composition->getSpeciesIndex(species); };
|
||||||
[[nodiscard]] atomic::Species getSpeciesAtIndex(const size_t index) const override { return m_base_composition->getSpeciesAtIndex(index); };
|
[[nodiscard]] atomic::Species getSpeciesAtIndex(const size_t index) const override { return m_base_composition->getSpeciesAtIndex(index); };
|
||||||
|
[[nodiscard]] std::unique_ptr<CompositionAbstract> clone() const override {
|
||||||
|
return std::make_unique<CompositionDecorator>(m_base_composition->clone());
|
||||||
|
}
|
||||||
|
[[nodiscard]] std::map<atomic::Species, double>::iterator begin() override {
|
||||||
|
return m_base_composition->begin();
|
||||||
|
}
|
||||||
|
[[nodiscard]] std::map<atomic::Species, double>::iterator end() override {
|
||||||
|
return m_base_composition->end();
|
||||||
|
}
|
||||||
|
[[nodiscard]] std::map<atomic::Species, double>::const_iterator begin() const override {
|
||||||
|
return std::as_const(*m_base_composition).begin();
|
||||||
|
}
|
||||||
|
[[nodiscard]] std::map<atomic::Species, double>::const_iterator end() const override {
|
||||||
|
return std::as_const(*m_base_composition).end();
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<CompositionAbstract> m_base_composition;
|
std::unique_ptr<CompositionAbstract> m_base_composition;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -506,6 +506,10 @@ namespace fourdst::composition {
|
|||||||
return sortedSymbols.at(index);
|
return sortedSymbols.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<CompositionAbstract> Composition::clone() const {
|
||||||
|
return std::make_unique<Composition>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
bool Composition::contains(
|
bool Composition::contains(
|
||||||
const atomic::Species &species
|
const atomic::Species &species
|
||||||
) const noexcept {
|
) const noexcept {
|
||||||
|
|||||||
Reference in New Issue
Block a user