MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / ACE_TMAIN

Function ACE_TMAIN

DevGuideExamples/DCPS/Messenger.minimal/Subscriber.cpp:19–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17using namespace examples::boilerplate;
18
19int
20ACE_TMAIN(int argc, ACE_TCHAR *argv[])
21{
22 try {
23 // Initialize DomainParticipantFactory, handling command line args
24 DDS::DomainParticipantFactory_var dpf =
25 TheParticipantFactoryWithArgs(argc, argv);
26
27 // Create domain participant
28 DDS::DomainParticipant_var participant = createParticipant(dpf);
29
30 // Register type support and create topic
31 DDS::Topic_var topic = createTopic(participant);
32
33 // Create subscriber
34 DDS::Subscriber_var subscriber = createSubscriber(participant);
35
36 // Create Listener
37 DataReaderListenerImpl* listener_impl = new DataReaderListenerImpl;
38 DDS::DataReaderListener_var listener(listener_impl);
39
40 // Create DataReader with the listener attached
41 DDS::DataReader_var reader = createDataReader(subscriber,
42 topic,
43 listener);
44
45 {
46 // Block until reader has associated with a writer
47 // but is no longer associated with any writer
48 OpenDDS::Model::ReaderSync rs(reader);
49 }
50
51 // Output the sample count
52 std::cout << "Subscriber received " << listener_impl->sample_count
53 << " samples" << std::endl;
54
55 // Clean-up!
56 cleanup(participant, dpf);
57
58 // Listener will be cleaned up when reader goes out of scope
59 } catch (const CORBA::Exception& e) {
60 e._tao_print_exception("Exception caught in main():");
61 return -1;
62 } catch (std::runtime_error& err) {
63 ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: main() - %C\n"),
64 err.what()), -1);
65 } catch (std::string& msg) {
66 ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: main() - %C\n"),
67 msg.c_str()), -1);
68 }
69
70 return 0;
71}

Callers

nothing calls this directly

Calls 7

_tao_print_exceptionMethod · 0.80
createParticipantFunction · 0.70
createTopicFunction · 0.70
createSubscriberFunction · 0.70
createDataReaderFunction · 0.70
cleanupFunction · 0.70
whatMethod · 0.45

Tested by

no test coverage detected