coral
A C++ library for distributed co-simulation
|
Imports and caches FMUs. More...
#include "coral/fmi/importer.hpp"
Public Member Functions | |
std::shared_ptr< FMU > | Import (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< Importer > | Create (const boost::filesystem::path &cachePath) |
Creates a new FMU importer that uses a specific cache directory. More... | |
static std::shared_ptr< Importer > | Create () |
Creates a new FMU importer that uses a temporary cache directory. More... | |
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().
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 |
Creates a new FMU importer that uses a specific cache directory.
The given directory will not be removed nor emptied on destruction.
[in] | cachePath | The path to the directory which will hold the FMU cache. If it does not exist already, it will be created. |
|
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<FMU> coral::fmi::Importer::Import | ( | const boost::filesystem::path & | fmuPath | ) |
Imports and loads an FMU.
Loaded FMUs are managed using reference counting. If an FMU is loaded, and then the same FMU is loaded again before the first one has been destroyed, the second call will return a reference to the first one. (Two FMUs are deemed to be the same if they have the same path or the same GUID.)
[in] | fmuPath | The path to the FMU file. |