13 #ifndef COSIM_ENDPOINT_H
14 #define COSIM_ENDPOINT_H
69 msg = std::move(
toCosim.front());
96 using Lock = std::lock_guard<std::mutex>;
115 std::string toHostTypeId);
132 const std::function<
void(std::string
id,
const Endpoint &)> &f)
const;
137 using Lock = std::lock_guard<std::mutex>;
The Endpoint registry is where Endpoints report their existence (register) and they are looked up by ...
bool registerEndpoint(std::string epId, std::string fromHostTypeId, std::string toHostTypeId)
Register an Endpoint.
std::mutex m
This object needs to be thread-safe. An object-wide mutex is sufficient.
void iterateEndpoints(const std::function< void(std::string id, const Endpoint &)> &f) const
Iterate over the list of endpoints, calling the provided function for each endpoint.
Endpoint * operator[](const std::string &epId)
Get the specified endpoint.
size_t size() const
Return the number of endpoints.
std::lock_guard< std::mutex > Lock
std::map< std::string, Endpoint > endpoints
Endpoint ID to object pointer mapping.
Implements a bi-directional, thread-safe bridge between the RPC server and DPI functions.
std::unique_ptr< MessageData > MessageDataPtr
Representing messages as shared pointers to vectors may be a performance issue in the future but it i...
std::string getSendTypeId() const
std::queue< MessageDataPtr > toCosim
Message queue from RPC client to the simulation.
bool setInUse()
These two are used to set and unset the inUse flag, to ensure that an open endpoint is not opened aga...
std::string getRecvTypeId() const
void pushMessageToSim(MessageDataPtr msg)
Queue message to the simulation.
void pushMessageToClient(MessageDataPtr msg)
Queue message to the RPC client.
std::lock_guard< std::mutex > Lock
std::queue< MessageDataPtr > toClient
Message queue to RPC client from the simulation.
bool getMessageToClient(MessageDataPtr &msg)
Pop from the to-RPC-client queue.
const std::string fromHostTypeId
const std::string toHostTypeId
std::mutex m
This class needs to be thread-safe.
bool getMessageToSim(MessageDataPtr &msg)
Pop from the to-simulator queue.
Endpoint(const Endpoint &)=delete
Disallow copying.
Endpoint(std::string fromHostTypeId, std::string toHostTypeId)
Construct an endpoint which knows and the type IDs in both directions.