-
Notifications
You must be signed in to change notification settings - Fork 180
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
[core] redesign service server api #1849
Changes from 4 commits
91741af
e79fa88
a2ccd10
9d2bf06
d9d7177
3f9de03
8e9fa32
7011eaa
63082f3
ffa87a5
4181604
02e8ad1
f59b100
a5fb463
c89f8ee
95187e9
f9d9a0a
c327a90
2ccc9c1
7bb8b57
995c66c
238b326
1f41360
3f9a963
d1cb855
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,8 @@ | |
*/ | ||
|
||
/** | ||
* @file ecal_server.h | ||
* @brief eCAL service interface | ||
* @file ecal_server_v5.h | ||
* @brief eCAL server interface (deprecated eCAL5 version) | ||
**/ | ||
|
||
#pragma once | ||
|
@@ -44,66 +44,26 @@ namespace eCAL | |
{ | ||
public: | ||
/** | ||
* @brief Constructor. | ||
**/ | ||
ECAL_API_EXPORTED_MEMBER | ||
CServiceServer(); | ||
|
||
/** | ||
* @brief Constructor. | ||
* @brief Constructor. | ||
* | ||
* @param service_name_ Unique service name. | ||
**/ | ||
ECAL_API_EXPORTED_MEMBER | ||
explicit CServiceServer(const std::string& service_name_); | ||
explicit CServiceServer(const std::string& service_name_, const ServerEventIDCallbackT event_callback_ = ServerEventIDCallbackT()); | ||
|
||
/** | ||
* @brief Destructor. | ||
* @brief Destructor. | ||
**/ | ||
ECAL_API_EXPORTED_MEMBER | ||
virtual ~CServiceServer(); | ||
|
||
/** | ||
* @brief CServiceServers are non-copyable | ||
**/ | ||
// Deleted copy constructor and copy assignment operator | ||
CServiceServer(const CServiceServer&) = delete; | ||
|
||
/** | ||
* @brief CServiceServers are non-copyable | ||
**/ | ||
CServiceServer& operator=(const CServiceServer&) = delete; | ||
|
||
/** | ||
* @brief Creates this object. | ||
* | ||
* @param service_name_ Unique service name. | ||
* | ||
* @return True if successful. | ||
**/ | ||
ECAL_API_EXPORTED_MEMBER | ||
bool Create(const std::string& service_name_); | ||
|
||
/** | ||
* @brief Destroys this object. | ||
* | ||
* @return True if successful. | ||
**/ | ||
ECAL_API_EXPORTED_MEMBER | ||
bool Destroy(); | ||
|
||
/** | ||
* @brief Add method type descriptions. | ||
* | ||
* @param method_ Service method name. | ||
* @param req_type_ Service method request type. | ||
* @param req_desc_ Service method request description. | ||
* @param resp_type_ Service method response type. | ||
* @param resp_desc_ Service method response description. | ||
* | ||
* @return 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_); | ||
// Move constructor and move assignment operator | ||
ECAL_API_EXPORTED_MEMBER CServiceServer(CServiceServer&& rhs) noexcept; | ||
ECAL_API_EXPORTED_MEMBER CServiceServer& operator=(CServiceServer&& rhs) noexcept; | ||
|
||
/** | ||
* @brief Add method callback. | ||
|
@@ -116,7 +76,7 @@ namespace eCAL | |
* @return 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_); | ||
bool AddMethodCallback(const std::string& method_, const SServiceMethodInformation& method_info_, const MethodCallbackT& callback_); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "eCAL::SServiceMethodInformation" is directly included [misc-include-cleaner] ecal/core/include/ecal/ecal_server.h:26: - #include <ecal/ecal_deprecate.h>
+ #include "ecal/ecal_types.h"
+ #include <ecal/ecal_deprecate.h> |
||
|
||
/** | ||
* @brief Remove method callback. | ||
|
@@ -128,27 +88,6 @@ namespace eCAL | |
ECAL_API_EXPORTED_MEMBER | ||
bool RemMethodCallback(const std::string& method_); | ||
|
||
/** | ||
* @brief Add server 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_EXPORTED_MEMBER | ||
bool AddEventCallback(eCAL_Server_Event type_, ServerEventCallbackT callback_); | ||
|
||
/** | ||
* @brief Remove server event callback function. | ||
* | ||
* @param type_ The event type to remove. | ||
* | ||
* @return True if succeeded, false if not. | ||
**/ | ||
ECAL_API_EXPORTED_MEMBER | ||
bool RemEventCallback(eCAL_Server_Event type_); | ||
|
||
/** | ||
* @brief Retrieve service name. | ||
* | ||
|
@@ -167,6 +106,5 @@ namespace eCAL | |
|
||
private: | ||
std::shared_ptr<CServiceServerImpl> m_service_server_impl; | ||
bool m_created; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,174 @@ | ||||||
/* ========================= 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_server_v5.h | ||||||
* @brief eCAL server interface (deprecated eCAL5 version) | ||||||
**/ | ||||||
|
||||||
#pragma once | ||||||
|
||||||
#include <ecal/ecal_deprecate.h> | ||||||
#include <ecal/ecal_os.h> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: included header ecal_deprecate.h is not used directly [misc-include-cleaner]
Suggested change
|
||||||
#include <ecal/ecal_callback.h> | ||||||
#include <ecal/ecal_service_info.h> | ||||||
|
||||||
#include <string> | ||||||
#include <vector> | ||||||
#include <memory> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: included header vector is not used directly [misc-include-cleaner]
Suggested change
|
||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: included header vector is not used directly [misc-include-cleaner]
Suggested change
|
||||||
namespace eCAL | ||||||
{ | ||||||
namespace v5 | ||||||
{ | ||||||
class CServiceServerImpl; | ||||||
|
||||||
/** | ||||||
* @brief Service Server wrapper class. | ||||||
**/ | ||||||
class ECAL_API_CLASS CServiceServer | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: class 'CServiceServer' defines a 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] class ECAL_API_CLASS CServiceServer
^ |
||||||
{ | ||||||
public: | ||||||
/** | ||||||
* @brief Constructor. | ||||||
**/ | ||||||
ECAL_API_EXPORTED_MEMBER | ||||||
CServiceServer(); | ||||||
|
||||||
/** | ||||||
* @brief Constructor. | ||||||
* | ||||||
* @param service_name_ Unique service name. | ||||||
**/ | ||||||
ECAL_API_EXPORTED_MEMBER | ||||||
explicit CServiceServer(const std::string& service_name_); | ||||||
|
||||||
/** | ||||||
* @brief Destructor. | ||||||
**/ | ||||||
ECAL_API_EXPORTED_MEMBER | ||||||
virtual ~CServiceServer(); | ||||||
|
||||||
/** | ||||||
* @brief CServiceServers are non-copyable | ||||||
**/ | ||||||
CServiceServer(const CServiceServer&) = delete; | ||||||
|
||||||
/** | ||||||
* @brief CServiceServers are non-copyable | ||||||
**/ | ||||||
CServiceServer& operator=(const CServiceServer&) = delete; | ||||||
|
||||||
/** | ||||||
* @brief Creates this object. | ||||||
* | ||||||
* @param service_name_ Unique service name. | ||||||
* | ||||||
* @return True if successful. | ||||||
**/ | ||||||
ECAL_API_EXPORTED_MEMBER | ||||||
bool Create(const std::string& service_name_); | ||||||
|
||||||
/** | ||||||
* @brief Destroys this object. | ||||||
* | ||||||
* @return True if successful. | ||||||
**/ | ||||||
ECAL_API_EXPORTED_MEMBER | ||||||
bool Destroy(); | ||||||
|
||||||
/** | ||||||
* @brief Add method type descriptions. | ||||||
* | ||||||
* @param method_ Service method name. | ||||||
* @param req_type_ Service method request type. | ||||||
* @param req_desc_ Service method request description. | ||||||
* @param resp_type_ Service method response type. | ||||||
* @param resp_desc_ Service method response description. | ||||||
* | ||||||
* @return 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_); | ||||||
|
||||||
/** | ||||||
* @brief Add method callback. | ||||||
* | ||||||
* @param method_ Service method name. | ||||||
* @param req_type_ Service method request type. | ||||||
* @param resp_type_ Service method response type. | ||||||
* @param callback_ Callback function for client request. | ||||||
* | ||||||
* @return 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_); | ||||||
|
||||||
/** | ||||||
* @brief Remove method callback. | ||||||
* | ||||||
* @param method_ Service method name. | ||||||
* | ||||||
* @return True if successful. | ||||||
**/ | ||||||
ECAL_API_EXPORTED_MEMBER | ||||||
bool RemMethodCallback(const std::string& method_); | ||||||
|
||||||
/** | ||||||
* @brief Add server 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_EXPORTED_MEMBER | ||||||
bool AddEventCallback(eCAL_Server_Event type_, ServerEventCallbackT callback_); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "eCAL_Server_Event" is directly included [misc-include-cleaner] ecal/core/include/ecal/ecal_server_v5.h:26: - #include <ecal/ecal_deprecate.h>
+ #include "ecal/cimpl/ecal_callback_cimpl.h"
+ #include <ecal/ecal_deprecate.h> |
||||||
|
||||||
/** | ||||||
* @brief Remove server event callback function. | ||||||
* | ||||||
* @param type_ The event type to remove. | ||||||
* | ||||||
* @return True if succeeded, false if not. | ||||||
**/ | ||||||
ECAL_API_EXPORTED_MEMBER | ||||||
bool RemEventCallback(eCAL_Server_Event type_); | ||||||
|
||||||
/** | ||||||
* @brief Retrieve service name. | ||||||
* | ||||||
* @return The service name. | ||||||
**/ | ||||||
ECAL_API_EXPORTED_MEMBER | ||||||
std::string GetServiceName(); | ||||||
|
||||||
/** | ||||||
* @brief Check connection state. | ||||||
* | ||||||
* @return True if connected, false if not. | ||||||
**/ | ||||||
ECAL_API_EXPORTED_MEMBER | ||||||
bool IsConnected(); | ||||||
|
||||||
private: | ||||||
std::shared_ptr<CServiceServerImpl> m_service_server_impl; | ||||||
}; | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ | |
|
||
#pragma once | ||
|
||
#include <ecal/ecal_server.h> | ||
#include <ecal/ecal_server_v5.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: 'ecal/ecal_server_v5.h' file not found [clang-diagnostic-error] #include <ecal/ecal_server_v5.h>
^ |
||
#include <ecal/msg/protobuf/ecal_proto_dyn.h> | ||
#include <functional> | ||
|
||
|
@@ -51,7 +51,7 @@ namespace eCAL | |
* @brief Google Protobuf Server wrapper class. | ||
**/ | ||
template <typename T> | ||
class CServiceServer : public eCAL::CServiceServer | ||
class CServiceServer : public eCAL::v5::CServiceServer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: class 'CServiceServer' 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] class CServiceServer : public eCAL::v5::CServiceServer
^ |
||
{ | ||
public: | ||
/** | ||
|
@@ -179,7 +179,7 @@ namespace eCAL | |
return true; | ||
} | ||
|
||
using eCAL::CServiceServer::Create; | ||
using eCAL::v5::CServiceServer::Create; | ||
|
||
protected: | ||
int RequestCallback(const std::string& method_, const std::string& /*req_type_*/, const std::string& /*resp_type_*/, const std::string& request_, std::string& response_) | ||
|
@@ -217,9 +217,9 @@ namespace eCAL | |
std::map<std::string, const google::protobuf::MethodDescriptor*> m_methods; | ||
|
||
private: | ||
using eCAL::CServiceServer::AddMethodCallback; | ||
using eCAL::CServiceServer::RemMethodCallback; | ||
using eCAL::CServiceServer::GetServiceName; | ||
using eCAL::v5::CServiceServer::AddMethodCallback; | ||
using eCAL::v5::CServiceServer::RemMethodCallback; | ||
using eCAL::v5::CServiceServer::GetServiceName; | ||
}; | ||
} | ||
} |
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: parameter 'event_callback_' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]