-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
first draft of a new client api #1785
Draft
rex-schilasky
wants to merge
6
commits into
master
Choose a base branch
from
feature/redesign-client-api
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,369
−83
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dc49318
first draft of a new client api (not implemented, not compiling)
rex-schilasky 72262ed
minor change
rex-schilasky cf7f3bc
draft API with entity ids aligned with public client api (will be red…
rex-schilasky ffc4320
new client api moved to separate units to introduce and test it in pa…
rex-schilasky fc55ad4
extra qualification removed
rex-schilasky 1e3d759
class restructured
rex-schilasky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
/* ========================= eCAL LICENSE ================================= | ||
* | ||
* Copyright (C) 2016 - 2024 Continental Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* ========================= eCAL LICENSE ================================= | ||
*/ | ||
|
||
/** | ||
* @file ecal_client.h | ||
* @brief eCAL client interface | ||
**/ | ||
|
||
#pragma once | ||
|
||
#include <ecal/ecal_deprecate.h> | ||
#include <ecal/ecal_os.h> | ||
#include <ecal/ecal_callback.h> | ||
#include <ecal/ecal_service_info.h> | ||
|
||
#include <iostream> | ||
#include <string> | ||
#include <vector> | ||
#include <memory> | ||
|
||
namespace eCAL | ||
{ | ||
class CServiceClientIDImpl; | ||
|
||
/** | ||
* @brief Service client wrapper class. | ||
**/ | ||
class CServiceClientID | ||
{ | ||
public: | ||
/** | ||
* @brief Constructor. | ||
**/ | ||
ECAL_API CServiceClientID(); | ||
|
||
/** | ||
* @brief Constructor. | ||
* | ||
* @param service_name_ Unique service name. | ||
**/ | ||
ECAL_API explicit CServiceClientID(const std::string& service_name_); | ||
|
||
/** | ||
* @brief Constructor. | ||
* | ||
* @param service_name_ Unique service name. | ||
* @param method_information_map_ Map of method names and corresponding datatype information. | ||
**/ | ||
ECAL_API explicit CServiceClientID(const std::string& service_name_, const ServiceMethodInformationMapT& method_information_map_); | ||
|
||
/** | ||
* @brief Destructor. | ||
**/ | ||
ECAL_API virtual ~CServiceClientID(); | ||
|
||
/** | ||
* @brief CServiceClients are non-copyable | ||
**/ | ||
CServiceClientID(const CServiceClientID&) = delete; | ||
|
||
/** | ||
* @brief CServiceClients are non-copyable | ||
**/ | ||
CServiceClientID& operator=(const CServiceClientID&) = delete; | ||
|
||
/** | ||
* @brief Creates this object. | ||
* | ||
* @param service_name_ Unique service name. | ||
* | ||
* @return True if successful. | ||
**/ | ||
ECAL_API bool Create(const std::string& service_name_); | ||
|
||
/** | ||
* @brief Creates this object. | ||
* | ||
* @param service_name_ Unique service name. | ||
* @param method_information_map_ Map of method names and corresponding datatype information. | ||
* | ||
* @return True if successful. | ||
**/ | ||
ECAL_API bool Create(const std::string& service_name_, const ServiceMethodInformationMapT& method_information_map_); | ||
|
||
/** | ||
* @brief Destroys this object. | ||
* | ||
* @return True if successful. | ||
**/ | ||
ECAL_API bool Destroy(); | ||
|
||
/** | ||
* @brief Get the unique service id's for all matching services | ||
* | ||
* @return Service id's of all matching services | ||
**/ | ||
ECAL_API std::vector<Registration::SEntityId> GetServiceIDs(); | ||
|
||
/** | ||
* @brief Blocking call specific service method, response will be returned as pair<bool, SServiceReponse> | ||
* | ||
* @param entity_id_ Unique service entity (service id, process id, host name). | ||
* @param method_name_ Method name. | ||
* @param request_ Request string. | ||
* @param timeout_ Maximum time before operation returns (in milliseconds, -1 means infinite). | ||
* | ||
* @return success state and service response | ||
**/ | ||
ECAL_API std::pair<bool, SServiceResponse> CallWithResponse(const Registration::SEntityId& entity_id_, const std::string& method_name_, const std::string& request_, int timeout_ = -1); | ||
|
||
/** | ||
* @brief Blocking call specific service method, using callback | ||
* | ||
* @param entity_id_ Unique service entity (service id, process id, host name). | ||
* @param method_name_ Method name. | ||
* @param request_ Request string. | ||
* @param timeout_ Maximum time before operation returns (in milliseconds, -1 means infinite). | ||
* | ||
* @return True if successful. | ||
**/ | ||
ECAL_API bool CallWithCallback(const Registration::SEntityId& entity_id_, const std::string& method_name_, const std::string& request_, int timeout_ = -1); | ||
|
||
/** | ||
* @brief Add server response callback. | ||
* | ||
* @param callback_ Callback function for server response. | ||
* | ||
* @return True if successful. | ||
**/ | ||
ECAL_API bool AddResponseCallback(const ResponseIDCallbackT& callback_); | ||
|
||
/** | ||
* @brief Remove server response callback. | ||
* | ||
* @return True if successful. | ||
**/ | ||
ECAL_API bool RemResponseCallback(); | ||
|
||
/** | ||
* @brief Add client event callback function. | ||
* | ||
* @param type_ The event type to react on. | ||
* @param callback_ The callback function to add. | ||
* | ||
* @return True if succeeded, false if not. | ||
**/ | ||
ECAL_API bool AddEventCallback(eCAL_Client_Event type_, ClientEventCallbackT callback_); | ||
|
||
/** | ||
* @brief Remove client event callback function. | ||
* | ||
* @param type_ The event type to remove. | ||
* | ||
* @return True if succeeded, false if not. | ||
**/ | ||
ECAL_API bool RemEventCallback(eCAL_Client_Event type_); | ||
|
||
/** | ||
* @brief Retrieve service name. | ||
* | ||
* @return The service name. | ||
**/ | ||
ECAL_API std::string GetServiceName(); | ||
|
||
/** | ||
* @brief Check connection state of a specific server connection. | ||
* | ||
* @param entity_id_ Unique service entity (service id, process id, host name). | ||
* | ||
* @return True if connected, false if not. | ||
**/ | ||
ECAL_API bool IsConnected(const Registration::SEntityId& entity_id_); | ||
|
||
/** | ||
* @brief Check connection state. | ||
* | ||
* @return True if connected, false if not. | ||
**/ | ||
ECAL_API bool IsConnected(); | ||
|
||
protected: | ||
std::shared_ptr<eCAL::CServiceClientIDImpl> m_service_client_impl; | ||
std::string m_service_name; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: class 'CServiceClientID' defines a non-default destructor, a copy constructor and a copy assignment operator but does not define a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]