The unmodified subscription example generated by rtiddsgen using the C++11 option for the -language flag.
- See Also
- Subscription Example
#include <algorithm>
#include <iostream>
#include <dds/sub/ddssub.hpp>
#include <dds/core/ddscore.hpp>
#include "Foo.hpp"
int subscriber_main(
int domain_id,
int sample_count)
{
int count = 0;
reader,
[&reader, &count]()
{
for (auto sample : samples){
if (sample.info().valid()){
count++;
std::cout << sample.data() << std::endl;
}
}
}
);
waitset += read_condition;
while (count < sample_count || sample_count == 0) {
std::cout << "MyOtherType subscriber sleeping for 4 sec..." << std::endl;
}
return 1;
}
int main(int argc, char *argv[])
{
int sample_count = 0;
if (argc >= 2) {
domain_id = atoi(argv[1]);
}
if (argc >= 3) {
sample_count = atoi(argv[2]);
}
try {
subscriber_main(domain_id, sample_count);
} catch (const std::exception& ex) {
std::cerr << "Exception in subscriber_main(): " << ex.what() << std::endl;
return -1;
}
return 0;
}