class EngineClientInterface

Overview

Interface to engines. More…

#include <engine_client_interface.h>

class EngineClientInterface: public PtrTemplates {
public:
    // construction

    EngineClientInterface(ProcessLauncherInterface::unique_ptr&& launcher);

    // methods

    virtual const std::string engineName() const = 0;
    virtual const nlohmann::json& engineConfig() const = 0;
    virtual nlohmann::json& engineConfig() = 0;
    virtual const std::vector<std::string> engineProcStartParams() const = 0;
    virtual pid_t launchEngine();
    virtual void initialize() = 0;
    virtual void reset() = 0;
    virtual void shutdown() = 0;
    virtual SimulationTime getEngineTimestep() const = 0;
    virtual SimulationTime getEngineTime() const = 0;
    virtual const std::string engineSchema() const = 0;
    virtual void runLoopStepAsync(SimulationTime timeStep) = 0;
    virtual void runLoopStepAsyncGet(SimulationTime timeOut) = 0;
    virtual void sendDataPacksToEngine(const datapacks_set_t& dataPacks) = 0;
    virtual datapacks_vector_t getDataPacksFromEngine(const datapack_identifiers_set_t& datapackIdentifiers) = 0;
};

// direct descendants

template <class ENGINE, const char* SCHEMA>
class EngineClient;

Inherited Members

public:
    // typedefs

    typedef std::shared_ptr<T> shared_ptr;
    typedef std::shared_ptr<const T> const_shared_ptr;
    typedef std::unique_ptr<T> unique_ptr;
    typedef std::unique_ptr<const T> const_unique_ptr;

Detailed Documentation

Interface to engines.

Methods

virtual const std::string engineName() const = 0

Get Engine Name.

Returns:

Returns engine name

virtual const nlohmann::json& engineConfig() const = 0

Get engine config data.

virtual nlohmann::json& engineConfig() = 0

Get engine config data.

virtual const std::vector<std::string> engineProcStartParams() const = 0

Get all Engine Process Startup parameters.

virtual pid_t launchEngine()

Launch the engine.

Returns:

Returns engine process ID on success, throws on failure

virtual void initialize() = 0

Initialize engine.

Parameters:

Throws

on error

Returns:

Returns SUCCESS if no error was encountered

virtual void reset() = 0

Reset engine.

Parameters:

Throws

on error

Returns:

Returns SUCCESS if no error was encountered

virtual void shutdown() = 0

Shutdown engine.

Parameters:

Throws

on error

Returns:

Return SUCCESS if no error was encountered

virtual SimulationTime getEngineTimestep() const = 0

Get engine timestep.

Parameters:

Throws

on error

virtual SimulationTime getEngineTime() const = 0

Get current engine time.

Returns:

Returns engine time

virtual const std::string engineSchema() const = 0

Get json schema for this specific engine type.

Parameters:

Throws

on error

Returns:

Returns URI of engine schema

virtual void runLoopStepAsync(SimulationTime timeStep) = 0

Starts a single loop step in a separate thread.

The function should be called in tandem with EngineClientInterface::runLoopStepAsyncGet(), which will join the worker thread and retrieve the results of the loop step.

Parameters:

timeStep

Requested duration of the simulation loop step.

virtual void runLoopStepAsyncGet(SimulationTime timeOut) = 0

Waits and gets the results of the loop step started by EngineClientInterface::runLoopStepAsync()

The function should be called after calling EngineClientInterface::runLoopStepAsync(). It should join the worker thread and retrieve the results of the loop step.

Parameters:

timeOut

Timeout of the loop step. If it’s less or equal to 0, the function will wait indefinitely.

virtual void sendDataPacksToEngine(const datapacks_set_t& dataPacks) = 0

Sends datapacks to engine.

Parameters:

datapacksArray

Array of datapacks that will be send to the engine

Throws

on error

Returns:

Returns SUCCESS if all datapacks could be handles, ERROR otherwise

virtual datapacks_vector_t getDataPacksFromEngine(const datapack_identifiers_set_t& datapackIdentifiers) = 0

Gets requested datapacks from engine.

Parameters:

datapackNames

All requested datapack ids

Throws

on error

Returns:

Returns all requested datapacks