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

clang tidy public API (not completed) #22

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 10 additions & 22 deletions src/core/include/ecal/ecal_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,35 +50,23 @@ namespace eCAL
**/
struct SPubEventCallbackData
{
SPubEventCallbackData()
{
type = pub_event_none;
time = 0;
clock = 0;
};
eCAL_Publisher_Event type; //!< publisher event type
long long time; //!< publisher event time in µs
long long clock; //!< publisher event clock
std::string tid; //!< topic id of the of the connected subscriber (for pub_event_update_connection only)
SDataTypeInformation tdatatype; //!< datatype description of the connected subscriber (for pub_event_update_connection only)
eCAL_Publisher_Event type{pub_event_none}; //!< publisher event type
long long time{0}; //!< publisher event time in µs
long long clock{0}; //!< publisher event clock
std::string tid; //!< topic id of the of the connected subscriber (for pub_event_update_connection only)
SDataTypeInformation tdatatype; //!< datatype description of the connected subscriber (for pub_event_update_connection only)
};

/**
* @brief eCAL subscriber event callback struct.
**/
struct SSubEventCallbackData
{
SSubEventCallbackData()
{
type = sub_event_none;
time = 0;
clock = 0;
};
eCAL_Subscriber_Event type; //!< subscriber event type
long long time; //!< subscriber event time in µs
long long clock; //!< subscriber event clock
std::string tid; //!< topic id of the of the connected publisher (for sub_event_update_connection only)
SDataTypeInformation tdatatype; //!< topic information of the connected subscriber (for pub_event_update_connection only)
eCAL_Subscriber_Event type{sub_event_none}; //!< subscriber event type
long long time{0}; //!< subscriber event time in µs
long long clock{0}; //!< subscriber event clock
std::string tid; //!< topic id of the of the connected publisher (for sub_event_update_connection only)
SDataTypeInformation tdatatype; //!< topic information of the connected subscriber (for pub_event_update_connection only)
};

/**
Expand Down
32 changes: 16 additions & 16 deletions src/core/include/ecal/ecal_clang.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ ECAL_API int ecal_set_unit_name(const char *unit_name_);
* @param info_ Info message.
*
**/
ECAL_API void ecal_set_process_state(const int severity_, const int level_, const char* info_);
ECAL_API void ecal_set_process_state(int severity_, int level_, const char* info_);

/**
* @brief Return the eCAL process state.
Expand Down Expand Up @@ -137,7 +137,7 @@ ECAL_API void ecal_free_mem(void* mem_);
*
* @param time_ms_ Time to sleep in ms.
**/
ECAL_API void ecal_sleep_ms(const long time_ms_);
ECAL_API void ecal_sleep_ms(long time_ms_);

/**
* @brief Send shutdown event to specified local user process using it's unit name.
Expand All @@ -151,7 +151,7 @@ ECAL_API void ecal_shutdown_process_uname(const char* unit_name_);
*
* @param process_id_ Process id.
**/
ECAL_API void ecal_shutdown_process_id(const int process_id_);
ECAL_API void ecal_shutdown_process_id(int process_id_);

/**
* @brief Send shutdown event to all local user processes.
Expand All @@ -170,7 +170,7 @@ ECAL_API void ecal_shutdown_core();
*
* @param state_ Switch on message loop back..
**/
ECAL_API void ecal_enable_loopback(const int state_);
ECAL_API void ecal_enable_loopback(int state_);

/**
* @brief Gets type name of the specified topic.
Expand Down Expand Up @@ -216,7 +216,7 @@ ECAL_API bool ecal_get_description(const char* topic_name_, const char** topic_d
*
* @param level_ The level.
**/
ECAL_API void log_setlevel(const int level_);
ECAL_API void log_setlevel(int level_);

/**
* @brief Log a message (with current log level).
Expand Down Expand Up @@ -257,7 +257,7 @@ ECAL_API bool pub_destroy(ECAL_HANDLE handle_);
*
* @return Number of bytes sent.
**/
ECAL_API int pub_send(ECAL_HANDLE handle_, const char* payload_, const int length_, const long long time_);
ECAL_API int pub_send(ECAL_HANDLE handle_, const char* payload_, int length_, long long time_);

/**
* @brief Add callback function for publisher events.
Expand All @@ -269,7 +269,7 @@ ECAL_API int pub_send(ECAL_HANDLE handle_, const char* payload_, const int lengt
*
* @return True if succeeded.
**/
ECAL_API bool pub_add_event_callback(ECAL_HANDLE handle_, enum eCAL_Publisher_Event type_, const PubEventCallbackCT callback_, void* par_);
ECAL_API bool pub_add_event_callback(ECAL_HANDLE handle_, enum eCAL_Publisher_Event type_, PubEventCallbackCT callback_, void* par_);

/**
* @brief Remove callback function for publisher events.
Expand Down Expand Up @@ -315,7 +315,7 @@ ECAL_API bool sub_destroy(ECAL_HANDLE handle_);
*
* @return Length of received buffer.
**/
ECAL_API int sub_receive(ECAL_HANDLE handle_, const char** rcv_buf_, int* rcv_buf_len_, long long* rcv_time_, const int timeout_);
ECAL_API int sub_receive(ECAL_HANDLE handle_, const char** rcv_buf_, int* rcv_buf_len_, long long* rcv_time_, int timeout_);

/**
* @brief Receive a message from the publisher (able to process zero length buffer).
Expand All @@ -329,7 +329,7 @@ ECAL_API int sub_receive(ECAL_HANDLE handle_, const char** rcv_buf_, int* rcv_bu
*
* @return True if succeeded.
**/
ECAL_API bool sub_receive_buffer(ECAL_HANDLE handle_, const char** rcv_buf_, int* rcv_buf_len_, long long* rcv_time_, const int timeout_);
ECAL_API bool sub_receive_buffer(ECAL_HANDLE handle_, const char** rcv_buf_, int* rcv_buf_len_, long long* rcv_time_, int timeout_);

/**
* @brief Add callback function for incoming receives.
Expand All @@ -340,7 +340,7 @@ ECAL_API bool sub_receive_buffer(ECAL_HANDLE handle_, const char** rcv_buf_, int
*
* @return True if succeeded.
**/
ECAL_API bool sub_add_receive_callback(ECAL_HANDLE handle_, const ReceiveCallbackCT callback_, void* par_);
ECAL_API bool sub_add_receive_callback(ECAL_HANDLE handle_, ReceiveCallbackCT callback_, void* par_);

/**
* @brief Remove callback function for incoming receives.
Expand All @@ -361,7 +361,7 @@ ECAL_API bool sub_rem_receive_callback(ECAL_HANDLE handle_);
*
* @return True if succeeded.
**/
ECAL_API bool sub_add_event_callback(ECAL_HANDLE handle_, enum eCAL_Subscriber_Event type_, const SubEventCallbackCT callback_, void* par_);
ECAL_API bool sub_add_event_callback(ECAL_HANDLE handle_, enum eCAL_Subscriber_Event type_, SubEventCallbackCT callback_, void* par_);

/**
* @brief Remove callback function for subscriber events.
Expand Down Expand Up @@ -403,7 +403,7 @@ ECAL_API bool dyn_json_sub_destroy(ECAL_HANDLE handle_);
*
* @return True if succeeded.
**/
ECAL_API bool dyn_json_sub_add_receive_callback(ECAL_HANDLE handle_, const ReceiveCallbackCT callback_, void* par_);
ECAL_API bool dyn_json_sub_add_receive_callback(ECAL_HANDLE handle_, ReceiveCallbackCT callback_, void* par_);

/**
* @brief Remove callback function for incoming receives.
Expand Down Expand Up @@ -452,7 +452,7 @@ ECAL_API bool server_destroy(ECAL_HANDLE handle_);
*
* @return True if succeeded.
**/
ECAL_API bool server_add_method_callback(ECAL_HANDLE handle_, const char* method_name_, const char* req_type_, const char* resp_type_, const MethodCallbackCT callback_, void* par_);
ECAL_API bool server_add_method_callback(ECAL_HANDLE handle_, const char* method_name_, const char* req_type_, const char* resp_type_, MethodCallbackCT callback_, void* par_);

/**
* @brief Remove server method callback.
Expand Down Expand Up @@ -503,7 +503,7 @@ ECAL_API bool client_set_hostname(ECAL_HANDLE handle_, const char* host_name_);
*
* @return True if succeeded.
**/
ECAL_API bool client_call_method(ECAL_HANDLE handle_, const char* method_name_, const char* request_, const int request_len_, const int timeout_);
ECAL_API bool client_call_method(ECAL_HANDLE handle_, const char* method_name_, const char* request_, int request_len_, int timeout_);

/**
* @brief Call method of this service (asynchronously with callback).
Expand All @@ -516,7 +516,7 @@ ECAL_API bool client_call_method(ECAL_HANDLE handle_, const char* method_name_,
*
* @return True if succeeded.
**/
ECAL_API bool client_call_method_async(ECAL_HANDLE handle_, const char* method_name_, const char* request_, const int request_len_, const int timeout_);
ECAL_API bool client_call_method_async(ECAL_HANDLE handle_, const char* method_name_, const char* request_, int request_len_, int timeout_);

/* TODO: not implemented and not used for now */
//ECAL_API client_add_response_callback
Expand Down Expand Up @@ -565,7 +565,7 @@ ECAL_API int mon_set_incl_filter(const char* filter_);
*
* @return Zero if succeeded.
**/
ECAL_API int mon_set_filter_state(const bool state_);
ECAL_API int mon_set_filter_state(bool state_);

/**
* @brief Get monitoring protobuf string.
Expand Down
6 changes: 3 additions & 3 deletions src/core/include/ecal/ecal_service_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace eCAL
eCallState call_state; //!< call state (see eCallState)
std::string response; //!< service response
};
typedef std::vector<SServiceResponse> ServiceResponseVecT; //!< vector of multiple service responses
using ServiceResponseVecT = std::vector<SServiceResponse>; //!< vector of multiple service responses

/**
* @brief Service method callback function type (low level server interface).
Expand All @@ -62,12 +62,12 @@ namespace eCAL
* @param request_ The request.
* @param response_ The response returned from the method call.
**/
typedef std::function<int(const std::string& method_, const std::string& req_type_, const std::string& resp_type_, const std::string& request_, std::string& response_)> MethodCallbackT;
using MethodCallbackT = std::function<int (const std::string &, const std::string &, const std::string &, const std::string &, std::string &)>;

/**
* @brief Service response callback function type (low level client interface).
*
* @param service_response_ Service response struct containing the (responding) server informations and the response itself.
**/
typedef std::function<void(const struct SServiceResponse& service_response_)> ResponseCallbackT;
using ResponseCallbackT = std::function<void (const struct SServiceResponse &)>;
}
10 changes: 5 additions & 5 deletions src/core/include/ecal/ecal_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ namespace eCAL
**/
struct ecal_clock
{
typedef std::chrono::nanoseconds duration;
typedef duration::rep rep;
typedef duration::period period;
typedef std::chrono::time_point<ecal_clock> time_point;
static const bool is_steady = false;
using duration = std::chrono::nanoseconds;
using rep = duration::rep;
using period = duration::period;
using time_point = std::chrono::time_point<ecal_clock>;
static const bool is_steady = false;

/**
* @brief Returns a time point representing the current point in eCAL time
Expand Down
2 changes: 1 addition & 1 deletion src/core/include/ecal/ecal_timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
namespace eCAL
{
class CTimerImpl;
typedef std::function<void(void)> TimerCallbackT;
using TimerCallbackT = std::function<void ()>;

/**
* @brief eCAL timer class.
Expand Down
12 changes: 3 additions & 9 deletions src/core/include/ecal/ecal_tlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,9 @@ namespace eCAL
**/
struct ECAL_API STLayer
{
STLayer()
{
sm_udp_mc = smode_none;
sm_shm = smode_none;
sm_tcp = smode_none;
}
eSendMode sm_udp_mc; //!< udp multicast
eSendMode sm_shm; //!< shared memory
eSendMode sm_tcp; //!< tcp
eSendMode sm_udp_mc{smode_none}; //!< udp multicast
eSendMode sm_shm{smode_none}; //!< shared memory
eSendMode sm_tcp{smode_none}; //!< tcp
};
}
}
1 change: 0 additions & 1 deletion src/core/include/ecal/ecal_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#pragma once

#include <ecal/ecal_deprecate.h>
#include <ecal/ecal_os.h>
#include <ecal/ecal_deprecate.h>
#include <ecal/ecal_types.h>
Expand Down
2 changes: 1 addition & 1 deletion src/core/include/ecal/msg/dynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace eCAL
{
public:
DynamicReflectionException(const std::string& message) : message_(message) {}
virtual const char* what() const throw() { return message_.c_str(); }
virtual const char* what() const noexcept { return message_.c_str(); }
private:
std::string message_;
};
Expand Down
8 changes: 3 additions & 5 deletions src/core/include/ecal/msg/protobuf/dynamic_json_subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,12 @@ namespace eCAL

inline CDynamicJSONSubscriber::CDynamicJSONSubscriber() :
m_created(false),
m_msg_decoder(nullptr),
m_msg_string()
m_msg_decoder(nullptr)
{}

inline CDynamicJSONSubscriber::CDynamicJSONSubscriber(const std::string& topic_name_) :
m_created(false),
m_msg_decoder(nullptr),
m_msg_string()
m_msg_decoder(nullptr)
{
Create(topic_name_);
}
Expand Down Expand Up @@ -249,7 +247,7 @@ namespace eCAL
options.always_print_primitive_fields = true;

std::string binary_input;
binary_input.assign((char*)data_->buf, static_cast<size_t>(data_->size));
binary_input.assign(static_cast<char*>(data_->buf), static_cast<size_t>(data_->size));
m_msg_string.clear();
auto status = google::protobuf::util::BinaryToJsonString(m_resolver.get(), m_topic_type_full, binary_input, &m_msg_string, options);
if (status.ok())
Expand Down
16 changes: 9 additions & 7 deletions src/core/include/ecal/msg/protobuf/dynamic_publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace eCAL
* @param topic_name_ Unique topic name.
* @param msg_ Protobuf message object.
**/
CDynamicPublisher(const std::string& topic_name_, std::shared_ptr<google::protobuf::Message> msg_)
CDynamicPublisher(const std::string& topic_name_, const std::shared_ptr<google::protobuf::Message>& msg_)
: CMsgPublisher<google::protobuf::Message>(topic_name_, GetTopicInformationFromMessage(msg_.get()))
, m_msg{ msg_ } {}

Expand All @@ -75,6 +75,11 @@ namespace eCAL
: CMsgPublisher<google::protobuf::Message>(topic_name_, GetTopicInformationFromMessage(CreateMessageByName(proto_type_name_).get()))
, m_msg{ CreateMessageByName(proto_type_name_) } {}

CDynamicPublisher(const CDynamicPublisher&) = delete;
CDynamicPublisher& operator=(const CDynamicPublisher&) = delete;
CDynamicPublisher(CDynamicPublisher&&) = default;
CDynamicPublisher& operator=(CDynamicPublisher&&) = default;

/**
* @brief Send message.
*
Expand Down Expand Up @@ -108,9 +113,9 @@ namespace eCAL
return std::dynamic_pointer_cast<T>(m_msg);
}

private:
size_t Send(const google::protobuf::Message& msg_, long long time_ = -1) = delete;

private:
SDataTypeInformation GetDataTypeInformation() const override
{
return GetTopicInformationFromMessage(m_msg.get());
Expand All @@ -133,6 +138,7 @@ namespace eCAL
static SDataTypeInformation GetTopicInformationFromMessage(const google::protobuf::Message* msg_ptr_)
{
assert(msg_ptr_);
if(msg_ptr_ == nullptr) return SDataTypeInformation();

SDataTypeInformation topic_info;
topic_info.encoding = "proto";
Expand All @@ -144,6 +150,7 @@ namespace eCAL
static std::string GetDescriptorFromMessage(const google::protobuf::Message* msg_ptr_)
{
assert(msg_ptr_);
if(msg_ptr_ == nullptr) return "";

const google::protobuf::Descriptor* desc = msg_ptr_->GetDescriptor();
google::protobuf::FileDescriptorSet pset;
Expand Down Expand Up @@ -182,11 +189,6 @@ namespace eCAL
return message;
}

CDynamicPublisher(const CDynamicPublisher&) = delete;
CDynamicPublisher& operator=(const CDynamicPublisher&) = delete;
CDynamicPublisher(CDynamicPublisher&&) = default;
CDynamicPublisher& operator=(CDynamicPublisher&&) = default;

std::shared_ptr<google::protobuf::Message> m_msg;
};
}
Expand Down
Loading