.. _api-getting-started: Getting started =============== Native example -------------- This installed-package example constructs a MAT command, supplies matter inputs, and calls ``execute()`` to obtain a typed result: .. code-block:: cpp #include #include int main() { snt::api::MATSubstance command("H2O"); command.argument_mass_density(snt::puq::Quantity(1.0, "g/cm3")); command.argument_volume(snt::puq::Quantity(1.0, "L")); const auto water = command.execute(); std::cout << water.matter.mass->convert("g").to_string() << "\n"; return 0; } The command facade uses the native MAT implementation and returns independent records. The supplied density and volume determine a mass of 1000 grams. PUQ and DIP command examples are covered in :doc:`workflows`, including their source-checkout header prerequisites. Build and run ------------- Install the C++ package using :doc:`../../installation` with the API and MAT modules enabled (``ENABLE_API=ON`` and ``ENABLE_MAT=ON``). Save the example above as ``main.cpp`` and create this ``CMakeLists.txt`` in the same directory: .. code-block:: cmake cmake_minimum_required(VERSION 3.22) project(snt_api_example LANGUAGES C CXX) find_package(snt CONFIG REQUIRED) add_executable(application main.cpp) target_compile_features(application PRIVATE cxx_std_17) target_link_libraries(application PRIVATE snt-api) Configure with the installed package prefix, build, and run: .. code-block:: console cmake -S . -B build -DCMAKE_PREFIX_PATH=/path/to/snt cmake --build build ./build/application Expected output: .. code-block:: text 1e3*g Replace ``/path/to/snt`` with the installation prefix; omit that option if CMake already finds SNT. C is enabled for discovery of HDF5 in packages built with DIP support. See :ref:`cmake-consumer` for package discovery details. Continue with :doc:`Workflows ` for MAT and DIP commands, or go directly to the detailed :doc:`PUQ commands `, :doc:`MAT commands `, and :doc:`DIP commands ` pages.