Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
mvsim::Server Class Reference

#include <Server.h>

Inheritance diagram for mvsim::Server:
Inheritance graph
[legend]

Classes

struct  InfoPerNode
 
struct  InfoPerPublisher
 
struct  InfoPerService
 
struct  InfoPerSubscriber
 
struct  InfoPerTopic
 

Public Member Functions

unsigned int listenningPort () const
 
void listenningPort (unsigned int port)
 
 Server ()
 
 ~Server ()
 
Main mvsim Server API
void start ()
 
void shutdown () noexcept
 

Private Member Functions

void internalServerThread ()
 
void requestMainThreadTermination ()
 

Private Attributes

std::thread mainThread_
 
std::atomic< zmq::context_t * > mainThreadZMQcontext_ = nullptr
 
unsigned int serverPortNo_ = MVSIM_PORTNO_MAIN_REP
 

Database (db_*) about connected nodes, topics, etc.

using node_name_t = std::string
 
using endpoint_t = std::string
 
using topic_name_t = std::string
 
using service_name_t = std::string
 
std::shared_mutex dbMutex
 
std::map< node_name_t, InfoPerNodeconnectedNodes_
 
std::map< topic_name_t, InfoPerTopicknownTopics_
 
std::map< service_name_t, InfoPerServiceknownServices_
 
void db_remove_node (const std::string &nodeName)
 
void db_register_node (const std::string &nodeName)
 
void db_advertise_topic (const std::string &topicName, const std::string &topicTypeName, const std::string &publisherEndpoint, const std::string &nodeName)
 
void db_advertise_service (const std::string &serviceName, const std::string &inputTypeName, const std::string &outputTypeName, const std::string &publisherEndpoint, const std::string &nodeName)
 
bool db_get_service_info (const std::string &serviceName, std::string &publisherEndpoint, std::string &nodeName) const
 
void db_add_topic_subscriber (const std::string &topicName, const std::string &updatesEndPoint)
 

Detailed Description

This class creates a parallel thread and listens for incoming connections from clients. This is the main hub for advertising and subscribing to topics. Users should instance a class mvsim::Client (C++) or mvsim.Client (Python) to interface with this server.

Usage:

Messages and topics are described as Protobuf messages, and communications are done via ZMQ sockets.

See: https://mvsimulator.readthedocs.io/

Definition at line 60 of file Server.h.

Member Typedef Documentation

Definition at line 145 of file Server.h.

Definition at line 142 of file Server.h.

Definition at line 209 of file Server.h.

Definition at line 189 of file Server.h.

Constructor & Destructor Documentation

Server::Server ( )

Definition at line 37 of file Server.cpp.

Server::~Server ( )

Definition at line 39 of file Server.cpp.

Member Function Documentation

void Server::db_add_topic_subscriber ( const std::string topicName,
const std::string updatesEndPoint 
)
private

Definition at line 232 of file Server.cpp.

void Server::db_advertise_service ( const std::string serviceName,
const std::string inputTypeName,
const std::string outputTypeName,
const std::string publisherEndpoint,
const std::string nodeName 
)
private

Adds a new offer for a service

Definition at line 268 of file Server.cpp.

void Server::db_advertise_topic ( const std::string topicName,
const std::string topicTypeName,
const std::string publisherEndpoint,
const std::string nodeName 
)
private

Adds a new publisher for a given topic

Definition at line 201 of file Server.cpp.

bool Server::db_get_service_info ( const std::string serviceName,
std::string publisherEndpoint,
std::string nodeName 
) const
private
Returns
true on success

Definition at line 296 of file Server.cpp.

void Server::db_register_node ( const std::string nodeName)
private

Adds the given node

Definition at line 192 of file Server.cpp.

void Server::db_remove_node ( const std::string nodeName)
private

Remove all references to a given node name

Definition at line 173 of file Server.cpp.

void Server::internalServerThread ( )
private

Definition at line 77 of file Server.cpp.

unsigned int mvsim::Server::listenningPort ( ) const
inline

Definition at line 76 of file Server.h.

void mvsim::Server::listenningPort ( unsigned int  port)
inline

Definition at line 77 of file Server.h.

void Server::requestMainThreadTermination ( )
private

Definition at line 157 of file Server.cpp.

void Server::shutdown ( )
noexcept

Shutdowns the server. Blocks until the thread is stopped. There is no need to manually call this method, it is called upon destruction.

Definition at line 59 of file Server.cpp.

void Server::start ( )

Launches the server in a parallel thread and returns immediately.

Definition at line 41 of file Server.cpp.

Member Data Documentation

std::map<node_name_t, InfoPerNode> mvsim::Server::connectedNodes_
private

Definition at line 143 of file Server.h.

std::shared_mutex mvsim::Server::dbMutex
mutableprivate

Adquired by all db_* functions; must be locked whenever any of the variables in this block is read/write.

Definition at line 103 of file Server.h.

std::map<service_name_t, InfoPerService> mvsim::Server::knownServices_
private

Definition at line 210 of file Server.h.

std::map<topic_name_t, InfoPerTopic> mvsim::Server::knownTopics_
private

Definition at line 190 of file Server.h.

std::thread mvsim::Server::mainThread_
private

Definition at line 80 of file Server.h.

std::atomic<zmq::context_t*> mvsim::Server::mainThreadZMQcontext_ = nullptr
private

Definition at line 81 of file Server.h.

unsigned int mvsim::Server::serverPortNo_ = MVSIM_PORTNO_MAIN_REP
private

Definition at line 214 of file Server.h.


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


mvsim
Author(s):
autogenerated on Fri May 7 2021 03:05:52