fix(CompositionAbstract): Moved CompositionAbstract into correct namespace
Further, added the composition_abstract header file to the correct install path
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
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = v2.0.1
|
||||
PROJECT_NUMBER = v2.0.2
|
||||
|
||||
# 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
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
# *********************************************************************** #
|
||||
project('libcomposition', 'cpp', version: 'v2.0.1', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0')
|
||||
project('libcomposition', 'cpp', version: 'v2.0.2', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0')
|
||||
|
||||
# Add default visibility for all C++ targets
|
||||
add_project_arguments('-fvisibility=default', language: 'cpp')
|
||||
|
||||
@@ -7,166 +7,168 @@
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* @brief Abstract base class for chemical composition representations.
|
||||
*
|
||||
* The purpose of this class is to define a standard interface for all composition types.
|
||||
* Children of this class are responsible for implementing the setter methods, but any
|
||||
* object that is a child of CompositionAbstract will always have these getter methods.
|
||||
*
|
||||
* This ensures that all derived composition classes provide a consistent API for querying
|
||||
* composition properties, regardless of how the data is set or stored.
|
||||
*
|
||||
* @par Example
|
||||
* @code
|
||||
* class MyComposition : public CompositionAbstract {
|
||||
* // ...implement all pure virtual methods...
|
||||
* };
|
||||
*
|
||||
* MyComposition comp;
|
||||
* if (comp.hasSymbol("H")) {
|
||||
* double mf = comp.getMassFraction("H");
|
||||
* }
|
||||
* std::set<std::string> symbols = comp.getRegisteredSymbols();
|
||||
* @endcode
|
||||
*/
|
||||
class CompositionAbstract {
|
||||
public:
|
||||
namespace fourdst::composition {
|
||||
/**
|
||||
* @brief Virtual destructor.
|
||||
* @brief Abstract base class for chemical composition representations.
|
||||
*
|
||||
* The purpose of this class is to define a standard interface for all composition types.
|
||||
* Children of this class are responsible for implementing the setter methods, but any
|
||||
* object that is a child of CompositionAbstract will always have these getter methods.
|
||||
*
|
||||
* This ensures that all derived composition classes provide a consistent API for querying
|
||||
* composition properties, regardless of how the data is set or stored.
|
||||
*
|
||||
* @par Example
|
||||
* @code
|
||||
* class MyComposition : public CompositionAbstract {
|
||||
* // ...implement all pure virtual methods...
|
||||
* };
|
||||
*
|
||||
* MyComposition comp;
|
||||
* if (comp.hasSymbol("H")) {
|
||||
* double mf = comp.getMassFraction("H");
|
||||
* }
|
||||
* std::set<std::string> symbols = comp.getRegisteredSymbols();
|
||||
* @endcode
|
||||
*/
|
||||
virtual ~CompositionAbstract() = default;
|
||||
class CompositionAbstract {
|
||||
public:
|
||||
/**
|
||||
* @brief Virtual destructor.
|
||||
*/
|
||||
virtual ~CompositionAbstract() = default;
|
||||
|
||||
/**
|
||||
* @brief Check if the composition contains the given species.
|
||||
* @param species The atomic species to check.
|
||||
* @return True if the species is contained, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] virtual bool contains(const fourdst::atomic::Species& species) const noexcept = 0;
|
||||
/**
|
||||
* @brief Check if the composition contains the given species.
|
||||
* @param species The atomic species to check.
|
||||
* @return True if the species is contained, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] virtual bool contains(const fourdst::atomic::Species& species) const noexcept = 0;
|
||||
|
||||
/**
|
||||
* @brief Check if the composition contains the given species.
|
||||
* @param symbol The symbol of the atomic species to check.
|
||||
* @return True if the species is contained, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] virtual bool contains(const std::string& symbol) const = 0;
|
||||
/**
|
||||
* @brief Check if the composition contains the given species.
|
||||
* @param symbol The symbol of the atomic species to check.
|
||||
* @return True if the species is contained, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] virtual bool contains(const std::string& symbol) const = 0;
|
||||
|
||||
[[nodiscard]] virtual size_t size() const noexcept = 0;
|
||||
[[nodiscard]] virtual size_t size() const noexcept = 0;
|
||||
|
||||
/**
|
||||
* @brief Get all registered chemical symbols in the composition.
|
||||
* @return A set of registered chemical symbols.
|
||||
*/
|
||||
[[nodiscard]] virtual std::set<std::string> getRegisteredSymbols() const noexcept = 0;
|
||||
/**
|
||||
* @brief Get all registered chemical symbols in the composition.
|
||||
* @return A set of registered chemical symbols.
|
||||
*/
|
||||
[[nodiscard]] virtual std::set<std::string> getRegisteredSymbols() const noexcept = 0;
|
||||
|
||||
/**
|
||||
* @brief Get all registered atomic species in the composition.
|
||||
* @return A set of registered atomic species.
|
||||
*/
|
||||
[[nodiscard]] virtual const std::set<fourdst::atomic::Species> &getRegisteredSpecies() const noexcept = 0;
|
||||
/**
|
||||
* @brief Get all registered atomic species in the composition.
|
||||
* @return A set of registered atomic species.
|
||||
*/
|
||||
[[nodiscard]] virtual const std::set<fourdst::atomic::Species> &getRegisteredSpecies() const noexcept = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the mass fraction for all registered symbols.
|
||||
* @return An unordered map from symbol to mass fraction.
|
||||
*/
|
||||
[[nodiscard]] virtual std::unordered_map<fourdst::atomic::Species, double> getMassFraction() const noexcept = 0;
|
||||
/**
|
||||
* @brief Get the mass fraction for all registered symbols.
|
||||
* @return An unordered map from symbol to mass fraction.
|
||||
*/
|
||||
[[nodiscard]] virtual std::unordered_map<fourdst::atomic::Species, double> getMassFraction() const noexcept = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the number fraction for all registered symbols.
|
||||
* @return An unordered map from symbol to number fraction.
|
||||
*/
|
||||
[[nodiscard]] virtual std::unordered_map<fourdst::atomic::Species, double> getNumberFraction() const noexcept = 0;
|
||||
/**
|
||||
* @brief Get the number fraction for all registered symbols.
|
||||
* @return An unordered map from symbol to number fraction.
|
||||
*/
|
||||
[[nodiscard]] virtual std::unordered_map<fourdst::atomic::Species, double> getNumberFraction() const noexcept = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the mass fraction for a given symbol.
|
||||
* @param symbol The chemical symbol.
|
||||
* @return The mass fraction for the symbol.
|
||||
*/
|
||||
[[nodiscard]] virtual double getMassFraction(const std::string& symbol) const = 0;
|
||||
/**
|
||||
* @brief Get the mass fraction for a given symbol.
|
||||
* @param symbol The chemical symbol.
|
||||
* @return The mass fraction for the symbol.
|
||||
*/
|
||||
[[nodiscard]] virtual double getMassFraction(const std::string& symbol) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the mass fraction for a given species.
|
||||
* @param species The atomic species.
|
||||
* @return The mass fraction for the species.
|
||||
*/
|
||||
[[nodiscard]] virtual double getMassFraction(const fourdst::atomic::Species& species) const = 0;
|
||||
/**
|
||||
* @brief Get the mass fraction for a given species.
|
||||
* @param species The atomic species.
|
||||
* @return The mass fraction for the species.
|
||||
*/
|
||||
[[nodiscard]] virtual double getMassFraction(const fourdst::atomic::Species& species) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the number fraction for a given symbol.
|
||||
* @param symbol The chemical symbol.
|
||||
* @return The number fraction for the symbol.
|
||||
*/
|
||||
[[nodiscard]] virtual double getNumberFraction(const std::string& symbol) const = 0;
|
||||
/**
|
||||
* @brief Get the number fraction for a given symbol.
|
||||
* @param symbol The chemical symbol.
|
||||
* @return The number fraction for the symbol.
|
||||
*/
|
||||
[[nodiscard]] virtual double getNumberFraction(const std::string& symbol) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the number fraction for a given species.
|
||||
* @param species The atomic species.
|
||||
* @return The number fraction for the species.
|
||||
*/
|
||||
[[nodiscard]] virtual double getNumberFraction(const fourdst::atomic::Species& species) const = 0;
|
||||
/**
|
||||
* @brief Get the number fraction for a given species.
|
||||
* @param species The atomic species.
|
||||
* @return The number fraction for the species.
|
||||
*/
|
||||
[[nodiscard]] virtual double getNumberFraction(const fourdst::atomic::Species& species) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the molar abundance for a given symbol.
|
||||
* @param symbol The chemical symbol.
|
||||
* @return The molar abundance for the symbol.
|
||||
*/
|
||||
[[nodiscard]] virtual double getMolarAbundance(const std::string& symbol) const = 0;
|
||||
/**
|
||||
* @brief Get the molar abundance for a given symbol.
|
||||
* @param symbol The chemical symbol.
|
||||
* @return The molar abundance for the symbol.
|
||||
*/
|
||||
[[nodiscard]] virtual double getMolarAbundance(const std::string& symbol) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the molar abundance for a given species.
|
||||
* @param species The atomic species.
|
||||
* @return The molar abundance for the species.
|
||||
*/
|
||||
[[nodiscard]] virtual double getMolarAbundance(const fourdst::atomic::Species& species) const = 0;
|
||||
/**
|
||||
* @brief Get the molar abundance for a given species.
|
||||
* @param species The atomic species.
|
||||
* @return The molar abundance for the species.
|
||||
*/
|
||||
[[nodiscard]] virtual double getMolarAbundance(const fourdst::atomic::Species& species) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the mean particle mass of the composition.
|
||||
* @return The mean particle mass.
|
||||
*/
|
||||
[[nodiscard]] virtual double getMeanParticleMass() const noexcept = 0;
|
||||
/**
|
||||
* @brief Get the mean particle mass of the composition.
|
||||
* @return The mean particle mass.
|
||||
*/
|
||||
[[nodiscard]] virtual double getMeanParticleMass() const noexcept = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the electron abundance of the composition.
|
||||
* @return The electron abundance.
|
||||
*/
|
||||
[[nodiscard]] virtual double getElectronAbundance() const noexcept = 0;
|
||||
/**
|
||||
* @brief Get the electron abundance of the composition.
|
||||
* @return The electron abundance.
|
||||
*/
|
||||
[[nodiscard]] virtual double getElectronAbundance() const noexcept = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the mass fraction as a vector.
|
||||
* @return A vector of mass fractions for all species.
|
||||
*/
|
||||
[[nodiscard]] virtual std::vector<double> getMassFractionVector() const noexcept = 0;
|
||||
/**
|
||||
* @brief Get the mass fraction as a vector.
|
||||
* @return A vector of mass fractions for all species.
|
||||
*/
|
||||
[[nodiscard]] virtual std::vector<double> getMassFractionVector() const noexcept = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the number fraction as a vector.
|
||||
* @return A vector of number fractions for all species.
|
||||
*/
|
||||
[[nodiscard]] virtual std::vector<double> getNumberFractionVector() const noexcept = 0;
|
||||
/**
|
||||
* @brief Get the number fraction as a vector.
|
||||
* @return A vector of number fractions for all species.
|
||||
*/
|
||||
[[nodiscard]] virtual std::vector<double> getNumberFractionVector() const noexcept = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the molar abundance as a vector.
|
||||
* @return A vector of molar abundances for all species.
|
||||
*/
|
||||
[[nodiscard]] virtual std::vector<double> getMolarAbundanceVector() const noexcept = 0;
|
||||
/**
|
||||
* @brief Get the molar abundance as a vector.
|
||||
* @return A vector of molar abundances for all species.
|
||||
*/
|
||||
[[nodiscard]] virtual std::vector<double> getMolarAbundanceVector() const noexcept = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the index of a species by symbol.
|
||||
* @param symbol The chemical symbol.
|
||||
* @return The index of the species.
|
||||
*/
|
||||
[[nodiscard]] virtual size_t getSpeciesIndex(const std::string& symbol) const = 0;
|
||||
/**
|
||||
* @brief Get the index of a species by symbol.
|
||||
* @param symbol The chemical symbol.
|
||||
* @return The index of the species.
|
||||
*/
|
||||
[[nodiscard]] virtual size_t getSpeciesIndex(const std::string& symbol) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the index of a species.
|
||||
* @param species The atomic species.
|
||||
* @return The index of the species.
|
||||
*/
|
||||
[[nodiscard]] virtual size_t getSpeciesIndex(const fourdst::atomic::Species& species) const = 0;
|
||||
/**
|
||||
* @brief Get the index of a species.
|
||||
* @param species The atomic species.
|
||||
* @return The index of the species.
|
||||
*/
|
||||
[[nodiscard]] virtual size_t getSpeciesIndex(const fourdst::atomic::Species& species) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the species at a given index.
|
||||
* @param index The index of the species.
|
||||
* @return The atomic species at the specified index.
|
||||
*/
|
||||
[[nodiscard]] virtual fourdst::atomic::Species getSpeciesAtIndex(size_t index) const = 0;
|
||||
};
|
||||
/**
|
||||
* @brief Get the species at a given index.
|
||||
* @param index The index of the species.
|
||||
* @return The atomic species at the specified index.
|
||||
*/
|
||||
[[nodiscard]] virtual fourdst::atomic::Species getSpeciesAtIndex(size_t index) const = 0;
|
||||
};
|
||||
}
|
||||
@@ -48,6 +48,7 @@ composition_dep = declare_dependency(
|
||||
# Make headers accessible
|
||||
composition_headers = files(
|
||||
'include/fourdst/composition/composition.h',
|
||||
'include/fourdst/composition/composition_abstract.h'
|
||||
)
|
||||
install_headers(composition_headers, subdir : 'fourdst/fourdst/composition')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user