Class CServiceServer

Class Documentation

class CServiceServer

Service Server wrapper class.

Public Functions

ECAL_API_EXPORTED_MEMBER CServiceServer(const std::string &service_name_, const ServerEventCallbackT &event_callback_ = ServerEventCallbackT())

Constructor.

Parameters:
  • service_name_ – Unique service name.

  • event_callback_ – Callback function for server events.

virtual ECAL_API_EXPORTED_MEMBER ~CServiceServer()

Destructor.

CServiceServer(const CServiceServer&) = delete

CServiceServer are non-copyable.

CServiceServer &operator=(const CServiceServer&) = delete

CServiceServer are non-copyable.

ECAL_API_EXPORTED_MEMBER CServiceServer(CServiceServer &&rhs) noexcept

CServiceServer are move-enabled.

ECAL_API_EXPORTED_MEMBER CServiceServer & operator= (CServiceServer &&rhs) noexcept

CServiceServer are move-enabled.

ECAL_API_EXPORTED_MEMBER bool SetMethodCallback (const SServiceMethodInformation &method_info_, const ServiceMethodCallbackT &callback_)

Set/overwrite a method callback, that will be invoked, when a connected client is making a service call.

Parameters:
  • method_info_ – Service method information (method name, request & response types).

  • callback_ – Callback function for client request.

Returns:

True if succeeded, false if not.

ECAL_API_EXPORTED_MEMBER bool RemoveMethodCallback (const std::string &method_)

Remove method callback.

Parameters:

method_ – Service method name.

Returns:

True if succeeded, false if not.

ECAL_API_EXPORTED_MEMBER const std::string & GetServiceName ()

Retrieve service name.

Returns:

The service name.

ECAL_API_EXPORTED_MEMBER const SServiceId & GetServiceId () const

Retrieve the service id.

Returns:

The service id.

ECAL_API_EXPORTED_MEMBER bool IsConnected ()

Check connection state.

Returns:

True if succeeded, false if not.

ECAL_API_EXPORTED_MEMBER CServiceServer()

Constructor.

explicit ECAL_API_EXPORTED_MEMBER CServiceServer(const std::string &service_name_)

Constructor.

Parameters:

service_name_ – Unique service name.

virtual ECAL_API_EXPORTED_MEMBER ~CServiceServer()

Destructor.

CServiceServer(const CServiceServer&) = delete

CServiceServers are non-copyable.

CServiceServer &operator=(const CServiceServer&) = delete

CServiceServers are non-copyable.

ECAL_API_EXPORTED_MEMBER bool Create (const std::string &service_name_)

Creates this object.

Parameters:

service_name_ – Unique service name.

Returns:

True if successful.

ECAL_API_EXPORTED_MEMBER bool Destroy ()

Destroys this object.

Returns:

True if successful.

ECAL_API_EXPORTED_MEMBER bool AddDescription (const std::string &method_, const std::string &req_type_, const std::string &req_desc_, const std::string &resp_type_, const std::string &resp_desc_)

Add method type descriptions.

Parameters:
  • method_ – Service method name.

  • req_type_ – Service method request type.

  • req_desc_ – Service method request description.

  • resp_type_ – Service method response type.

  • resp_desc_ – Service method response description.

Returns:

True if successful.

ECAL_API_EXPORTED_MEMBER bool AddMethodCallback (const std::string &method_, const std::string &req_type_, const std::string &resp_type_, const MethodCallbackT &callback_)

Add method callback.

Parameters:
  • method_ – Service method name.

  • req_type_ – Service method request type.

  • resp_type_ – Service method response type.

  • callback_ – Callback function for client request.

Returns:

True if successful.

ECAL_API_EXPORTED_MEMBER bool RemMethodCallback (const std::string &method_)

Remove method callback.

Parameters:

method_ – Service method name.

Returns:

True if successful.

ECAL_API_EXPORTED_MEMBER bool AddEventCallback (eServerEvent type_, ServerEventCallbackT callback_)

Add server event callback function.

Parameters:
  • type_ – The event type to react on.

  • callback_ – The callback function to add.

Returns:

True if succeeded, false if not.

ECAL_API_EXPORTED_MEMBER bool RemEventCallback (eServerEvent type_)

Remove server event callback function.

Parameters:

type_ – The event type to remove.

Returns:

True if succeeded, false if not.

ECAL_API_EXPORTED_MEMBER std::string GetServiceName ()

Retrieve service name.

Returns:

The service name.

ECAL_API_EXPORTED_MEMBER bool IsConnected ()

Check connection state.

Returns:

True if connected, false if not.