Skip to content

jkCXf9X4/ssp4cpp

Repository files navigation

SSP4CPP

SSP4CPP is a C++23 library for reading and analyzing System Structure and Parameterization (SSP) archives. The project provides code for loading .ssp files and parsing system structure information (ssd).

In addition it also parses FMI2 FMU's and the model description for ease of handling

See the SSP standard and FMI standard for more information about the file formats.

Project Structure

The project is organized into the following directories:

  • 3rdParty: Contains third-party libraries and dependencies.
  • lib: Contains the core SSP4CPP library code.
  • resources: Contains toml representations of the bindings to be used as basis for generating the c++ bindings
  • binding_generator: Contains a Python script for generating C++ classes from XML schema definitions.

Library Architecture

  • schema: Contains the C++ classes that represent the SSP schema. These classes are generated from the SSP XML schema definitions using the binding_generator tool. The code is manually generated, inspect the git diff before committing the new representation

The schema component contains the C++ classes that represent the SSP schema. These classes are generated from the SSP XML schema definitions using the binding_generator tool. The generated classes provide a type-safe way to access the data in an SSP file.

It also has some utility functions to extract and work with the SSP, named as extensions. Located within files ending with "_Ext"

Tools

Schema generator

The binding_generator directory contains a Python script for generating C++ classes from XML schema definitions. This is used to create the C++ classes that represent the SSP schema. The script uses the lxml library to parse the XML schema and generate the C++ code.

Generate bindings

python3 -m venv venv
. ./venv/bin/activate
pip install -r requirements.txt

./tools/binding_generator/binding_generator.md

Getting started

  1. Clone the repository and initialize submodules:

    git clone git@github.com:jkCXf9X4/ssp4cpp.git
    git submodule update --init --recursive 
    or
    git clone --recursive git@github.com:jkCXf9X4/ssp4cpp.git
  2. Configure the build using the provided CMake preset (requires vcpkg):

    cmake --preset=vcpkg
  3. Build the project:

    cmake --build build
  4. Release/debug

cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release

Possible dependencies sudo apt install ninja-build

Usage Example

Once the library is installed (either via your build tree or the vcpkg port), you can link against the exported target and load an SSP archive:

find_package(ssp4cpp CONFIG REQUIRED)

add_executable(ssp_demo main.cpp)
target_link_libraries(ssp_demo PRIVATE ssp4cpp::ssp4cpp)
#include <ssp4cpp/ssp.hpp>
#include <iostream>

int main()
{
    // Point to an .ssp file or an unpacked directory
    ssp4cpp::Ssp archive{"./tests/resources/embrace_scen.ssp"};

    std::cout << archive.to_string();

    for (auto *component : archive.resources)
    {
        std::cout << "Component: " << component->name.value_or("<unnamed>") << '\n';
    }

    return 0;
}

Tests

cmake -S . -B build -DSSP4CPP_BUILD_TESTS=ON

cmake --build build && ./build/tests/ssp4cpp_tests
or
ctest --test-dir build --output-on-failure

Contributing

Contributions are welcome! Please open an issue or submit a pull request if you have any improvements or suggestions.

License

This project is released under the MIT license. See LICENCE for details.

Credits

The project is heavily inspired by FMI4cpp. Credit where credit is due.

About

Simple library for parsing System Structure and Parameterization (SSP) files

Resources

License

Stars

Watchers

Forks

Packages

No packages published