| 101 | } |
| 102 | |
| 103 | int read(const RelayConfigDataReader_var& reader, RelayConfig& config, bool& done) |
| 104 | { |
| 105 | RelayConfig sample; |
| 106 | DDS::SampleInfo info; |
| 107 | DDS::ReturnCode_t ret; |
| 108 | while ((ret = reader->take_next_sample(sample, info)) == DDS::RETCODE_OK) { |
| 109 | if (info.valid_data) { |
| 110 | filter(sample); |
| 111 | std::cout << OpenDDS::DCPS::to_json(sample) << std::endl; |
| 112 | if (sample.relay_id() == config.relay_id()) { |
| 113 | for (auto it{config.config().begin()}; it != config.config().end();) { |
| 114 | const auto sample_it{sample.config().find(it->first)}; |
| 115 | if (sample_it != sample.config().end() && sample_it->second == it->second) { |
| 116 | config.config().erase(it++); |
| 117 | } else { |
| 118 | ++it; |
| 119 | } |
| 120 | } |
| 121 | if (config.config().empty() && !keep_running) { |
| 122 | done = true; |
| 123 | } |
| 124 | } |
| 125 | } else { |
| 126 | if (info.instance_state != DDS::ALIVE_INSTANCE_STATE) { |
| 127 | std::cerr << "Relay no longer available: " << sample.relay_id() << std::endl; |
| 128 | if (sample.relay_id() == config.relay_id() && !keep_running) { |
| 129 | done = true; |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | if (ret != DDS::RETCODE_NO_DATA) { |
| 136 | ACE_ERROR((LM_ERROR, "ERROR: read returned %C\n", OpenDDS::DCPS::retcode_to_string(ret))); |
| 137 | return EXIT_FAILURE; |
| 138 | } |
| 139 | |
| 140 | return EXIT_SUCCESS; |
| 141 | } |
| 142 | |
| 143 | int run(int argc, ACE_TCHAR* argv[]) |
| 144 | { |
no test coverage detected