OpenDDS  Snapshot(2023/04/28-20:55)
XML_Intf.cpp
Go to the documentation of this file.
1 
2 #include "XML_Intf.h"
3 #include "ace/XML_Utils/XML_Helper.h"
4 #include "ace/XML_Utils/XMLSchema/id_map.hpp"
5 
8 #include "TopicQos_Handler.h"
9 #include "PublisherQos_Handler.h"
10 #include "SubscriberQos_Handler.h"
11 #include "ParticipantQos_Handler.h"
12 
13 #include "dds/DCPS/debug.h"
14 
16 
17 namespace OpenDDS {
18 namespace DCPS {
19 
21  {
22  }
23 
25  {
26  }
27 
28  ::dds::qosProfile *
30  {
31  if (ACE_OS::strlen(profile_name) == 0)
32  {
33  if (DCPS_debug_level > 7)
34  {
36  ACE_TEXT("(%P|%t) ERROR: QOS_XML_Handler::get_profile - ")
37  ACE_TEXT("No profile specified\n")));
38  return 0;
39  }
40  }
41 
42  dds::qosProfile_seq::qos_profile_const_iterator it;
43  for (it = profiles_.begin_qos_profile();
44  it != profiles_.end_qos_profile();
45  ++it)
46  {
47  if (ACE_OS::strcmp((*it)->name().c_str(), profile_name) == 0)
48  {
49  if (DCPS_debug_level > 7)
50  {
52  ACE_TEXT("QOS_XML_Handler::get_profile - ")
53  ACE_TEXT("Found profile <%s>\n"),
54  (*it)->name().c_str()));
55  }
56  return it->get();
57  }
58  }
59 
61  {
63  ACE_TEXT("(%P|%t) ERROR: QOS_XML_Handler::get_profile - ")
64  ACE_TEXT("Did not find profile <%s>\n"),
65  profile_name));
66  }
67 
68  return 0;
69  }
70 
72  QOS_XML_Handler::addQoSProfile(const dds::qosProfile & profile)
73  {
74  // get profile name and check if it exists
75 
76  const ACE_TCHAR* profileName = profile.name().c_str();
77  if (ACE_OS::strlen(profileName) == 0) {
78  if (DCPS_debug_level > 7)
79  {
81  ACE_TEXT("(%P|%t) ERROR: QOS_XML_Handler::addQoSProfile - ")
82  ACE_TEXT("No profile name specified\n")));
83  return DDS::RETCODE_ERROR;
84  }
85  }
86 
87  // check if this profile name is already in the list
88  dds::qosProfile_seq::qos_profile_const_iterator it;
89  for (it = profiles_.begin_qos_profile();
90  it != profiles_.end_qos_profile();
91  ++it)
92  {
93  if (ACE_OS::strcmp((*it)->name().c_str(), profileName) == 0) {
94  if (DCPS_debug_level > 7)
95  {
97  ACE_TEXT("(%P|%t) ERROR: QOS_XML_Handler::addQoSProfile - ")
98  ACE_TEXT("Profile exists or profile name <%C> in use.\n"),
99  profileName));
100  }
101  return DDS::RETCODE_ERROR;
102  }
103  }
104 
105  // append qos profile to list
106  dds::qosProfile_seq::qos_profile_value_type t(new dds::qosProfile(profile));
107  profiles_.add_qos_profile(t);
108  return DDS::RETCODE_OK;
109  }
110 
112  QOS_XML_Handler::addQoSProfileSeq(const dds::qosProfile_seq & profiles)
113  {
114 
115  dds::qosProfile_seq::qos_profile_const_iterator it;
116  for (it = profiles.begin_qos_profile();
117  it != profiles.end_qos_profile();
118  ++it)
119  {
120  dds::qosProfile qos(*(it->get()));
121  addQoSProfile(qos);
122  }
123 
124  return DDS::RETCODE_OK;
125 
126  }
127 
130  {
131 
132  if (ACE_OS::strlen(profileName) == 0)
133  {
134  if (DCPS_debug_level > 7)
135  {
137  ACE_TEXT("(%P|%t) ERROR: QOS_XML_Handler::delQoSProfile - ")
138  ACE_TEXT("No profile specified\n")));
139  return DDS::RETCODE_ERROR;
140  }
141  }
142 
143  dds::qosProfile_seq::qos_profile_const_iterator it;
144  for (it = profiles_.begin_qos_profile();
145  it != profiles_.end_qos_profile();
146  ++it)
147  {
148  if (ACE_OS::strcmp((*it)->name().c_str(), profileName) == 0) {
149  profiles_.del_qos_profile(*it);
150  return DDS::RETCODE_OK;
151  }
152 
153  }
154 
155  if (DCPS_debug_level > 7)
156  {
158  ACE_TEXT("(%P|%t) ERROR: QOS_XML_Handler::delQoSProfile - ")
159  ACE_TEXT("Profile doesn't exists or wrong profile name.\n")));
160  }
161  return DDS::RETCODE_ERROR;
162  }
163 
164  size_t QOS_XML_Handler::length() const
165  {
166  return profiles_.count_qos_profile();
167  }
168 
171  const ACE_TCHAR * profile_name,
172  const ACE_TCHAR * topic_name)
173  {
174  ACE_UNUSED_ARG(topic_name);
175 
177  try
178  {
179  ::dds::qosProfile * profile = this->get_profile(profile_name);
180  if (profile != 0)
181  {
183  retcode = ::DDS::RETCODE_OK;
184  }
185  else
186  retcode = DDS::RETCODE_BAD_PARAMETER;
187  }
188  catch (const CORBA::Exception &ex)
189  {
191  ACE_TEXT("QOS_XML_Handler::get_datawriter_qos - ")
192  ACE_TEXT("Caught CORBA exception whilst parsing XML into IDL: %C\n"),
193  ex._info().c_str()));
194  retcode = DDS::RETCODE_ERROR;
195  }
196  catch (...)
197  {
199  ACE_TEXT("QOS_XML_Handler::get_datawriter_qos - ")
200  ACE_TEXT("Unexpected exception whilst parsing XML into IDL.\n")));
201  retcode = DDS::RETCODE_ERROR;
202  }
203 
204  return retcode;
205  }
206 
209  const ACE_TCHAR * profile_name,
210  const ACE_TCHAR * topic_name)
211  {
212  ACE_UNUSED_ARG(topic_name);
213 
215  try
216  {
217  ::dds::qosProfile * profile = this->get_profile(profile_name);
218  if (profile != 0)
219  {
221  retcode = ::DDS::RETCODE_OK;
222  }
223  else
224  retcode = DDS::RETCODE_BAD_PARAMETER;
225  }
226  catch (const CORBA::Exception &ex)
227  {
229  ACE_TEXT("QOS_XML_Handler::get_datareader_qos - ")
230  ACE_TEXT("Caught CORBA exception whilst parsing XML into IDL: %C\n"),
231  ex._info().c_str()));
232  retcode = DDS::RETCODE_ERROR;
233  }
234  catch (...)
235  {
237  ACE_TEXT("QOS_XML_Handler::get_datareader_qos - ")
238  ACE_TEXT("Unexpected exception whilst parsing XML into IDL.\n")));
239  retcode = DDS::RETCODE_ERROR;
240  }
241 
242  return retcode;
243  }
244 
247  const ACE_TCHAR * profile_name,
248  const ACE_TCHAR * topic_name)
249  {
250  ACE_UNUSED_ARG(topic_name);
251 
253  try
254  {
255  ::dds::qosProfile * profile = this->get_profile(profile_name);
256  if (profile != 0)
257  {
258  TopicQos_Handler::get_topic_qos(tp_qos, profile);
259  retcode = ::DDS::RETCODE_OK;
260  }
261  else
262  retcode = DDS::RETCODE_BAD_PARAMETER;
263  }
264  catch (const CORBA::Exception &ex)
265  {
267  ACE_TEXT("QOS_XML_Handler::get_topic_qos - ")
268  ACE_TEXT("Caught CORBA exception whilst parsing XML into IDL: %C\n"),
269  ex._info().c_str()));
270  retcode = DDS::RETCODE_ERROR;
271  }
272  catch (...)
273  {
275  ACE_TEXT("QOS_XML_Handler::get_topic_qos - ")
276  ACE_TEXT("Unexpected exception whilst parsing XML into IDL.\n")));
277  retcode = DDS::RETCODE_ERROR;
278  }
279 
280  return retcode;
281  }
282 
285  const ACE_TCHAR * profile_name)
286  {
288  try
289  {
290  ::dds::qosProfile * profile = this->get_profile(profile_name);
291  if (profile != 0)
292  {
293  PublisherQos_Handler::get_publisher_qos(pub_qos, profile);
294  retcode = ::DDS::RETCODE_OK;
295  }
296  else
297  retcode = DDS::RETCODE_BAD_PARAMETER;
298  }
299  catch (const CORBA::Exception &ex)
300  {
302  ACE_TEXT("QOS_XML_Handler::get_publisher_qos - ")
303  ACE_TEXT("Caught CORBA exception whilst parsing XML into IDL: %C\n"),
304  ex._info().c_str()));
305  retcode = DDS::RETCODE_ERROR;
306  }
307  catch (...)
308  {
310  ACE_TEXT("QOS_XML_Handler::get_publisher_qos - ")
311  ACE_TEXT("Unexpected exception whilst parsing XML into IDL.\n")));
312  retcode = DDS::RETCODE_ERROR;
313  }
314 
315  return retcode;
316  }
317 
320  const ACE_TCHAR * profile_name)
321  {
323  try
324  {
325  ::dds::qosProfile * profile = this->get_profile(profile_name);
326  if (profile != 0)
327  {
329  retcode = ::DDS::RETCODE_OK;
330  }
331  else
332  retcode = DDS::RETCODE_BAD_PARAMETER;
333  }
334  catch (const CORBA::Exception &ex)
335  {
337  ACE_TEXT("QOS_XML_Handler::get_subscriber_qos - ")
338  ACE_TEXT("Caught CORBA exception whilst parsing XML into IDL: %C\n"),
339  ex._info().c_str()));
340  retcode = DDS::RETCODE_ERROR;
341  }
342  catch (...)
343  {
345  ACE_TEXT("QOS_XML_Handler::get_subscriber_qos - ")
346  ACE_TEXT("Unexpected exception whilst parsing XML into IDL.\n")));
347  retcode = DDS::RETCODE_ERROR;
348  }
349 
350  return retcode;
351  }
352 
355  const ACE_TCHAR * profile_name)
356  {
358  try
359  {
360  ::dds::qosProfile * profile = this->get_profile(profile_name);
361  if (profile != 0)
362  {
364  retcode = ::DDS::RETCODE_OK;
365  }
366  else
367  retcode = DDS::RETCODE_BAD_PARAMETER;
368  }
369  catch (const CORBA::Exception &ex)
370  {
372  ACE_TEXT("QOS_XML_Handler::get_participant_qos - ")
373  ACE_TEXT("Caught CORBA exception whilst parsing XML into IDL: %C\n"),
374  ex._info().c_str()));
375  retcode = DDS::RETCODE_ERROR;
376  }
377  catch (...)
378  {
380  ACE_TEXT("QOS_XML_Handler::get_participant_qos - ")
381  ACE_TEXT("Unexpected exception whilst parsing XML into IDL.\n")));
382  retcode = DDS::RETCODE_ERROR;
383  }
384 
385  return retcode;
386  }
387 
388 }
389 }
390 
DDS::ReturnCode_t get_participant_qos(::DDS::DomainParticipantQos &sub_qos, const ACE_TCHAR *profile_name)
Definition: XML_Intf.cpp:354
#define ACE_ERROR(X)
const char * c_str(void) const
DDS::ReturnCode_t get_datareader_qos(::DDS::DataReaderQos &dr_qos, const ACE_TCHAR *profile_name, const ACE_TCHAR *topic_name)
Definition: XML_Intf.cpp:208
static bool get_subscriber_qos(::DDS::SubscriberQos &sub_qos, ::dds::qosProfile *profile, const ACE_TCHAR *name=0)
size_t strlen(const char *s)
DDS::ReturnCode_t get_publisher_qos(::DDS::PublisherQos &pub_qos, const ACE_TCHAR *profile_name)
Definition: XML_Intf.cpp:284
static bool get_publisher_qos(::DDS::PublisherQos &pub_qos, ::dds::qosProfile *profile, const ACE_TCHAR *name=0)
DDS::ReturnCode_t get_topic_qos(::DDS::TopicQos &tp_qos, const ACE_TCHAR *profile_name, const ACE_TCHAR *topic_name)
Definition: XML_Intf.cpp:246
DDS::ReturnCode_t get_datawriter_qos(::DDS::DataWriterQos &dw_qos, const ACE_TCHAR *profile_name, const ACE_TCHAR *topic_name)
Definition: XML_Intf.cpp:170
static bool get_datareader_qos(::DDS::DataReaderQos &dr_qos, ::dds::qosProfile *profile, const ACE_TCHAR *name=0)
char ACE_TCHAR
virtual ACE_CString _info(void) const=0
DDS::ReturnCode_t get_subscriber_qos(::DDS::SubscriberQos &sub_qos, const ACE_TCHAR *profile_name)
Definition: XML_Intf.cpp:319
DDS::ReturnCode_t addQoSProfile(const dds::qosProfile &profile)
Definition: XML_Intf.cpp:72
::dds::qosProfile * get_profile(const ACE_TCHAR *profile_name)
Definition: XML_Intf.cpp:29
int strcmp(const char *s, const char *t)
static bool get_topic_qos(::DDS::TopicQos &tp_qos, ::dds::qosProfile *profile, const ACE_TCHAR *name=0)
ACE_TEXT("TCP_Factory")
DDS::ReturnCode_t addQoSProfileSeq(const dds::qosProfile_seq &profiles)
Definition: XML_Intf.cpp:112
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
::dds::qosProfile_seq profiles_
Definition: XML_Intf.h:116
const ReturnCode_t RETCODE_ERROR
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
const ReturnCode_t RETCODE_OK
DDS::ReturnCode_t delQoSProfile(const ACE_TCHAR *profileName)
Definition: XML_Intf.cpp:129
LM_ERROR
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
static bool get_participant_qos(::DDS::DomainParticipantQos &dp_qos, ::dds::qosProfile *profile, const ACE_TCHAR *name=0)
const ReturnCode_t RETCODE_BAD_PARAMETER
static bool get_datawriter_qos(::DDS::DataWriterQos &dw_qos, ::dds::qosProfile *profile, const ACE_TCHAR *name=0)