Skip to content

Commit

Permalink
clang-tidy + PubConfig fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
rex-schilasky committed May 2, 2024
1 parent 010bbdf commit 6818c2c
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 65 deletions.
1 change: 1 addition & 0 deletions ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ set(ecal_header_cmn
include/ecal/ecal_process.h
include/ecal/ecal_process_severity.h
include/ecal/ecal_publisher.h
include/ecal/ecal_publisher_config.h
include/ecal/ecal_server.h
include/ecal/ecal_service_info.h
include/ecal/ecal_subscriber.h
Expand Down
2 changes: 2 additions & 0 deletions ecal/core/include/ecal/ecal_publisher_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include <ecal/ecal_tlayer.h>

#include <cstddef>

namespace eCAL
{
struct ECAL_API SHMPubConfig
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/include/ecal/msg/capnproto/publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace eCAL
* @param topic_name_ Unique topic name.
* @param config_ Optional configuration parameters.
**/
CPublisher(const std::string& topic_name_, const eCAL::CPublisher::Config& config_ = {})
CPublisher(const std::string& topic_name_, const eCAL::PubConfig& config_ = {})
: eCAL::CPublisher(topic_name_, GetDataTypeInformation(), config_)
, builder(std::make_unique<capnp::MallocMessageBuilder>())
, root_builder(builder->initRoot<message_type>())
Expand Down Expand Up @@ -150,7 +150,7 @@ namespace eCAL
*
* @return True if it succeeds, false if it fails.
**/
bool Create(const std::string& topic_name_, const eCAL::CPublisher::Config& config_ = {})
bool Create(const std::string& topic_name_, const eCAL::PubConfig& config_ = {})
{
return(eCAL::CPublisher::Create(topic_name_, GetDataTypeInformation(), config_));
}
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/include/ecal/msg/flatbuffers/publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace eCAL
* @param topic_name_ Unique topic name.
* @param config_ Optional configuration parameters.
**/
CPublisher(const std::string& topic_name_, const eCAL::CPublisher::Config& config_ = {}) : CMsgPublisher<T>(topic_name_, GetDataTypeInformation(), config_)
CPublisher(const std::string& topic_name_, const eCAL::PubConfig& config_ = {}) : CMsgPublisher<T>(topic_name_, GetDataTypeInformation(), config_)
{
}

Expand Down Expand Up @@ -85,7 +85,7 @@ namespace eCAL
*
* @return True if it succeeds, false if it fails.
**/
bool Create(const std::string& topic_name_, const eCAL::CPublisher::Config& config_ = {})
bool Create(const std::string& topic_name_, const eCAL::PubConfig& config_ = {})
{
return(CMsgPublisher<T>::Create(topic_name_, GetDataTypeInformation(), config_));
}
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/include/ecal/msg/messagepack/publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace eCAL
* @param topic_name_ Unique topic name.
* @param config_ Optional configuration parameters.
**/
CPublisher(const std::string& topic_name_, const eCAL::CPublisher::Config& config_ = {}) : CMsgPublisher<T>(topic_name_, GetDataTypeInformation(), config_)
CPublisher(const std::string& topic_name_, const eCAL::PubConfig& config_ = {}) : CMsgPublisher<T>(topic_name_, GetDataTypeInformation(), config_)
{
}

Expand Down Expand Up @@ -88,7 +88,7 @@ namespace eCAL
*
* @return True if it succeeds, false if it fails.
**/
bool Create(const std::string& topic_name_, const eCAL::CPublisher::Config& config_ = {})
bool Create(const std::string& topic_name_, const eCAL::PubConfig& config_ = {})
{
return(CMsgPublisher<T>::Create(topic_name_, GetDataTypeInformation(), config_));
}
Expand Down
16 changes: 9 additions & 7 deletions ecal/tests/cpp/pubsub_test/src/pubsub_multibuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@

#include <gtest/gtest.h>

#define CMN_REGISTRATION_REFRESH 1000
#define DATA_FLOW_TIME 50
#define PAYLOAD_SIZE 1024
enum {
CMN_REGISTRATION_REFRESH_MS = 1000,
DATA_FLOW_TIME_MS = 50,
PAYLOAD_SIZE_BYTE = 1024
};

// a binary payload object for testing
// full (WriteFull) and partial (WriteModified) writing
Expand Down Expand Up @@ -68,7 +70,7 @@ class CBinaryPayload : public eCAL::CPayloadWriter
std::vector<char> multibuffer_pub_sub_test(int buffer_count, bool zero_copy, int publications, int bytes_to_read)
{
// create payload
CBinaryPayload binary_payload(PAYLOAD_SIZE);
CBinaryPayload binary_payload(PAYLOAD_SIZE_BYTE);

// create subscriber for topic "A"
eCAL::CSubscriber sub("A");
Expand Down Expand Up @@ -106,13 +108,13 @@ std::vector<char> multibuffer_pub_sub_test(int buffer_count, bool zero_copy, int
EXPECT_EQ(true, sub.AddReceiveCallback(lambda));

// let's match them
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH);
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS);

// run publications
for (int i = 0; i < publications; ++i)
{
EXPECT_EQ(PAYLOAD_SIZE, pub.Send(binary_payload));
eCAL::Process::SleepMS(DATA_FLOW_TIME);
EXPECT_EQ(PAYLOAD_SIZE_BYTE, pub.Send(binary_payload));
eCAL::Process::SleepMS(DATA_FLOW_TIME_MS);
}

return received_content;
Expand Down
8 changes: 5 additions & 3 deletions ecal/tests/cpp/pubsub_test/src/pubsub_receive_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@

#include <gtest/gtest.h>

#define CMN_REGISTRATION_REFRESH 1000
enum {
CMN_REGISTRATION_REFRESH_MS = 1000
};

using namespace std::chrono_literals;

Expand Down Expand Up @@ -76,7 +78,7 @@ TEST(core_cpp_pubsub, TimingSubscriberReceive)
eCAL::string::CSubscriber<std::string> sub("CLOCK");

// let's match them
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH);
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS);

// Send nothing and make sure the functions return as specified
std::string received;
Expand Down Expand Up @@ -173,7 +175,7 @@ TEST(core_cpp_pubsub, SporadicEmptyReceives)
eCAL::string::CSubscriber<std::string> sub("CLOCK");

// let's match them
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH);
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS);

// start publishing thread
std::atomic<bool> pub_stop(false);
Expand Down
66 changes: 34 additions & 32 deletions ecal/tests/cpp/pubsub_test/src/pubsub_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@

#include <gtest/gtest.h>

#define CMN_REGISTRATION_REFRESH 1000
#define DATA_FLOW_TIME 50
#define PAYLOAD_SIZE 1024
enum {
CMN_REGISTRATION_REFRESH_MS = 1000,
DATA_FLOW_TIME_MS = 50,
PAYLOAD_SIZE_BYTE = 1024
};

namespace
{
Expand Down Expand Up @@ -69,7 +71,7 @@ TEST(core_cpp_pubsub, LeakedPubSub)
eCAL::CPublisher pub("foo");

// let's match them
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH);
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS);

// start publishing thread
std::atomic<bool> pub_stop(false);
Expand Down Expand Up @@ -201,7 +203,7 @@ TEST(core_cpp_pubsub, CreateDestroy)
TEST(core_cpp_pubsub, SimpleMessage1)
{
// default send / receive strings
std::string send_s = CreatePayLoad(PAYLOAD_SIZE);
std::string send_s = CreatePayLoad(PAYLOAD_SIZE_BYTE);
std::string recv_s;

// initialize eCAL API
Expand All @@ -217,20 +219,20 @@ TEST(core_cpp_pubsub, SimpleMessage1)
eCAL::CSubscriber sub("foo");

// let's match them
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH);
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS);

// send content
EXPECT_EQ(send_s.size(), pub.Send(send_s));

// receive content with DATA_FLOW_TIME ms timeout
// receive content with DATA_FLOW_TIME_MS timeout
recv_s.clear();
EXPECT_EQ(true, sub.ReceiveBuffer(recv_s, nullptr, DATA_FLOW_TIME));
EXPECT_EQ(true, sub.ReceiveBuffer(recv_s, nullptr, DATA_FLOW_TIME_MS));
EXPECT_EQ(send_s.size(), recv_s.size());

// receive content with DATA_FLOW_TIME ms timeout
// receive content with DATA_FLOW_TIME_MS timeout
// should return because no new publishing
recv_s.clear();
EXPECT_EQ(false, sub.ReceiveBuffer(recv_s, nullptr, DATA_FLOW_TIME));
EXPECT_EQ(false, sub.ReceiveBuffer(recv_s, nullptr, DATA_FLOW_TIME_MS));
EXPECT_EQ(0, recv_s.size());

// destroy publisher
Expand All @@ -246,7 +248,7 @@ TEST(core_cpp_pubsub, SimpleMessage1)
TEST(core_cpp_pubsub, SimpleMessage2)
{
// default send / receive strings
std::string send_s = CreatePayLoad(PAYLOAD_SIZE);
std::string send_s = CreatePayLoad(PAYLOAD_SIZE_BYTE);
std::string recv_s;

// initialize eCAL API
Expand All @@ -262,14 +264,14 @@ TEST(core_cpp_pubsub, SimpleMessage2)
eCAL::CPublisher pub("foo");

// let's match them
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH);
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS);

// send content
EXPECT_EQ(send_s.size(), pub.Send(send_s));

// receive content with DATA_FLOW_TIME ms timeout
// receive content with DATA_FLOW_TIME_MS timeout
recv_s.clear();
EXPECT_EQ(true, sub.ReceiveBuffer(recv_s, nullptr, DATA_FLOW_TIME));
EXPECT_EQ(true, sub.ReceiveBuffer(recv_s, nullptr, DATA_FLOW_TIME_MS));
EXPECT_EQ(send_s.size(), recv_s.size());

// destroy publisher
Expand All @@ -285,7 +287,7 @@ TEST(core_cpp_pubsub, SimpleMessage2)
TEST(core_cpp_pubsub, SimpleMessageCB)
{
// default send string
std::string send_s = CreatePayLoad(PAYLOAD_SIZE);
std::string send_s = CreatePayLoad(PAYLOAD_SIZE_BYTE);

// initialize eCAL API
eCAL::Initialize(0, nullptr, "pubsub_test");
Expand All @@ -303,14 +305,14 @@ TEST(core_cpp_pubsub, SimpleMessageCB)
EXPECT_EQ(true, sub.AddReceiveCallback(std::bind(OnReceive, std::placeholders::_1, std::placeholders::_2)));

// let's match them
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH);
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS);

// send content
g_callback_received_bytes = 0;
EXPECT_EQ(send_s.size(), pub.Send(send_s));

// let the data flow
eCAL::Process::SleepMS(DATA_FLOW_TIME);
eCAL::Process::SleepMS(DATA_FLOW_TIME_MS);

// check callback receive
EXPECT_EQ(send_s.size(), g_callback_received_bytes);
Expand All @@ -323,7 +325,7 @@ TEST(core_cpp_pubsub, SimpleMessageCB)
EXPECT_EQ(send_s.size(), pub.Send(send_s));

// let the data flow
eCAL::Process::SleepMS(DATA_FLOW_TIME);
eCAL::Process::SleepMS(DATA_FLOW_TIME_MS);

// check callback receive
EXPECT_EQ(0, g_callback_received_bytes);
Expand All @@ -336,7 +338,7 @@ TEST(core_cpp_pubsub, SimpleMessageCB)
EXPECT_EQ(send_s.size(), pub.Send(send_s));

// let the data flow
eCAL::Process::SleepMS(DATA_FLOW_TIME);
eCAL::Process::SleepMS(DATA_FLOW_TIME_MS);

// check callback receive
EXPECT_EQ(send_s.size(), g_callback_received_bytes);
Expand All @@ -349,7 +351,7 @@ TEST(core_cpp_pubsub, SimpleMessageCB)
EXPECT_EQ(send_s.size(), pub.Send(send_s));

// let the data flow
eCAL::Process::SleepMS(DATA_FLOW_TIME);
eCAL::Process::SleepMS(DATA_FLOW_TIME_MS);

// check callback receive
EXPECT_EQ(0, g_callback_received_bytes);
Expand All @@ -364,7 +366,7 @@ TEST(core_cpp_pubsub, SimpleMessageCB)
TEST(core_cpp_pubsub, DynamicSizeCB)
{
// default send string
std::string send_s = CreatePayLoad(PAYLOAD_SIZE);
std::string send_s = CreatePayLoad(PAYLOAD_SIZE_BYTE);

// initialize eCAL API
eCAL::Initialize(0, nullptr, "pubsub_test");
Expand All @@ -382,27 +384,27 @@ TEST(core_cpp_pubsub, DynamicSizeCB)
EXPECT_EQ(true, sub.AddReceiveCallback(std::bind(OnReceive, std::placeholders::_1, std::placeholders::_2)));

// let's match them
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH);
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS);

// send content
g_callback_received_bytes = 0;
EXPECT_EQ(send_s.size(), pub.Send(send_s));

// let the data flow
eCAL::Process::SleepMS(DATA_FLOW_TIME);
eCAL::Process::SleepMS(DATA_FLOW_TIME_MS);

// check callback receive
EXPECT_EQ(send_s.size(), g_callback_received_bytes);

// increase payload size
send_s = CreatePayLoad(PAYLOAD_SIZE*10);
send_s = CreatePayLoad(PAYLOAD_SIZE_BYTE*10);

// send content
g_callback_received_bytes = 0;
EXPECT_EQ(send_s.size(), pub.Send(send_s));

// let the data flow
eCAL::Process::SleepMS(DATA_FLOW_TIME);
eCAL::Process::SleepMS(DATA_FLOW_TIME_MS);

// check callback receive
EXPECT_EQ(send_s.size(), g_callback_received_bytes);
Expand All @@ -420,7 +422,7 @@ TEST(core_cpp_pubsub, DynamicSizeCB)
TEST(core_cpp_pubsub, DynamicCreate)
{
// default send string
std::string send_s = CreatePayLoad(PAYLOAD_SIZE);
std::string send_s = CreatePayLoad(PAYLOAD_SIZE_BYTE);

// initialize eCAL API
eCAL::Initialize(0, nullptr, "pubsub_test");
Expand All @@ -440,14 +442,14 @@ TEST(core_cpp_pubsub, DynamicCreate)
EXPECT_EQ(true, sub->AddReceiveCallback(std::bind(OnReceive, std::placeholders::_1, std::placeholders::_2)));

// let's match them
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH);
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS);

// send content
g_callback_received_bytes = 0;
EXPECT_EQ(send_s.size(), pub->Send(send_s));

// let the data flow
eCAL::Process::SleepMS(DATA_FLOW_TIME);
eCAL::Process::SleepMS(DATA_FLOW_TIME_MS);

// check callback receive
EXPECT_EQ(send_s.size(), g_callback_received_bytes);
Expand All @@ -463,14 +465,14 @@ TEST(core_cpp_pubsub, DynamicCreate)
EXPECT_EQ(true, sub->AddReceiveCallback(std::bind(OnReceive, std::placeholders::_1, std::placeholders::_2)));

// let's match them
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH);
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS);

// send content
g_callback_received_bytes = 0;
EXPECT_EQ(send_s.size(), pub->Send(send_s));

// let the data flow
eCAL::Process::SleepMS(DATA_FLOW_TIME);
eCAL::Process::SleepMS(DATA_FLOW_TIME_MS);

// check callback receive
EXPECT_EQ(send_s.size(), g_callback_received_bytes);
Expand All @@ -485,14 +487,14 @@ TEST(core_cpp_pubsub, DynamicCreate)
EXPECT_EQ(true, sub->AddReceiveCallback(std::bind(OnReceive, std::placeholders::_1, std::placeholders::_2)));

// let's match them
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH);
eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS);

// send content
g_callback_received_bytes = 0;
EXPECT_EQ(send_s.size(), pub->Send(send_s));

// let the data flow
eCAL::Process::SleepMS(DATA_FLOW_TIME);
eCAL::Process::SleepMS(DATA_FLOW_TIME_MS);

// check callback receive
EXPECT_EQ(send_s.size(), g_callback_received_bytes);
Expand Down
Loading

0 comments on commit 6818c2c

Please sign in to comment.