Class CServiceClient
Defined in File client.h
Class Documentation
-
class CServiceClient
Service client wrapper class.
Public Functions
-
ECAL_API_EXPORTED_MEMBER CServiceClient(const std::string &service_name_, const ServiceMethodInformationSetT &method_information_set_ = ServiceMethodInformationSetT(), const ClientEventCallbackT &event_callback_ = ClientEventCallbackT())
Constructor.
- Parameters:
service_name_ – Unique service name.
method_information_set_ – Set of method names and corresponding datatype information.
event_callback_ – The client event callback funtion.
-
virtual ECAL_API_EXPORTED_MEMBER ~CServiceClient()
Destructor.
-
CServiceClient(const CServiceClient&) = delete
CServiceClient are non-copyable.
-
CServiceClient &operator=(const CServiceClient&) = delete
CServiceClient are non-copyable.
-
ECAL_API_EXPORTED_MEMBER CServiceClient(CServiceClient &&rhs) noexcept
CServiceClient are move-enabled.
- ECAL_API_EXPORTED_MEMBER CServiceClient & operator= (CServiceClient &&rhs) noexcept
CServiceClient are move-enabled.
- ECAL_API_EXPORTED_MEMBER std::vector< CClientInstance > GetClientInstances () const
Get the client instances for all matching services.
- Returns:
Vector of client instances
- ECAL_API_EXPORTED_MEMBER bool CallWithResponse (const std::string &method_name_, const std::string &request_, ServiceResponseVecT &service_response_vec_, int timeout_ms_=DEFAULT_TIME_ARGUMENT) const
Blocking call of a service method for all existing service instances, response will be returned as ServiceResponseVecT.
- Parameters:
method_name_ – Method name.
request_ – Request string.
service_response_vec_ – [out] Response vector containing service responses from every called service (null pointer == no response).
timeout_ms_ – Maximum time before operation returns (in milliseconds, DEFAULT_TIME_ARGUMENT means infinite).
- Returns:
True if all calls were successful.
- ECAL_API_EXPORTED_MEMBER bool CallWithCallback (const std::string &method_name_, const std::string &request_, const ResponseCallbackT &response_callback_, int timeout_ms_=DEFAULT_TIME_ARGUMENT) const
Blocking call (with timeout) of a service method for all existing service instances, using callback.
- Parameters:
method_name_ – Method name.
request_ – Request string.
response_callback_ – Callback function for the service method response.
timeout_ms_ – Maximum time before operation returns (in milliseconds, DEFAULT_TIME_ARGUMENT means infinite).
- Returns:
True if all calls were successful.
- ECAL_API_EXPORTED_MEMBER bool CallWithCallbackAsync (const std::string &method_name_, const std::string &request_, const ResponseCallbackT &response_callback_) const
Asynchronous call of a service method for all existing service instances, using callback.
- Parameters:
method_name_ – Method name.
request_ – Request string.
response_callback_ – Callback function for the service method response.
- Returns:
True if all calls were successful.
- ECAL_API_EXPORTED_MEMBER const std::string & GetServiceName () const
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 () const
Check connection to at least one service.
- Returns:
True if at least one service client instance is connected.
-
ECAL_API_EXPORTED_MEMBER CServiceClient()
Constructor.
-
explicit ECAL_API_EXPORTED_MEMBER CServiceClient(const std::string &service_name_)
Constructor.
- Parameters:
service_name_ – Unique service name.
-
explicit ECAL_API_EXPORTED_MEMBER CServiceClient(const std::string &service_name_, const ServiceMethodInformationSetT &method_information_map_)
Constructor.
- Parameters:
service_name_ – Unique service name.
method_information_map_ – Map of method names and corresponding datatype information.
-
virtual ECAL_API_EXPORTED_MEMBER ~CServiceClient()
Destructor.
-
CServiceClient(const CServiceClient&) = delete
CServiceClients are non-copyable.
-
CServiceClient &operator=(const CServiceClient&) = delete
CServiceClients 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 Create (const std::string &service_name_, const ServiceMethodInformationSetT &method_information_map_)
Creates this object.
- Parameters:
service_name_ – Unique service name.
method_information_map_ – Map of method names and corresponding datatype information.
- Returns:
True if successful.
- ECAL_API_EXPORTED_MEMBER bool Destroy ()
Destroys this object.
- Returns:
True if successful.
- ECAL_API_EXPORTED_MEMBER bool SetHostName (const std::string &host_name_)
Change the host name filter for that client instance.
- Parameters:
host_name_ – Host name filter (empty == all hosts)
- Returns:
True if successful.
- ECAL_API_EXPORTED_MEMBER bool Call (const std::string &method_name_, const std::string &request_, int timeout_=-1)
Call a method of this service, responses will be returned by callback.
- Parameters:
method_name_ – Method name.
request_ – Request string.
timeout_ – Maximum time before operation returns (in milliseconds, -1 means infinite).
- Returns:
True if successful.
- ECAL_API_EXPORTED_MEMBER bool Call (const std::string &method_name_, const std::string &request_, int timeout_, ServiceResponseVecT *service_response_vec_)
Call a method of this service, all responses will be returned in service_response_vec_.
- Parameters:
method_name_ – Method name.
request_ – Request string.
timeout_ – Maximum time before operation returns (in milliseconds, -1 means infinite).
service_response_vec_ – [out] Response vector containing service responses from every called service (null pointer == no response).
- Returns:
True if successful.
- ECAL_API_EXPORTED_MEMBER bool CallAsync (const std::string &method_name_, const std::string &request_, int timeout_=-1)
Call a method of this service asynchronously, responses will be returned by callback.
- Parameters:
method_name_ – Method name.
request_ – Request string.
timeout_ – Maximum time before operation returns (in milliseconds, -1 means infinite) - NOT SUPPORTED YET.
- Returns:
True if successful.
- ECAL_API_EXPORTED_MEMBER bool AddResponseCallback (const ResponseCallbackT &callback_)
Add server response callback.
- Parameters:
callback_ – Callback function for server response.
- Returns:
True if successful.
- ECAL_API_EXPORTED_MEMBER bool RemResponseCallback ()
Remove server response callback.
- Returns:
True if successful.
- ECAL_API_EXPORTED_MEMBER bool AddEventCallback (eClientEvent type_, ClientEventCallbackT callback_)
Add client 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 (eClientEvent type_)
Remove client 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.
Public Static Attributes
- static ECAL_API_EXPORTED_MEMBER constexpr long long DEFAULT_TIME_ARGUMENT = -1
Use DEFAULT_TIME_ARGUMENT in the
CallWithResponse()
andCallWithCallback()
functions for blocking calls
-
ECAL_API_EXPORTED_MEMBER CServiceClient(const std::string &service_name_, const ServiceMethodInformationSetT &method_information_set_ = ServiceMethodInformationSetT(), const ClientEventCallbackT &event_callback_ = ClientEventCallbackT())