OpenDDS  Snapshot(2023/04/28-20:55)
XML_File_Intf.cpp
Go to the documentation of this file.
1 #include "XML_File_Intf.h"
2 #include "ace/XML_Utils/XML_Helper.h"
3 #include "ace/XML_Utils/XMLSchema/id_map.hpp"
4 
5 #include "dds/DCPS/debug.h"
6 
8 
9 namespace OpenDDS {
10 namespace DCPS {
11 
12  QOS_XML_File_Handler::QOS_XML_File_Handler(XML::XML_Error_Handler* error_handler) :
14  res_(new XML::XML_Schema_Resolver<XML::Environment_Resolver>()),
15  eh_(error_handler ? error_handler : new XML::XML_Error_Handler()),
16  helper_(res_,eh_)
17  {
18  }
19 
21  {
22  delete res_;
23  delete eh_;
24  }
25 
28  {
30  try
31  {
32  if (!helper_.is_initialized())
33  {
35  ACE_TEXT("QOS_XML_File_Handler::init - ")
36  ACE_TEXT("Unable to initialize XML_Helper.\n")));
37  return DDS::RETCODE_ERROR;
38  }
39 
40  if (DCPS_debug_level > 9)
41  {
43  ACE_TEXT("QOS_XML_File_Handler::init - ")
44  ACE_TEXT("Constructing DOM\n")));
45  }
46 
47  XERCES_CPP_NAMESPACE::DOMDocument *dom =
48  helper_.create_dom(file);
49 
50  if (dom == 0)
51  {
52  if (DCPS_debug_level > 1)
53  {
55  ACE_TEXT("QOS_XML_File_Handler::init - ")
56  ACE_TEXT("Failed to open file %s\n"),
57  file));
58  }
59  return DDS::RETCODE_ERROR;
60  }
61 
62  XERCES_CPP_NAMESPACE::DOMElement *profile_dom = dom->getDocumentElement();
63 
64  if (DCPS_debug_level > 9)
65  {
67  ACE_TEXT("QOS_XML_File_Handler::init - ")
68  ACE_TEXT("DOMElement pointer: %u\n"), profile_dom));
69  }
70 
71  ID_Map::TSS_ID_Map* TSS_ID_Map(ACE_Singleton<ID_Map::TSS_ID_Map, ACE_Null_Mutex>::instance());
72  (*TSS_ID_Map)->reset();
73 
74  this->profiles_ = dds::reader::dds(dom);
75  }
76  catch (const CORBA::Exception &ex)
77  {
79  ACE_TEXT("QOS_XML_File_Handler::init - ")
80  ACE_TEXT("Caught CORBA exception whilst parsing XML <%s> into IDL: %C\n"),
81  file,
82  ex._info().c_str()));
83  retcode = DDS::RETCODE_ERROR;
84  }
85  catch (...)
86  {
88  ACE_TEXT("QOS_XML_File_Handler::init - ")
89  ACE_TEXT("Unexpected exception whilst parsing XML <%s> into IDL.\n"),
90  file));
91  retcode = DDS::RETCODE_ERROR;
92  }
93  return retcode;
94  }
95 
96  void
98  const ACE_TCHAR *relpath)
99  {
100  helper_.get_resolver().get_resolver().add_path(environment, relpath);
101  }
102 }
103 }
104 
#define ACE_DEBUG(X)
#define ACE_ERROR(X)
const char * c_str(void) const
QOS_XML_File_Handler(XML::XML_Error_Handler *error_handler=0)
::dds::qosProfile_seq dds(xercesc::DOMDocument const *d)
Definition: dds_qos.cpp:7398
LM_TRACE
char ACE_TCHAR
XML_RESOLVER * res_
Schema resolver.
Definition: XML_File_Intf.h:70
void add_search_path(const ACE_TCHAR *environment, const ACE_TCHAR *relpath)
virtual ACE_CString _info(void) const=0
XML_HELPER helper_
XML Helper.
Definition: XML_File_Intf.h:76
ACE_TEXT("TCP_Factory")
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
DDS::ReturnCode_t init(const ACE_TCHAR *file)
::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
LM_ERROR
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
XML::XML_Error_Handler * eh_
Error handler.
Definition: XML_File_Intf.h:73