18 : fromHostTypeId(fromHostTypeId), toHostTypeId(toHostTypeId), inUse(false) {
33 fprintf(stderr,
"Warning: Returning an endpoint which was not in use.\n");
38 std::string fromHostTypeId,
39 std::string toHostTypeId) {
42 fprintf(stderr,
"Endpoint ID already exists!\n");
47 endpoints.emplace(std::piecewise_construct,
49 std::forward_as_tuple(epId),
51 std::forward_as_tuple(fromHostTypeId, toHostTypeId));
56 const std::function<
void(std::string,
const Endpoint &)> &f)
const {
61 f(ep.first, ep.second);
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.
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.
bool setInUse()
These two are used to set and unset the inUse flag, to ensure that an open endpoint is not opened aga...
std::lock_guard< std::mutex > Lock
std::mutex m
This class needs to be thread-safe.
Endpoint(std::string fromHostTypeId, std::string toHostTypeId)
Construct an endpoint which knows and the type IDs in both directions.