| 22 | } |
| 23 | |
| 24 | int run_test_instance(DDS::DomainParticipant_ptr dp) |
| 25 | { |
| 26 | using namespace DDS; |
| 27 | using namespace OpenDDS::DCPS; |
| 28 | using namespace Messenger; |
| 29 | WaitSet_var ws = new WaitSet; |
| 30 | MessageTypeSupport_var ts = new MessageTypeSupportImpl; |
| 31 | ts->register_type(dp, ""); |
| 32 | CORBA::String_var type_name = ts->get_type_name(); |
| 33 | Topic_var topic = dp->create_topic("MyTopic", type_name, |
| 34 | TOPIC_QOS_DEFAULT, 0, ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); |
| 35 | |
| 36 | Publisher_var pub = dp->create_publisher(PUBLISHER_QOS_DEFAULT, 0, |
| 37 | ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); |
| 38 | DataWriter_var dw = pub->create_datawriter(topic, DATAWRITER_QOS_DEFAULT, 0, |
| 39 | ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); |
| 40 | |
| 41 | Subscriber_var sub = dp->create_subscriber(SUBSCRIBER_QOS_DEFAULT, 0, |
| 42 | ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); |
| 43 | DataReader_var dr = sub->create_datareader(topic, DATAREADER_QOS_DEFAULT, 0, |
| 44 | ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); |
| 45 | |
| 46 | StatusCondition_var dw_sc = dw->get_statuscondition(); |
| 47 | dw_sc->set_enabled_statuses(PUBLICATION_MATCHED_STATUS); |
| 48 | ws->attach_condition(dw_sc); |
| 49 | Duration_t infinite = {DURATION_INFINITE_SEC, DURATION_INFINITE_NSEC}; |
| 50 | ConditionSeq active; |
| 51 | |
| 52 | ReturnCode_t ret = ws->wait(active, infinite); |
| 53 | if (ret != RETCODE_OK) return ret; |
| 54 | |
| 55 | ret = ws->detach_condition(dw_sc); |
| 56 | if (ret != RETCODE_OK) return ret; |
| 57 | |
| 58 | MessageDataWriter_var mdw = MessageDataWriter::_narrow(dw); |
| 59 | Message msg = {0}; |
| 60 | for (int i(0); i < 12; ++i) { |
| 61 | ++msg.subject_id; |
| 62 | ret = mdw->write(msg, HANDLE_NIL); |
| 63 | if (ret != RETCODE_OK) return ret; |
| 64 | } |
| 65 | |
| 66 | ReadCondition_var dr_rc = dr->create_readcondition(NOT_READ_SAMPLE_STATE, |
| 67 | NEW_VIEW_STATE, ALIVE_INSTANCE_STATE); |
| 68 | ReadCondition_var dr_rc2 = dr->create_readcondition(ANY_SAMPLE_STATE, |
| 69 | ANY_VIEW_STATE, NOT_ALIVE_DISPOSED_INSTANCE_STATE); |
| 70 | ws->attach_condition(dr_rc); |
| 71 | ws->attach_condition(dr_rc2); |
| 72 | MessageDataReader_var mdr = MessageDataReader::_narrow(dr); |
| 73 | bool passed = true, done = false; |
| 74 | while (!done) { |
| 75 | ret = ws->wait(active, infinite); |
| 76 | if (ret != RETCODE_OK) { |
| 77 | passed = false; |
| 78 | break; |
| 79 | } |
| 80 | cout << "wait returned" << endl; |
| 81 | for (CORBA::ULong i(0); i < active.length(); ++i) { |
no test coverage detected