| 242 | } |
| 243 | |
| 244 | int read (int expect_success) |
| 245 | { |
| 246 | ACE_DEBUG((LM_DEBUG, |
| 247 | ACE_TEXT("(%P|%t) read begins.\n"))); |
| 248 | |
| 249 | try |
| 250 | { |
| 251 | ::Xyz::FooDataReader_var foo_dr |
| 252 | = ::Xyz::FooDataReader::_narrow(datareader.in ()); |
| 253 | if (CORBA::is_nil (foo_dr.in ())) |
| 254 | { |
| 255 | ACE_ERROR_RETURN ((LM_ERROR, |
| 256 | ACE_TEXT("(%P|%t) ::Xyz::FooDataReader::_narrow failed.\n")), |
| 257 | -1); |
| 258 | } |
| 259 | |
| 260 | int num_reads = 0; |
| 261 | int num_received = 0; |
| 262 | |
| 263 | bool init_val = false; |
| 264 | ACE_Array<bool> messages(num_writes, init_val); |
| 265 | |
| 266 | while ( num_reads < num_writes) |
| 267 | { |
| 268 | |
| 269 | ::Xyz::Foo foo; |
| 270 | ::DDS::SampleInfo si ; |
| 271 | |
| 272 | DDS::ReturnCode_t status = foo_dr->read_next_sample(foo, si) ; |
| 273 | num_reads ++; |
| 274 | |
| 275 | if (status == ::DDS::RETCODE_OK) |
| 276 | { |
| 277 | if (!expect_success) |
| 278 | { |
| 279 | ACE_ERROR_RETURN ((LM_ERROR, |
| 280 | ACE_TEXT("(%P|%t) ERROR: received an unexpected sample!\n")) |
| 281 | , -1); |
| 282 | |
| 283 | } |
| 284 | num_received++; |
| 285 | |
| 286 | if (default_key != foo.key) |
| 287 | { |
| 288 | ACE_ERROR ((LM_ERROR, |
| 289 | ACE_TEXT("(%P|%t) ERROR: reader received incorrect key!\n") |
| 290 | )); |
| 291 | } |
| 292 | int msg_num = (int) foo.x; |
| 293 | if ((0 <= msg_num) && (msg_num< num_writes)) |
| 294 | { |
| 295 | messages[msg_num] = true; |
| 296 | } |
| 297 | else |
| 298 | { |
| 299 | ACE_ERROR ((LM_ERROR, |
| 300 | ACE_TEXT("(%P|%t) ERROR: reader received unexpected message number %d!\n"), |
| 301 | msg_num)); |
no test coverage detected