coral A C++ library for distributed co-simulation
coral::fmi::Importer Class Reference

Imports and caches FMUs. More...

#include "coral/fmi/importer.hpp"

Inheritance diagram for coral::fmi::Importer:

## Public Member Functions

std::shared_ptr< FMUImport (const boost::filesystem::path &fmuPath)
Imports and loads an FMU. More...

void CleanCache ()
Removes unused files and directories from the FMU cache. More...

std::string LastErrorMessage ()
Returns the last FMI Library error message.

fmi_import_context_t * FmilibHandle () const
Returns a pointer to the underlying FMI Library import context.

## Static Public Member Functions

static std::shared_ptr< ImporterCreate (const boost::filesystem::path &cachePath)
Creates a new FMU importer that uses a specific cache directory. More...

static std::shared_ptr< ImporterCreate ()
Creates a new FMU importer that uses a temporary cache directory. More...

## Detailed Description

Imports and caches FMUs.

The main purpose of this class is to read FMU files and create coral::fmi::FMU objects to represent them. This is done with the Import() function.

An Importer object uses an on-disk cache that holds the unpacked contents of previously imported FMUs, so that they don't need to be unpacked anew every time they are imported. This is a huge time-saver when large and/or many FMUs are loaded. The path to this cache may be supplied by the user, in which case it is not automatically emptied on destruction. Thus, if the same path is supplied each time, the cache becomes persistent between program runs. It may be cleared manually by calling CleanCache().

Warning
Currently there are no synchronisation mechanisms to protect the cache from concurrent use, so accessing the same cache from multiple instances/processes will likely cause problems.

## Member Function Documentation

 void coral::fmi::Importer::CleanCache ( )

Removes unused files and directories from the FMU cache.

This will remove all FMU contents from the cache, except the ones for which there currently exist FMU objects.

 static std::shared_ptr coral::fmi::Importer::Create ( const boost::filesystem::path & cachePath )
static

Creates a new FMU importer that uses a specific cache directory.

The given directory will not be removed nor emptied on destruction.

Parameters
 [in] cachePath The path to the directory which will hold the FMU cache. If it does not exist already, it will be created.
 static std::shared_ptr coral::fmi::Importer::Create ( )
static

Creates a new FMU importer that uses a temporary cache directory.

A new cache directory will be created in a location suitable for temporary files under the conventions of the operating system. It will be completely removed again on destruction.

 std::shared_ptr coral::fmi::Importer::Import ( const boost::filesystem::path & fmuPath )