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

Function ACE_TMAIN

tests/DCPS/FindTopic/findtopic.cpp:130–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130int ACE_TMAIN(int argc, ACE_TCHAR* argv[])
131{
132 try {
133 DDS::DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv);
134
135 OpenDDS::DCPS::Discovery_rch discovery;
136 if (argc > 1 && ACE_TString(argv[1]) == ACE_TEXT("rtps")) {
137 OpenDDS::RTPS::RtpsDiscovery_rch rtps_disc =
138 OpenDDS::DCPS::make_rch<OpenDDS::RTPS::RtpsDiscovery>("RTPS");
139 rtps_disc->sedp_multicast(false);
140 discovery = rtps_disc;
141 ACE_DEBUG((LM_DEBUG, "%N:%l main() using RTPS Discovery\n"));
142 } else {
143 discovery = OpenDDS::DCPS::make_rch<LocalDiscovery>();
144 ACE_DEBUG((LM_DEBUG, "%N:%l main() using Local Discovery\n"));
145 }
146 TheServiceParticipant->add_discovery(discovery);
147 TheServiceParticipant->set_default_discovery(discovery->key());
148
149 TransportInst_rch default_inst = TheTransportRegistry->create_inst("transport", "rtps_udp");
150 TheTransportRegistry->get_config(TransportRegistry::DEFAULT_CONFIG_NAME)->sorted_insert(default_inst);
151
152 DDS::DomainParticipant_var participant = dpf->create_participant(11, PARTICIPANT_QOS_DEFAULT, 0, 0);
153 if (!participant) {
154 ACE_ERROR_RETURN((LM_ERROR, "%N:%l: main() ERROR: create_participant failed!\n"), EXIT_FAILURE);
155 }
156
157 Messenger::MessageTypeSupport_var mts = new Messenger::MessageTypeSupportImpl;
158 if (mts->register_type(participant, "") != DDS::RETCODE_OK) {
159 ACE_ERROR_RETURN((LM_ERROR, "%N:%l: main() ERROR: register_type failed!\n"), EXIT_FAILURE);
160 }
161
162 CORBA::String_var type_name = mts->get_type_name();
163 DDS::Topic_var topic1 = participant->create_topic("Movie Discussion List",
164 type_name, TOPIC_QOS_DEFAULT, 0, 0);
165 if (!topic1) {
166 ACE_ERROR_RETURN((LM_ERROR, "%N:%l: main() ERROR: create_topic failed!\n"), EXIT_FAILURE);
167 }
168
169 DDS::Publisher_var pub1 = participant->create_publisher(PUBLISHER_QOS_DEFAULT, 0, 0);
170 if (!pub1) {
171 ACE_ERROR_RETURN((LM_ERROR, "%N:%l: main() ERROR: create_publisher 1 failed!\n"), EXIT_FAILURE);
172 }
173
174 DDS::DataWriter_var dw1 = pub1->create_datawriter(topic1, DATAWRITER_QOS_DEFAULT, 0, 0);
175 if (!dw1) {
176 ACE_ERROR_RETURN((LM_ERROR, "%N:%l: main() ERROR: create_datawriter 1 failed!\n"), EXIT_FAILURE);
177 }
178
179 // Now the second part of the program will try to do its setup
180 if (sub_program(participant) != EXIT_SUCCESS) {
181 ACE_ERROR_RETURN((LM_ERROR, "%N:%l: main() ERROR: sub program 1 failed!\n"), EXIT_FAILURE);
182 }
183
184 // Now test double create/delete
185 if (double_delete(participant, type_name.in ()) != EXIT_SUCCESS) {
186 ACE_ERROR_RETURN((LM_ERROR, "%N:%l: main() ERROR: double_delete failed!\n"), EXIT_FAILURE);
187 }

Callers

nothing calls this directly

Calls 15

sub_programFunction · 0.85
double_deleteFunction · 0.85
sedp_multicastMethod · 0.80
add_discoveryMethod · 0.80
set_default_discoveryMethod · 0.80
sorted_insertMethod · 0.80
delete_datawriterMethod · 0.80
delete_publisherMethod · 0.80
delete_topicMethod · 0.80
delete_participantMethod · 0.80
keyMethod · 0.45
create_instMethod · 0.45

Tested by

no test coverage detected