Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
  • Loading branch information
JesusPoderoso committed Mar 25, 2024
1 parent d36ae54 commit 90c3c52
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 15 deletions.
61 changes: 47 additions & 14 deletions examples/cpp/configuration/CLIParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace examples {
namespace configuration {

using namespace eprosima::fastdds::dds;
using Log;
using dds::Log;

class CLIParser
{
Expand Down Expand Up @@ -306,10 +306,10 @@ class CLIParser
try
{
int input = std::stoi(argv[i]);
if (input < 0 || input > 232)
if (input < 1 || input > 255)
{
throw std::out_of_range("domain argument " + std::string(
argv[i]) + " out of range [0, 232].");
argv[i]) + " out of range [1, 255].");
}
else
{
Expand Down Expand Up @@ -501,7 +501,7 @@ class CLIParser
try
{
int input = std::stoi(argv[i]);
if (input < 1 || input > max_duration)
if (input < 1 || static_cast<long>(input) > static_cast<long>(max_duration))
{
throw std::out_of_range("deadline argument " + std::string(
argv[i]) + " out of range [1, " + std::to_string(
Expand Down Expand Up @@ -551,7 +551,7 @@ class CLIParser
try
{
int input = std::stoi(argv[i]);
if (input < 1 || input > max_duration)
if (input < 1 || static_cast<long>(input) > static_cast<long>(max_duration))
{
throw std::out_of_range("lifespan argument " + std::string(
argv[i]) + " out of range [1, " + std::to_string(
Expand Down Expand Up @@ -587,7 +587,7 @@ class CLIParser
try
{
int input = std::stoi(argv[i]);
if (input < 1 || input > max_duration)
if (input < 1 || static_cast<long>(input) > static_cast<long>(max_duration))
{
throw std::out_of_range("liveliness argument " + std::string(
argv[i]) + " out of range [1, " + std::to_string(
Expand Down Expand Up @@ -639,7 +639,7 @@ class CLIParser
}
else
{
EPROSIMA_LOG_ERROR(CLI_PARSER, "parsing liveliness-kind argument");
EPROSIMA_LOG_ERROR(CLI_PARSER, "parsing liveliness-kind argument " + kind);
print_help(EXIT_FAILURE);
}
}
Expand All @@ -656,7 +656,7 @@ class CLIParser
try
{
int input = std::stoi(argv[i]);
if (input < 1 || input > max_duration)
if (input < 1 || static_cast<long>(input) > static_cast<long>(max_duration))
{
throw std::out_of_range("liveliness-assert argument " + std::string(
argv[i]) + " out of range [1, " + std::to_string(
Expand Down Expand Up @@ -713,7 +713,7 @@ class CLIParser
try
{
int input = std::stoi(argv[i]);
if (input < 1 || input > max_duration)
if (input < 1 || static_cast<long>(input) > static_cast<long>(max_duration))
{
throw std::out_of_range("wait argument " + std::string(
argv[i]) + " out of range [1, " + std::to_string(
Expand Down Expand Up @@ -757,7 +757,7 @@ class CLIParser
try
{
int input = std::stoi(argv[i]);
if (input < 1 || input > std::numeric_limits<uint32_t>::max())
if (input < 1 || static_cast<long>(input) > static_cast<long>(std::numeric_limits<uint32_t>::max()))
{
throw std::out_of_range("strength argument " + std::string(
argv[i]) + " out of range [1, " +
Expand Down Expand Up @@ -802,7 +802,7 @@ class CLIParser
try
{
int input = std::stoi(argv[i]);
if (input < 1 || input > max_duration)
if (input < 1 || static_cast<long>(input) > static_cast<long>(max_duration))
{
throw std::out_of_range("interval argument " + std::string(
argv[i]) + " out of range [1, " + std::to_string(
Expand Down Expand Up @@ -858,7 +858,7 @@ class CLIParser
try
{
int input = std::stoi(argv[i]);
if (input < 1 || input > max_duration)
if (input < 1 || static_cast<long>(input) > static_cast<long>(max_duration))
{
throw std::out_of_range("ack-keep-duration argument " + std::string(
argv[i]) + " out of range [1, " + std::to_string(
Expand Down Expand Up @@ -903,8 +903,8 @@ class CLIParser
try
{
int input = std::stoi(argv[i]);
if (input < std::numeric_limits<uint32_t>::min() ||
input > std::numeric_limits<uint32_t>::max())
if (static_cast<long>(input) < static_cast<long>(std::numeric_limits<uint32_t>::min()) ||
static_cast<long>(input) > static_cast<long>(std::numeric_limits<uint32_t>::max()))
{
throw std::out_of_range("strength argument " + std::string(
argv[i]) + " out of range [0, " +
Expand Down Expand Up @@ -949,6 +949,39 @@ class CLIParser
return config;
}

static std::string parse_signal(
const int& signum)
{
switch (signum)
{
case SIGINT:
return "SIGINT";
case SIGTERM:
return "SIGTERM";
case SIGQUIT:
return "SIGQUIT";
case SIGHUP:
return "SIGHUP";
default:
return "UNKNOWN SIGNAL";
}
}

static std::string parse_entity_kind(
const EntityKind& entity)
{
switch (entity)
{
case EntityKind::PUBLISHER:
return "Publisher";
case EntityKind::SUBSCRIBER:
return "Subscriber";
case EntityKind::UNDEFINED:
default:
return "Undefined entity";
}
}

};

} // namespace configuration
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/configuration/PublisherApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void PublisherApp::run()
}
// Wait for period or stop event
std::unique_lock<std::mutex> terminate_lock(mutex_);
terminate_cv_.wait_for(terminate_lock, std::chrono::milliseconds(period_ms_), [&]()
cv_.wait_for(terminate_lock, std::chrono::milliseconds(period_ms_), [&]()
{
return is_stopped();
});
Expand Down
2 changes: 2 additions & 0 deletions examples/cpp/configuration/SubscriberApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
#include <condition_variable>
#include <stdexcept>

#include <fastdds/dds/core/status/SubscriptionMatchedStatus.hpp>
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/subscriber/DataReader.hpp>
#include <fastdds/dds/subscriber/qos/DataReaderQos.hpp>
#include <fastdds/dds/subscriber/qos/SubscriberQos.hpp>
#include <fastdds/dds/subscriber/SampleInfo.hpp>
#include <fastdds/dds/subscriber/Subscriber.hpp>
#include <fastdds/rtps/transport/shared_mem/SharedMemTransportDescriptor.h>
Expand Down
2 changes: 2 additions & 0 deletions examples/cpp/configuration/SubscriberApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#include <condition_variable>
#include <mutex>

#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/subscriber/DataReaderListener.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp>

#include "Application.hpp"
#include "CLIParser.hpp"
Expand Down

0 comments on commit 90c3c52

Please sign in to comment.