#include <algorithm>
#include <iostream>
#include <dds/sub/ddssub.hpp>
#include <dds/core/ddscore.hpp>
#include <rti/config/Logger.hpp>
#include "Foo.hpp"
#include "application.hpp"
{
int count = 0;
for (const auto& sample : samples) {
if (sample.info().valid()) {
count++;
std::cout << sample.data() << std::endl;
} else {
std::cout << "Instance state changed to "
<< sample.info().state().instance_state() << std::endl;
}
}
return count;
}
void run_subscriber_application(
unsigned int domain_id,
unsigned int sample_count)
{
unsigned int samples_read = 0;
reader,
[reader, &samples_read]() { samples_read += process_data(reader); });
waitset += read_condition;
while (!application::shutdown_requested && samples_read < sample_count) {
std::cout << "MyOtherType subscriber sleeping up to 1 sec..." << std::endl;
}
}
int main(int argc, char *argv[])
{
auto arguments = parse_arguments(argc, argv);
if (arguments.parse_result == ParseReturn::exit) {
return EXIT_SUCCESS;
} else if (arguments.parse_result == ParseReturn::failure) {
return EXIT_FAILURE;
}
setup_signal_handlers();
try {
run_subscriber_application(arguments.domain_id, arguments.sample_count);
} catch (const std::exception& ex) {
std::cerr << "Exception in run_subscriber_application(): " << ex.what()
<< std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}