Skip to content

Commit

Permalink
PubConfig -> Publisher::Configuration
Browse files Browse the repository at this point in the history
SHMConfig -> Publisher::SHM::Configuration
UDPConfig -> Publisher::UDP::Configuration
TCPConfig -> Publisher::TCP::Configuration
  • Loading branch information
rex-schilasky committed May 6, 2024
1 parent 6818c2c commit eb93882
Show file tree
Hide file tree
Showing 31 changed files with 106 additions and 91 deletions.
6 changes: 3 additions & 3 deletions ecal/core/include/ecal/ecal_publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ namespace eCAL
* @param data_type_info_ Topic data type information (encoding, type, descriptor).
* @param config_ Optional configuration parameters.
**/
ECAL_API CPublisher(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const PubConfig& config_ = {});
ECAL_API CPublisher(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const Publisher::Configuration& config_ = {});

/**
* @brief Constructor.
*
* @param topic_name_ Unique topic name.
* @param config_ Optional configuration parameters.
**/
ECAL_API explicit CPublisher(const std::string& topic_name_, const PubConfig& config_ = {});
ECAL_API explicit CPublisher(const std::string& topic_name_, const Publisher::Configuration& config_ = {});

/**
* @brief Destructor.
Expand Down Expand Up @@ -128,7 +128,7 @@ namespace eCAL
*
* @return True if it succeeds, false if it fails.
**/
ECAL_API bool Create(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const PubConfig& config_ = {});
ECAL_API bool Create(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const Publisher::Configuration& config_ = {});

/**
* @brief Creates this object.
Expand Down
66 changes: 39 additions & 27 deletions ecal/core/include/ecal/ecal_publisher_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,49 @@

namespace eCAL
{
struct ECAL_API SHMPubConfig
namespace Publisher
{
TLayer::eSendMode send_mode = TLayer::smode_auto; //!< shm layer send mode (default auto)
bool zero_copy_mode = false; //!< enable zero copy shared memory transport mode
int acknowledge_timeout_ms = 0; /*!< force connected subscribers to send acknowledge event after processing the message
the publisher send call is blocked on this event with this timeout (0 == no handshake) */
size_t memfile_min_size_bytes = 4096; //!< default memory file size for new publisher
size_t memfile_reserve_percent = 50; //!< dynamic file size reserve before recreating memory file if topic size changes
size_t memfile_buffer_count = 1; //!< maximum number of used buffers (needs to be greater than 1, default = 1)
};
namespace SHM
{
struct ECAL_API Configuration
{
TLayer::eSendMode send_mode = TLayer::smode_auto; //!< shm layer send mode (default auto)
bool zero_copy_mode = false; //!< enable zero copy shared memory transport mode
int acknowledge_timeout_ms = 0; /*!< force connected subscribers to send acknowledge event after processing the message
the publisher send call is blocked on this event with this timeout (0 == no handshake) */
size_t memfile_min_size_bytes = 4096; //!< default memory file size for new publisher
size_t memfile_reserve_percent = 50; //!< dynamic file size reserve before recreating memory file if topic size changes
size_t memfile_buffer_count = 1; //!< maximum number of used buffers (needs to be greater than 1, default = 1)
};
}

struct ECAL_API UDPPubConfig
{
TLayer::eSendMode send_mode = TLayer::smode_auto; //!< udp layer send mode (default auto)
int sndbuf_size_bytes = (5*1024*1024); //!< udp send buffer size in bytes (default 5MB)
};
namespace UDP
{
struct ECAL_API Configuration
{
TLayer::eSendMode send_mode = TLayer::smode_auto; //!< udp layer send mode (default auto)
int sndbuf_size_bytes = (5*1024*1024); //!< udp send buffer size in bytes (default 5MB)
};
}

struct ECAL_API TCPPubConfig
{
TLayer::eSendMode send_mode = TLayer::smode_off; //!< tcp layer send mode (default off)
};
namespace TCP
{
struct ECAL_API Configuration
{
TLayer::eSendMode send_mode = TLayer::smode_off; //!< tcp layer send mode (default off)
};
}

struct ECAL_API PubConfig
{
PubConfig();
struct ECAL_API Configuration
{
Configuration();

SHMPubConfig shm;
UDPPubConfig udp;
TCPPubConfig tcp;
SHM::Configuration shm;
UDP::Configuration udp;
TCP::Configuration tcp;

bool share_topic_type = true;
bool share_topic_description = true;
};
bool share_topic_type = true; //!< share topic type via registration
bool share_topic_description = true; //!< share topic description via registration
};
}
}
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::PubConfig& config_ = {})
CPublisher(const std::string& topic_name_, const eCAL::Publisher::Configuration& 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::PubConfig& config_ = {})
bool Create(const std::string& topic_name_, const eCAL::Publisher::Configuration& 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::PubConfig& config_ = {}) : CMsgPublisher<T>(topic_name_, GetDataTypeInformation(), config_)
CPublisher(const std::string& topic_name_, const eCAL::Publisher::Configuration& 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::PubConfig& config_ = {})
bool Create(const std::string& topic_name_, const eCAL::Publisher::Configuration& 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::PubConfig& config_ = {}) : CMsgPublisher<T>(topic_name_, GetDataTypeInformation(), config_)
CPublisher(const std::string& topic_name_, const eCAL::Publisher::Configuration& 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::PubConfig& config_ = {})
bool Create(const std::string& topic_name_, const eCAL::Publisher::Configuration& config_ = {})
{
return(CMsgPublisher<T>::Create(topic_name_, GetDataTypeInformation(), config_));
}
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/include/ecal/msg/protobuf/dynamic_publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace eCAL
* @param msg_ Protobuf message object.
* @param config_ Optional configuration parameters.
**/
CDynamicPublisher(const std::string& topic_name_, const std::shared_ptr<google::protobuf::Message>& msg_, const eCAL::PubConfig& config_ = {})
CDynamicPublisher(const std::string& topic_name_, const std::shared_ptr<google::protobuf::Message>& msg_, const eCAL::Publisher::Configuration& config_ = {})
: CMsgPublisher<google::protobuf::Message>(topic_name_, GetTopicInformationFromMessage(msg_.get()), config_)
, m_msg{ msg_ } {}

Expand Down
4 changes: 2 additions & 2 deletions ecal/core/include/ecal/msg/protobuf/publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace eCAL
// where the vtable is not created yet, or it's destructed.
// Probably we can handle the Message publishers differently. One message publisher class and then one class for payloads and getting type
// descriptor information.
explicit CPublisher(const std::string& topic_name_, const eCAL::PubConfig& config_ = {}) : eCAL::CPublisher(topic_name_, CPublisher::GetDataTypeInformation(), config_)
explicit CPublisher(const std::string& topic_name_, const eCAL::Publisher::Configuration& config_ = {}) : eCAL::CPublisher(topic_name_, CPublisher::GetDataTypeInformation(), config_)
{
}

Expand Down Expand Up @@ -144,7 +144,7 @@ namespace eCAL
*
* @return True if it succeeds, false if it fails.
**/
bool Create(const std::string& topic_name_, const eCAL::PubConfig& config_ = {})
bool Create(const std::string& topic_name_, const eCAL::Publisher::Configuration& config_ = {})
{
return(eCAL::CPublisher::Create(topic_name_, GetDataTypeInformation(), config_));
}
Expand Down
6 changes: 3 additions & 3 deletions ecal/core/include/ecal/msg/publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace eCAL
* @param data_type_info_ Topic data type information (encoding, type, descriptor).
* @param config_ Optional configuration parameters.
**/
CMsgPublisher(const std::string& topic_name_, const struct SDataTypeInformation& data_type_info_, const PubConfig& config_ = {}) : CPublisher(topic_name_, data_type_info_, config_)
CMsgPublisher(const std::string& topic_name_, const struct SDataTypeInformation& data_type_info_, const Publisher::Configuration& config_ = {}) : CPublisher(topic_name_, data_type_info_, config_)
{
}

Expand All @@ -74,7 +74,7 @@ namespace eCAL
* @param topic_name_ Unique topic name.
* @param config_ Optional configuration parameters.
**/
explicit CMsgPublisher(const std::string& topic_name_, const PubConfig& config_ = {}) : CMsgPublisher(topic_name_, GetDataTypeInformation(), config_)
explicit CMsgPublisher(const std::string& topic_name_, const Publisher::Configuration& config_ = {}) : CMsgPublisher(topic_name_, GetDataTypeInformation(), config_)
{
}

Expand Down Expand Up @@ -109,7 +109,7 @@ namespace eCAL
*
* @return True if it succeeds, false if it fails.
**/
bool Create(const std::string& topic_name_, const struct SDataTypeInformation& data_type_info_, const PubConfig& config_ = {})
bool Create(const std::string& topic_name_, const struct SDataTypeInformation& data_type_info_, const Publisher::Configuration& config_ = {})
{
return(CPublisher::Create(topic_name_, data_type_info_, config_));
}
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/include/ecal/msg/string/publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace eCAL

// call the function via its class because it's a virtual function that is called in constructor/destructor,-
// where the vtable is not created yet, or it's destructed.
explicit CPublisher(const std::string& topic_name_, const eCAL::PubConfig& config_ = {}) : CMsgPublisher<T>(topic_name_, GetDataTypeInformation(), config_)
explicit CPublisher(const std::string& topic_name_, const eCAL::Publisher::Configuration& config_ = {}) : CMsgPublisher<T>(topic_name_, GetDataTypeInformation(), config_)
{
}

Expand Down Expand Up @@ -92,7 +92,7 @@ namespace eCAL
*
* @return True if it succeeds, false if it fails.
**/
bool Create(const std::string& topic_name_, const eCAL::PubConfig& config_ = {})
bool Create(const std::string& topic_name_, const eCAL::Publisher::Configuration& config_ = {})
{
return(CMsgPublisher<T>::Create(topic_name_, GetDataTypeInformation(), config_));
}
Expand Down
6 changes: 3 additions & 3 deletions ecal/core/src/pubsub/ecal_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ namespace eCAL
{
}

CPublisher::CPublisher(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const PubConfig& config_)
CPublisher::CPublisher(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const Publisher::Configuration& config_)
: CPublisher()
{
CPublisher::Create(topic_name_, data_type_info_, config_);
}

CPublisher::CPublisher(const std::string& topic_name_, const PubConfig& config_)
CPublisher::CPublisher(const std::string& topic_name_, const Publisher::Configuration& config_)
: CPublisher(topic_name_, SDataTypeInformation{}, config_)
{}

Expand Down Expand Up @@ -90,7 +90,7 @@ namespace eCAL
return *this;
}

bool CPublisher::Create(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const PubConfig& config_)
bool CPublisher::Create(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const Publisher::Configuration& config_)
{
if (m_created) return(false);
if (topic_name_.empty()) return(false);
Expand Down
33 changes: 18 additions & 15 deletions ecal/core/src/pubsub/ecal_publisher_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,27 @@

namespace eCAL
{
PubConfig::PubConfig() :
share_topic_type(eCAL::Config::IsTopicTypeSharingEnabled()),
share_topic_description(eCAL::Config::IsTopicDescriptionSharingEnabled())
namespace Publisher
{
// shm config
shm.send_mode = eCAL::Config::GetPublisherShmMode();
shm.zero_copy_mode = eCAL::Config::IsMemfileZerocopyEnabled();
shm.acknowledge_timeout_ms = eCAL::Config::GetMemfileAckTimeoutMs();
Configuration::Configuration() :
share_topic_type(eCAL::Config::IsTopicTypeSharingEnabled()),
share_topic_description(eCAL::Config::IsTopicDescriptionSharingEnabled())
{
// shm config
shm.send_mode = eCAL::Config::GetPublisherShmMode();
shm.zero_copy_mode = eCAL::Config::IsMemfileZerocopyEnabled();
shm.acknowledge_timeout_ms = eCAL::Config::GetMemfileAckTimeoutMs();

shm.memfile_min_size_bytes = eCAL::Config::GetMemfileMinsizeBytes();
shm.memfile_reserve_percent = eCAL::Config::GetMemfileOverprovisioningPercentage();
shm.memfile_buffer_count = eCAL::Config::GetMemfileBufferCount();
shm.memfile_min_size_bytes = eCAL::Config::GetMemfileMinsizeBytes();
shm.memfile_reserve_percent = eCAL::Config::GetMemfileOverprovisioningPercentage();
shm.memfile_buffer_count = eCAL::Config::GetMemfileBufferCount();

// udp config
udp.send_mode = eCAL::Config::GetPublisherUdpMulticastMode();
udp.sndbuf_size_bytes = eCAL::Config::GetUdpMulticastSndBufSizeBytes();
// udp config
udp.send_mode = eCAL::Config::GetPublisherUdpMulticastMode();
udp.sndbuf_size_bytes = eCAL::Config::GetUdpMulticastSndBufSizeBytes();

// tcp config
tcp.send_mode = eCAL::Config::GetPublisherTcpMode();
// tcp config
tcp.send_mode = eCAL::Config::GetPublisherTcpMode();
}
}
}
2 changes: 1 addition & 1 deletion ecal/core/src/readwrite/ecal_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace std

namespace eCAL
{
CDataWriter::CDataWriter(const std::string& topic_name_, const SDataTypeInformation& topic_info_, const PubConfig& config_) :
CDataWriter::CDataWriter(const std::string& topic_name_, const SDataTypeInformation& topic_info_, const Publisher::Configuration& config_) :
m_host_name(Process::GetHostName()),
m_host_group_name(Process::GetHostGroupName()),
m_pid(Process::GetProcessID()),
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/src/readwrite/ecal_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace eCAL
}
};

CDataWriter(const std::string& topic_name_, const SDataTypeInformation& topic_info_, const PubConfig& config_ = {});
CDataWriter(const std::string& topic_name_, const SDataTypeInformation& topic_info_, const Publisher::Configuration& config_ = {});
~CDataWriter();

bool SetDataTypeInformation(const SDataTypeInformation& topic_info_);
Expand Down Expand Up @@ -148,7 +148,7 @@ namespace eCAL
SDataTypeInformation m_topic_info;
std::map<std::string, std::string> m_attr;
size_t m_topic_size;
PubConfig m_config;
Publisher::Configuration m_config;

std::vector<char> m_payload_buffer;

Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/readwrite/shm/ecal_writer_shm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace eCAL
{
const std::string CDataWriterSHM::m_memfile_base_name = "ecal_";

CDataWriterSHM::CDataWriterSHM(const std::string& /*host_name_*/, const std::string& topic_name_, const std::string& /*topic_id_*/, const SHMPubConfig& shm_config_) :
CDataWriterSHM::CDataWriterSHM(const std::string& /*host_name_*/, const std::string& topic_name_, const std::string& /*topic_id_*/, const Publisher::SHM::Configuration& shm_config_) :
m_config(shm_config_)
{
m_topic_name = topic_name_;
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/src/readwrite/shm/ecal_writer_shm.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace eCAL
class CDataWriterSHM : public CDataWriterBase
{
public:
CDataWriterSHM(const std::string& host_name_, const std::string& topic_name_, const std::string& topic_id_, const SHMPubConfig& shm_config_);
CDataWriterSHM(const std::string& host_name_, const std::string& topic_name_, const std::string& topic_id_, const Publisher::SHM::Configuration& shm_config_);

SWriterInfo GetInfo() override;

Expand All @@ -53,7 +53,7 @@ namespace eCAL
Registration::ConnectionPar GetConnectionParameter() override;

protected:
SHMPubConfig m_config;
Publisher::SHM::Configuration m_config;

size_t m_write_idx = 0;
std::vector<std::shared_ptr<CSyncMemoryFile>> m_memory_file_vec;
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/readwrite/tcp/ecal_writer_tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace eCAL
std::mutex CDataWriterTCP::g_tcp_writer_executor_mtx;
std::shared_ptr<tcp_pubsub::Executor> CDataWriterTCP::g_tcp_writer_executor;

CDataWriterTCP::CDataWriterTCP(const std::string& host_name_, const std::string& topic_name_, const std::string& topic_id_, const TCPPubConfig& tcp_config_) :
CDataWriterTCP::CDataWriterTCP(const std::string& host_name_, const std::string& topic_name_, const std::string& topic_id_, const Publisher::TCP::Configuration& tcp_config_) :
m_config(tcp_config_)
{
{
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/src/readwrite/tcp/ecal_writer_tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace eCAL
class CDataWriterTCP : public CDataWriterBase
{
public:
CDataWriterTCP(const std::string& host_name_, const std::string& topic_name_, const std::string& topic_id_, const TCPPubConfig& tcp_config_);
CDataWriterTCP(const std::string& host_name_, const std::string& topic_name_, const std::string& topic_id_, const Publisher::TCP::Configuration& tcp_config_);

SWriterInfo GetInfo() override;

Expand All @@ -49,7 +49,7 @@ namespace eCAL
Registration::ConnectionPar GetConnectionParameter() override;

private:
TCPPubConfig m_config;
Publisher::TCP::Configuration m_config;

std::vector<char> m_header_buffer;

Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/readwrite/udp/ecal_writer_udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

namespace eCAL
{
CDataWriterUdpMC::CDataWriterUdpMC(const std::string& host_name_, const std::string& topic_name_, const std::string& topic_id_, const UDPPubConfig& udp_config_) :
CDataWriterUdpMC::CDataWriterUdpMC(const std::string& host_name_, const std::string& topic_name_, const std::string& topic_id_, const Publisher::UDP::Configuration& udp_config_) :
m_config(udp_config_)
{
m_host_name = host_name_;
Expand Down
Loading

0 comments on commit eb93882

Please sign in to comment.