Skip to content
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

Merged
merged 25 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
91741af
v5 renaming
rex-schilasky Dec 6, 2024
e79fa88
intermediate commit
rex-schilasky Dec 9, 2024
a2ccd10
intermediate commit (building, not working)
rex-schilasky Dec 9, 2024
9d2bf06
intermediate commit
rex-schilasky Dec 9, 2024
d9d7177
commenting
rex-schilasky Dec 9, 2024
3f9de03
first server implementation
rex-schilasky Dec 10, 2024
8e9fa32
Merge branch 'master' into feature/redesign-service-api
rex-schilasky Dec 11, 2024
7011eaa
Merge branch 'master' into feature/client-api-cleanup
rex-schilasky Dec 11, 2024
63082f3
commenting, logging + minor fix
rex-schilasky Dec 11, 2024
ffa87a5
eCAL::v5::CServiceServerImpl implemented based on eCAL::CServiceServer
rex-schilasky Dec 11, 2024
4181604
missing include
rex-schilasky Dec 11, 2024
02e8ad1
logging improved
rex-schilasky Dec 11, 2024
f59b100
minor comment and include fixes
rex-schilasky Dec 11, 2024
a5fb463
improved logging
rex-schilasky Dec 11, 2024
c89f8ee
Merge branch 'feature/client-api-cleanup' into feature/redesign-servi…
rex-schilasky Dec 11, 2024
95187e9
formatting
rex-schilasky Dec 11, 2024
f9d9a0a
minor review adaptions
rex-schilasky Dec 12, 2024
c327a90
shared_ptr handling, commenting
rex-schilasky Dec 12, 2024
2ccc9c1
check for nullptr in destructor
rex-schilasky Dec 13, 2024
7bb8b57
logging added/improved for CServiceClientImpl and CServiceServerImpl
rex-schilasky Dec 13, 2024
995c66c
GetServiceID added to public API of CServerClient and CServiceServer …
rex-schilasky Dec 13, 2024
238b326
review results
rex-schilasky Dec 13, 2024
1f41360
Merge branch 'master' into feature/redesign-service-api
Peguen Dec 13, 2024
3f9a963
server/client samples updated to v6
rex-schilasky Dec 13, 2024
d1cb855
minor test fix
rex-schilasky Dec 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ if(ECAL_CORE_SERVICE)
src/service/ecal_service_server.cpp
src/service/ecal_service_server_impl.cpp
src/service/ecal_service_server_impl.h
src/service/ecal_service_server_v5.cpp
src/service/ecal_service_server_v5_impl.cpp
src/service/ecal_service_server_v5_impl.h
src/service/ecal_service_singleton_manager.cpp
src/service/ecal_service_singleton_manager.h
)
Expand Down Expand Up @@ -536,6 +539,7 @@ set(ecal_header_cmn
include/ecal/ecal_registration.h
include/ecal/ecal_publisher.h
include/ecal/ecal_server.h
include/ecal/ecal_server_v5.h
include/ecal/ecal_service_info.h
include/ecal/ecal_subscriber.h
include/ecal/ecal_time.h
Expand Down
82 changes: 10 additions & 72 deletions ecal/core/include/ecal/ecal_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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());
Copy link
Contributor

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]

Suggested change
explicit CServiceServer(const std::string& service_name_, const ServerEventIDCallbackT event_callback_ = ServerEventIDCallbackT());
explicit CServiceServer(const std::string& service_name_, 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.
Expand All @@ -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_);
Copy link
Contributor

Choose a reason for hiding this comment

The 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.
Expand All @@ -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.
*
Expand All @@ -167,6 +106,5 @@ namespace eCAL

private:
std::shared_ptr<CServiceServerImpl> m_service_server_impl;
bool m_created;
};
}
174 changes: 174 additions & 0 deletions ecal/core/include/ecal/ecal_server_v5.h
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>
Copy link
Contributor

Choose a reason for hiding this comment

The 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_os.h>
#include <ecal/ecal_os.h>

#include <ecal/ecal_callback.h>
#include <ecal/ecal_service_info.h>

#include <string>
#include <vector>
#include <memory>
Copy link
Contributor

Choose a reason for hiding this comment

The 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
#include <memory>
#include <memory>


Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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_);
Copy link
Contributor

Choose a reason for hiding this comment

The 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;
};
}
}
12 changes: 6 additions & 6 deletions ecal/core/include/ecal/msg/protobuf/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#pragma once

#include <ecal/ecal_server.h>
#include <ecal/ecal_server_v5.h>
Copy link
Contributor

Choose a reason for hiding this comment

The 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>

Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The 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:
/**
Expand Down Expand Up @@ -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_)
Expand Down Expand Up @@ -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;
};
}
}
Loading
Loading