class EngineGrpcServer

Overview

Abstract class for Engine server with gRPC support. More…

#include <engine_grpc_server.h>

class EngineGrpcServer: public Service {
public:
    // typedefs

    typedef std::timed_mutex mutex_t;
    typedef std::unique_lock<EngineGrpcServer::mutex_t> lock_t;

    // construction

    EngineGrpcServer();

    EngineGrpcServer(
        const std::string serverAddress,
        const std::string& engineName,
        const std::string& protobufPluginsPath,
        const nlohmann::json& protobufPlugins
    );

    // methods

    void startServer();
    void startServerAsync();
    void shutdownServer();
    bool isServerRunning() const;
    const std::string serverAddress() const;

    void registerDataPack(
        const std::string& datapackName,
        ProtoDataPackController* interface
    );

    void registerDataPackNoLock(
        const std::string& datapackName,
        ProtoDataPackController* interface
    );

    unsigned getNumRegisteredDataPacks();
    const std::string& getEngineName();
};

// direct descendants

class NRPGRPCCommunicationController;

Detailed Documentation

Abstract class for Engine server with gRPC support.

The class provides a base for implementing an Engine server with gRPC as middleware. All RPC services are implemented. Derived classes are responsible for implementing simulation initialization, shutdown and run step methods.

Construction

EngineGrpcServer()

No dummy servers, only those with name and url.

EngineGrpcServer(
    const std::string serverAddress,
    const std::string& engineName,
    const std::string& protobufPluginsPath,
    const nlohmann::json& protobufPlugins
)

Constructor.

Parameters:

serverAddress

Address of the gRPC server

engineName

Name of the simulation engine

Methods

void startServer()

Starts the gRPC server in synchronous mode.

void startServerAsync()

Starts the gRPC server in asynchronous mode.

void shutdownServer()

Shutdowns the gRPC server.

bool isServerRunning() const

Indicates whether the gRPC server is currently running.

const std::string serverAddress() const

Returns address of the gRPC server.

void registerDataPack(
    const std::string& datapackName,
    ProtoDataPackController* interface
)

Registers a datapack controller with the given name in the engine.

Parameters:

datapackName

Name of the datapack to be registered

datapackController

Pointer to the datapack controller object that’s supposed to be registered in the engine

const std::string& getEngineName()

Get the Engine name.