| 113 | } |
| 114 | |
| 115 | int |
| 116 | ACE_TMAIN(int argc, ACE_TCHAR *argv[]) |
| 117 | { |
| 118 | long stage = 0; |
| 119 | std::stringstream ss; |
| 120 | ss << "(" << ACE_OS::getpid() << ")"; |
| 121 | const std::string pid = ss.str(); |
| 122 | std::cerr << pid << "Sub Creating App\n"; |
| 123 | int status = 0; |
| 124 | try { |
| 125 | ::TestUtils::DDSApp ddsApp(argc, argv); |
| 126 | std::cerr << pid << "Sub Creating topic\n"; |
| 127 | ::TestUtils::DDSTopicFacade< ::Xyz::Foo > topic = |
| 128 | ddsApp.topic_facade< ::Xyz::Foo >("bar"); |
| 129 | |
| 130 | // need to process after calling topic to ensure all DDS/TAO/ACE command line |
| 131 | // parameters are already removed |
| 132 | ::TestUtils::Arguments args; |
| 133 | args.add_long("stage", 0); |
| 134 | args.add_bool("verbose", false); |
| 135 | ::TestUtils::Options options(argc, argv); |
| 136 | |
| 137 | stage = options.get<long>("stage"); |
| 138 | if (stage != 1 && stage != 2) { |
| 139 | std::cerr << "ERROR: Sub command line parameter \"stage\" set to " |
| 140 | << stage << " should be set to 1 or 2 "; |
| 141 | return -1; |
| 142 | } |
| 143 | |
| 144 | // Create Listener |
| 145 | ::TestUtils::ListenerRecorder< ::Xyz::Foo, ::Xyz::FooDataReader>* listener_impl = |
| 146 | new ::TestUtils::ListenerRecorder< ::Xyz::Foo, ::Xyz::FooDataReader>; |
| 147 | listener_impl->verbose(options.get<bool>("verbose")); |
| 148 | DDS::DataReaderListener_var listener(listener_impl); |
| 149 | // Create data reader for the topic |
| 150 | std::cerr << pid << "Sub Creating Stage " << stage << " reader\n"; |
| 151 | DDS::DataReader_var dr = topic.reader(listener); |
| 152 | |
| 153 | |
| 154 | { |
| 155 | std::cerr << pid << "Sub Stage " << stage |
| 156 | << " waiting for 2 writer to come and go" << std::endl; |
| 157 | OpenDDS::Model::ReaderSync rs(dr, 2); |
| 158 | } |
| 159 | std::cerr << pid << "Sub Stage " << stage << " done waiting\n"; |
| 160 | |
| 161 | const Messages msgs = listener_impl->messages(); |
| 162 | |
| 163 | int expected_count = -1; |
| 164 | if (!valid(msgs, stage, expected_count)) { |
| 165 | status = -1; |
| 166 | } |
| 167 | |
| 168 | std::cerr << pid << "Sub Stage " << stage << " DDSApp going out of scope\n"; |
| 169 | // Listener will be cleaned up when reader goes out of scope |
| 170 | } catch (const CORBA::Exception& e) { |
| 171 | e._tao_print_exception("Exception caught in main():"); |
| 172 | status = -1; |