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] active entity unregistration in descgate #1520

Merged
merged 31 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6b6cf04
topic, clients, services get unregistered actively from DescGate
rex-schilasky Apr 10, 2024
5b8c21b
minor logic bug
rex-schilasky Apr 10, 2024
a68af97
expmap test moved to core (solution folder)
rex-schilasky Apr 10, 2024
e3f0afd
descgate first draft finished
rex-schilasky Apr 12, 2024
62a2d24
minor fixes
rex-schilasky Apr 12, 2024
2f93bfc
Merge branch 'master' into feature/active-descgate-unregistration
rex-schilasky Apr 12, 2024
3e67a72
legacy gettopics_xy API reimplemented
rex-schilasky Apr 12, 2024
12351f8
next refactoring
rex-schilasky Apr 14, 2024
f4b789c
clang-tidy and minor type fix
rex-schilasky Apr 14, 2024
45a7c07
argument name fixes
rex-schilasky Apr 14, 2024
a46fc88
service data type info quality split for request and response
rex-schilasky Apr 15, 2024
96d7fa8
clang-tidy
rex-schilasky Apr 15, 2024
46d630a
cut descgate interfaces to config, registration receiver and registra…
rex-schilasky Apr 15, 2024
7c62264
simple descgate test added
rex-schilasky Apr 15, 2024
79cc993
desc_gate added
rex-schilasky Apr 16, 2024
f4b7753
topic_id, service_id now uint64_t
rex-schilasky Apr 16, 2024
ef29175
minimal send sample reverted
rex-schilasky Apr 16, 2024
d232e13
desc_gate test fixed
rex-schilasky Apr 17, 2024
e819830
DescQualityFlags operators added again
rex-schilasky Apr 17, 2024
6bd7b83
Merge branch 'master' into feature/active-descgate-unregistration
rex-schilasky Apr 17, 2024
1897fe6
descgate getpublisher test corrected
rex-schilasky Apr 18, 2024
1223e1e
Merge branch 'master' into feature/active-descgate-unregistration
rex-schilasky Apr 18, 2024
1df54d1
clang-tidy
rex-schilasky Apr 19, 2024
9749d72
CDescGate::GetPublisher -> CDescGate::GetPublishers, CDescGate::GetSu…
rex-schilasky Apr 22, 2024
5fcdbe7
GetPublisher > GetPublishers ..
rex-schilasky Apr 22, 2024
d6b0709
includes added
rex-schilasky Apr 22, 2024
f82d20d
a few keller-tidy
rex-schilasky Apr 23, 2024
afa72a2
a few more keller-tidy
rex-schilasky Apr 24, 2024
3c8dd97
some additional usings added
rex-schilasky Apr 24, 2024
1339572
Merge branch 'master' into feature/active-descgate-unregistration
rex-schilasky Apr 24, 2024
d4769e5
SServiceIdKey compare operator improved
rex-schilasky Apr 24, 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
51 changes: 51 additions & 0 deletions ecal/core/include/ecal/cimpl/ecal_util_cimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,57 @@ extern "C"
* @return Response description buffer length or zero if failed.
**/
ECALC_API int eCAL_Util_GetServiceResponseDescription(const char* service_name_, const char* method_name_, void* resp_desc_, int resp_desc_len_);

/**
* @brief Gets client method request type name.
*
* @param client_name_ Client name.
* @param method_name_ Method name.
* @param [out] req_type_ Pointer to store the request type.
* @param req_type_len_ Length of allocated buffer or ECAL_ALLOCATE_4ME if
* eCAL should allocate the buffer for you (see eCAL_FreeMem).
*
* @return Type name buffer length or zero if failed.
**/
ECALC_API int eCAL_Util_GetClientRequestTypeName(const char* client_name_, const char* method_name_, void* req_type_, int req_type_len_);

/**
* @brief Gets client method response type name.
*
* @param client_name_ Client name.
* @param method_name_ Method name.
* @param [out] resp_type_ Pointer to store the response type.
* @param resp_type_len_ Length of allocated buffer or ECAL_ALLOCATE_4ME if
*
* @return Type name buffer length or zero if failed.
**/
ECALC_API int eCAL_Util_GetClientResponseTypeName(const char* client_name_, const char* method_name_, void* resp_type_, int resp_type_len_);

/**
* @brief Gets client method request description.
*
* @param client_name_ Client name.
* @param method_name_ Method name.
* @param [out] req_desc_ Pointer to store the request description.
* @param req_desc_len_ Length of allocated buffer or ECAL_ALLOCATE_4ME if
* eCAL should allocate the buffer for you (see eCAL_FreeMem).
*
* @return Request description buffer length or zero if failed.
**/
ECALC_API int eCAL_Util_GetClientRequestDescription(const char* client_name_, const char* method_name_, void* req_desc_, int req_desc_len_);

/**
* @brief Gets client method response description.
*
* @param client_name_ Client name.
* @param method_name_ Method name.
* @param [out] resp_desc_ Pointer to store the response description.
* @param resp_desc_len_ Length of allocated buffer or ECAL_ALLOCATE_4ME if
* eCAL should allocate the buffer for you (see eCAL_FreeMem).
*
* @return Response description buffer length or zero if failed.
**/
ECALC_API int eCAL_Util_GetClientResponseDescription(const char* client_name_, const char* method_name_, void* resp_desc_, int resp_desc_len_);
#ifdef __cplusplus
}
#endif /*__cplusplus*/
Expand Down
184 changes: 168 additions & 16 deletions ecal/core/include/ecal/ecal_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,43 @@
#include <ecal/ecal_os.h>
#include <ecal/ecal_deprecate.h>
#include <ecal/ecal_types.h>

#include <map>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

namespace eCAL
{
namespace Util
{
namespace Util
{
// enumeration of quality bits used for detecting how good a data information is
enum class DescQualityFlags : std::uint8_t
{
NO_QUALITY = 0, //!< Special value for initialization
DESCRIPTION_AVAILABLE = 0x1 << 3, //!< Having a type descriptor available
ENCODING_AVAILABLE = 0x1 << 2, //!< Having a type encoding
TYPENAME_AVAILABLE = 0x1 << 1, //!< Having a type name available
INFO_COMES_FROM_PRODUCER = 0x1 << 0 //!< Info is coming from the producer (like a publisher, service)
};
inline DescQualityFlags& operator|= (DescQualityFlags& a, DescQualityFlags b) { return reinterpret_cast<DescQualityFlags&>(reinterpret_cast<std::underlying_type_t<DescQualityFlags>&>(a) |= static_cast<std::underlying_type_t<DescQualityFlags>>(b)); }

struct SQualityTopicInfo
KerstinKeller marked this conversation as resolved.
Show resolved Hide resolved
KerstinKeller marked this conversation as resolved.
Show resolved Hide resolved
{
std::string id;
SDataTypeInformation info;
DescQualityFlags quality = DescQualityFlags::NO_QUALITY;
};
rex-schilasky marked this conversation as resolved.
Show resolved Hide resolved

struct SQualityServiceInfo
KerstinKeller marked this conversation as resolved.
Show resolved Hide resolved
KerstinKeller marked this conversation as resolved.
Show resolved Hide resolved
{
std::string id;
SServiceMethodInformation info;
DescQualityFlags request_quality = DescQualityFlags::NO_QUALITY;
DescQualityFlags response_quality = DescQualityFlags::NO_QUALITY;
};

/**
* @brief Retrieve eCAL configuration path.
* This is path is for the global eCAL configuration files
Expand Down Expand Up @@ -124,12 +149,84 @@ namespace eCAL
ECAL_API void PubShareDescription(bool state_);

/**
* @brief Get complete topic map (including types and descriptions).
* @brief Get complete snapshot of data type information with quality and topic id for all known publisher.
*
* @return MultiMap containing the quality datatype information and the topic id's.
**/
ECAL_API std::multimap<std::string, SQualityTopicInfo> GetPublisher();
rex-schilasky marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief Get data type information with quality and topic id for this publisher.
*
* @param topic_name_ Topic name.
*
* @return Vector containing the quality datatype information for this publisher.
**/
ECAL_API std::vector<SQualityTopicInfo> GetPublisher(const std::string& topic_name_);

/**
* @brief Get complete snapshot of data type information with quality and topic id for all known subscriber.
*
* @return MultiMap containing the quality datatype information and the topic id's.
**/
ECAL_API std::multimap<std::string, SQualityTopicInfo> GetSubscriber();

/**
* @brief Get data type information with quality and topic id for this subscriber.
*
* @param topic_name_ Topic name.
*
* @return Vector containing the quality datatype information for this subscriber.
**/
ECAL_API std::vector<SQualityTopicInfo> GetSubscriber(const std::string& topic_name_);
rex-schilasky marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief Get highest quality data type information out of a vector of quality data type information.
*
* @param quality_topic_info_vec_ Vector of quality data type information
*
* @return Highest quality data type information.
**/
ECAL_API SDataTypeInformation GetHighestQualityDataTypeInformation(const std::vector<SQualityTopicInfo>& quality_topic_info_vec_);

/**
* @brief Get complete snapshot of service method information with quality and service id for all known services.
*
* @return MultiMap<ServiceName, MethodName> containing the quality datatype information and the service id's.
**/
ECAL_API std::multimap<std::tuple<std::string, std::string>, SQualityServiceInfo> GetServices();
rex-schilasky marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief Get complete snapshot of service method information with quality and client id for all known clients.
*
* @param topic_info_map_ Map to store the datatype descriptions.
* Map containing { TopicName -> (Encoding, Type, Description) } mapping of all topics that are currently known.
* @return MultiMap<ClientName, MethodName> containing the quality datatype information and the client id's.
**/
ECAL_API void GetTopics(std::unordered_map<std::string, SDataTypeInformation>& topic_info_map_);
ECAL_API std::multimap<std::tuple<std::string, std::string>, SQualityServiceInfo> GetClients();

/**
* @brief Get highest quality service method type information out of a vector of quality service method information.
*
* @param quality_service_info_vec_ Vector of quality service method information
*
* @return Highest quality service method information.
**/
ECAL_API SServiceMethodInformation GetHighestQualityServiceMethodInformation(const std::vector<SQualityServiceInfo>& quality_service_info_vec_);

/**
* @brief Get complete topic map.
*
* @param data_type_info_map_ Map to store the datatype information.
* Map { TopicName -> SDataTypeInformation } mapping of all currently known publisher/subscriber.
**/
ECAL_API void GetTopics(std::map<std::string, SDataTypeInformation>& data_type_info_map_);

/**
* @brief Get complete quality topic map.
*
* @param quality_topic_info_map_ Map to store the quality datatype information.
* Map { TopicName -> SQualityDataTypeInformation } mapping of all currently known publisher/subscriber.
**/
ECAL_API void GetTopics(std::map<std::string, SQualityTopicInfo>& quality_topic_info_map_);

/**
* @brief Get all topic names.
Expand All @@ -141,27 +238,35 @@ namespace eCAL
/**
* @brief Gets description of the specified topic.
*
* @param topic_name_ Topic name.
* @param topic_info_ SDataTypeInformation to be filled by this function.
* @param topic_name_ Topic name.
* @param data_type_info_ SDataTypeInformation to be filled by this function.
*
* @return True if TopicInformation for specified topic could be retrieved, false otherwise.
**/
ECAL_API bool GetTopicDataTypeInformation(const std::string& topic_name_, SDataTypeInformation& topic_info_);
ECAL_API bool GetTopicDataTypeInformation(const std::string& topic_name_, SDataTypeInformation& data_type_info_);

/**
* @brief Get complete service map.
*
* @param service_method_info_map_ Map to store the service/method descriptions.
* Map { (ServiceName, MethodName) -> SServiceMethodInformation } mapping of all currently known services.
**/
ECAL_API void GetServices(std::map<std::tuple<std::string, std::string>, SServiceMethodInformation>& service_method_info_map_);

/**
* @brief Get complete service map (including request and response types and descriptions).
* @brief Get complete quality service map.
*
* @param service_info_map_ Map to store the datatype descriptions.
* Map { (ServiceName, MethodName) -> ( (ReqType, ReqDescription), (RespType, RespDescription) ) } mapping of all currently known services.
* @param quality_service_info_map_ Map to store the quality service/method descriptions.
* Map { (ServiceName, MethodName) -> SQualityServiceMethodInformation } mapping of all currently known services.
**/
ECAL_API void GetServices(std::map<std::tuple<std::string, std::string>, SServiceMethodInformation>& service_info_map_);
ECAL_API void GetServices(std::map<std::tuple<std::string, std::string>, SQualityServiceInfo>& quality_service_info_map_);

/**
* @brief Get all service/method names.
*
* @param service_method_names_ Vector to store the service/method tuples (Vector { (ServiceName, MethodName) }).
**/
ECAL_API void GetServiceNames(std::vector<std::tuple<std::string, std::string>>& service_method_names_);
ECAL_API void GetServiceMethodNames(std::vector<std::tuple<std::string, std::string>>& service_method_names_);

/**
* @brief Gets service method request and response type names.
Expand All @@ -187,6 +292,53 @@ namespace eCAL
**/
ECAL_API bool GetServiceDescription(const std::string& service_name_, const std::string& method_name_, std::string& req_desc_, std::string& resp_desc_);

/**
* @brief Get complete client map.
*
* @param client_method_info_map_ Map to store the client/method descriptions.
* Map { (ClientName, MethodName) -> SServiceMethodInformation } mapping of all currently known clients.
**/
ECAL_API void GetClients(std::map<std::tuple<std::string, std::string>, SServiceMethodInformation>& client_method_info_map_);

/**
* @brief Get complete quality client map.
*
* @param quality_client_info_map_ Map to store the quality client/method descriptions.
* Map { (ClientName, MethodName) -> SQualityServiceMethodInformation } mapping of all currently known clients.
**/
ECAL_API void GetClients(std::map<std::tuple<std::string, std::string>, SQualityServiceInfo>& quality_client_info_map_);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'eCAL::Util::GetClients' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name]

    ECAL_API void GetClients(std::map<std::tuple<std::string, std::string>, SQualityServiceInfo>& quality_client_info_map_);
                  ^
Additional context

ecal/core/src/ecal_util.cpp:518: the definition seen here

    void GetClients(std::map<std::tuple<std::string, std::string>, SQualityServiceInfo>& quality_client_method_info_map_)
         ^

ecal/core/include/ecal/ecal_util.h:307: differing parameters are named here: ('quality_client_info_map_'), in definition: ('quality_client_method_info_map_')

    ECAL_API void GetClients(std::map<std::tuple<std::string, std::string>, SQualityServiceInfo>& quality_client_info_map_);
                  ^


/**
* @brief Get all client/method names.
*
* @param client_method_names_ Vector to store the client/method tuples (Vector { (ClientName, MethodName) }).
**/
ECAL_API void GetClientMethodNames(std::vector<std::tuple<std::string, std::string>>& client_method_names_);

/**
* @brief Gets client method request and response type names.
*
* @param client_name_ Client name.
* @param method_name_ Method name.
* @param req_type_ String to store request type.
* @param resp_type_ String to store response type.
*
* @return True if succeeded.
**/
ECAL_API bool GetClientTypeNames(const std::string& client_name_, const std::string& method_name_, std::string& req_type_, std::string& resp_type_);

/**
* @brief Gets client method request and response descriptions.
*
* @param client_name_ Client name.
* @param method_name_ Method name.
* @param req_desc_ String to store request description.
* @param resp_desc_ String to store response description.
*
* @return True if succeeded.
**/
ECAL_API bool GetClientDescription(const std::string& client_name_, const std::string& method_name_, std::string& req_desc_, std::string& resp_desc_);

/**
* @brief Splits the topic type (eCAL < 5.12) into encoding and types (>= eCAL 5.12)
*
Expand Down
56 changes: 56 additions & 0 deletions ecal/core/src/cimpl/ecal_util_cimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,60 @@ extern "C"
}
return 0;
}

ECALC_API int eCAL_Util_GetClientRequestTypeName(const char* client_name_, const char* method_name_, void* req_type_, int req_type_len_)
rex-schilasky marked this conversation as resolved.
Show resolved Hide resolved
{
if (client_name_ == nullptr) return(0);
if (method_name_ == nullptr) return(0);
if (req_type_ == nullptr) return(0);
std::string req_type;
std::string resp_type;
if (eCAL::Util::GetClientTypeNames(client_name_, method_name_, req_type, resp_type))
{
return(CopyBuffer(req_type_, req_type_len_, req_type));
}
return 0;
}

ECALC_API int eCAL_Util_GetClientResponseTypeName(const char* client_name_, const char* method_name_, void* resp_type_, int resp_type_len_)
{
if (client_name_ == nullptr) return(0);
if (method_name_ == nullptr) return(0);
if (resp_type_ == nullptr) return(0);
std::string req_type;
std::string resp_type;
if (eCAL::Util::GetClientTypeNames(client_name_, method_name_, req_type, resp_type))
{
return(CopyBuffer(resp_type_, resp_type_len_, resp_type));
}
return 0;
}

ECALC_API int eCAL_Util_GetClientRequestDescription(const char* client_name_, const char* method_name_, void* req_desc_, int req_desc_len_)
{
if (client_name_ == nullptr) return(0);
if (method_name_ == nullptr) return(0);
if (req_desc_ == nullptr) return(0);
std::string req_desc;
std::string resp_desc;
if (eCAL::Util::GetClientDescription(client_name_, method_name_, req_desc, resp_desc))
{
return(CopyBuffer(req_desc_, req_desc_len_, req_desc));
}
return 0;
}

ECALC_API int eCAL_Util_GetClientResponseDescription(const char* client_name_, const char* method_name_, void* resp_desc_, int resp_desc_len_)
{
if (client_name_ == nullptr) return(0);
if (method_name_ == nullptr) return(0);
if (resp_desc_ == nullptr) return(0);
std::string req_desc;
std::string resp_desc;
if (eCAL::Util::GetClientDescription(client_name_, method_name_, req_desc, resp_desc))
{
return(CopyBuffer(resp_desc_, resp_desc_len_, resp_desc));
}
return 0;
}
}
Loading
Loading