diff --git a/src/composition/meson.build b/src/composition/meson.build new file mode 100644 index 0000000..456d718 --- /dev/null +++ b/src/composition/meson.build @@ -0,0 +1,32 @@ +# Define the library +composition_sources = files( + 'private/composition.cpp', +) + +composition_headers = files( + 'public/composition.h' +) + +dependencies = [ + probe_dep, + config_dep, + quill_dep, +] + +# Define the libcomposition library so it can be linked against by other parts of the build system +libcomposition = static_library('composition', + composition_sources, + include_directories: include_directories('public'), + cpp_args: ['-fvisibility=default'], + dependencies: dependencies, + install : true) + +composition_dep = declare_dependency( + include_directories: include_directories('public'), + link_with: libcomposition, + dependencies: dependencies, + sources: composition_sources, +) + +# Make headers accessible +install_headers(composition_headers, subdir : '4DSSE/composition') \ No newline at end of file diff --git a/src/composition/private/composition.h b/src/composition/private/composition.h new file mode 100644 index 0000000..b8dc7f3 --- /dev/null +++ b/src/composition/private/composition.h @@ -0,0 +1,36 @@ +#ifndef COMPOSITION_H +#define COMPOSITION_H + +#include +#include +#include +#include +#include + +#include "quill/LogMacros.h + +#include "probe.h" +#include "config.h" + +struct CompositionEntry { + std::string symbol; + std::string mass_fraction; + + friend std::ostream& operator<<(std::ostream& os, const CompositionEntry& entry) { + os << std::setw(5) << "<" << entry.symbol << " : " << entry.mass_fraction << ">"; + return os; + } +}; + +class Composition { +private: + Config& m_config = Config::getInstance(); + Probe::LogManager& m_logManager = Probe::LogManager::getInstance(); + quill::Logger* m_logger = logManager.getLogger('log'); + + std::vector m_registeredSymbols; + std::unordered_map m_compositions; + +} + +#endif // COMPOSITION_H \ No newline at end of file diff --git a/tests/composition/compositionTest.cpp b/tests/composition/compositionTest.cpp new file mode 100644 index 0000000..1336983 --- /dev/null +++ b/tests/composition/compositionTest.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +#include "atomicSpecies.h" + +std::string EXAMPLE_FILENAME = std::string(getenv("MESON_SOURCE_ROOT")) + "/tests/composition/example.yaml"; + +/** + * @brief Test suite for the composition class. + */ +class compositionTest : public ::testing::Test {}; + +/** + * @brief Test the constructor of the composition class. + */ +TEST_F(compositionTest, constructor) { + std::cout << "Testing the constructor of the composition class." << std::endl; + std::cout << chemSpecies::species.at("H-1") << std::endl; +} + diff --git a/tests/composition/meson.build b/tests/composition/meson.build new file mode 100644 index 0000000..a5b6889 --- /dev/null +++ b/tests/composition/meson.build @@ -0,0 +1,23 @@ +# Test files for const +test_sources = [ + 'compositionTest.cpp', +] + +foreach test_file : test_sources + exe_name = test_file.split('.')[0] + message('Building test: ' + exe_name) + + # Create an executable target for each test + test_exe = executable( + exe_name, + test_file, + dependencies: [gtest_dep, species_weight_dep, gtest_main], + install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly + ) + + # Add the executable as a test + test( + exe_name, + test_exe, + env: ['MESON_SOURCE_ROOT=' + meson.project_source_root(), 'MESON_BUILD_ROOT=' + meson.project_build_root()]) +endforeach