CIRCT 22.0.0git
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
esi::backends::cosim::RpcClient Class Reference

A gRPC client for communicating with the cosimulation server. More...

#include <RpcClient.h>

Collaboration diagram for esi::backends::cosim::RpcClient:
Collaboration graph
[legend]

Classes

struct  ChannelDesc
 Description of a channel from the server. More...
 
class  Impl
 
class  ReadChannelConnection
 Abstract handle for a read channel connection. More...
 

Public Types

enum class  ChannelDirection { ToServer , ToClient }
 Channel direction as reported by the server. More...
 
using ReadCallback = std::function< bool(const MessageData &)>
 Callback type for receiving messages from a client-bound channel.
 

Public Member Functions

 RpcClient (const std::string &hostname, uint16_t port)
 
 ~RpcClient ()
 
 RpcClient (const RpcClient &)=delete
 
RpcClientoperator= (const RpcClient &)=delete
 
uint32_t getEsiVersion () const
 Get the ESI version from the manifest.
 
std::vector< uint8_t > getCompressedManifest () const
 Get the compressed manifest from the server.
 
bool getChannelDesc (const std::string &channelName, ChannelDesc &desc) const
 Get the channel description for a channel name.
 
std::vector< ChannelDesclistChannels () const
 List all channels available on the server.
 
void writeToServer (const std::string &channelName, const MessageData &data)
 Send a message to a server-bound channel.
 
std::unique_ptr< ReadChannelConnectionconnectClientReceiver (const std::string &channelName, ReadCallback callback)
 Connect to a client-bound channel and receive messages via callback.
 

Private Attributes

std::unique_ptr< Implimpl
 

Detailed Description

A gRPC client for communicating with the cosimulation server.

This class wraps all gRPC/protobuf dependencies.

Definition at line 36 of file RpcClient.h.

Member Typedef Documentation

◆ ReadCallback

using esi::backends::cosim::RpcClient::ReadCallback = std::function<bool(const MessageData &)>

Callback type for receiving messages from a client-bound channel.

Return true if the message was consumed, false to retry.

Definition at line 73 of file RpcClient.h.

Member Enumeration Documentation

◆ ChannelDirection

Channel direction as reported by the server.

Enumerator
ToServer 
ToClient 

Definition at line 52 of file RpcClient.h.

Constructor & Destructor Documentation

◆ RpcClient() [1/2]

RpcClient::RpcClient ( const std::string &  hostname,
uint16_t  port 
)

Definition at line 204 of file RpcClient.cpp.

◆ ~RpcClient()

RpcClient::~RpcClient ( )
default

◆ RpcClient() [2/2]

esi::backends::cosim::RpcClient::RpcClient ( const RpcClient )
delete

Member Function Documentation

◆ connectClientReceiver()

std::unique_ptr< RpcClient::ReadChannelConnection > RpcClient::connectClientReceiver ( const std::string &  channelName,
ReadCallback  callback 
)

Connect to a client-bound channel and receive messages via callback.

Returns a handle that disconnects when destroyed.

Definition at line 246 of file RpcClient.cpp.

References impl.

◆ getChannelDesc()

bool RpcClient::getChannelDesc ( const std::string &  channelName,
ChannelDesc desc 
) const

Get the channel description for a channel name.

Returns true if the channel was found.

Definition at line 220 of file RpcClient.cpp.

References esi::backends::cosim::RpcClient::ChannelDesc::dir, impl, esi::backends::cosim::RpcClient::ChannelDesc::name, ToClient, ToServer, and esi::backends::cosim::RpcClient::ChannelDesc::type.

◆ getCompressedManifest()

std::vector< uint8_t > RpcClient::getCompressedManifest ( ) const

Get the compressed manifest from the server.

Definition at line 213 of file RpcClient.cpp.

References impl.

◆ getEsiVersion()

uint32_t RpcClient::getEsiVersion ( ) const

Get the ESI version from the manifest.

Definition at line 209 of file RpcClient.cpp.

References impl.

◆ listChannels()

std::vector< RpcClient::ChannelDesc > RpcClient::listChannels ( ) const

List all channels available on the server.

Definition at line 236 of file RpcClient.cpp.

References impl.

◆ operator=()

RpcClient & esi::backends::cosim::RpcClient::operator= ( const RpcClient )
delete

◆ writeToServer()

void RpcClient::writeToServer ( const std::string &  channelName,
const MessageData data 
)

Send a message to a server-bound channel.

Definition at line 240 of file RpcClient.cpp.

References impl.

Member Data Documentation

◆ impl

std::unique_ptr<Impl> esi::backends::cosim::RpcClient::impl
private

The documentation for this class was generated from the following files: