XMLEndpointParser.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @file XMLEndpointParser.h
  16. *
  17. */
  18. #ifndef XMLENDPOINTPARSER_H_
  19. #define XMLENDPOINTPARSER_H_
  20. #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
  21. #include <fastrtps/xmlparser/XMLParserCommon.h>
  22. #include <set>
  23. #include <vector>
  24. #include <cstdint>
  25. namespace tinyxml2
  26. {
  27. class XMLElement;
  28. class XMLDocument;
  29. }
  30. namespace eprosima{
  31. namespace fastrtps{
  32. namespace rtps{
  33. class ReaderProxyData;
  34. class WriterProxyData;
  35. }
  36. namespace xmlparser{
  37. /**
  38. * Class StaticRTPSParticipantInfo, contains the information of writers and readers loaded from the XML file.
  39. *@ingroup DISCOVERY_MODULE
  40. */
  41. class StaticRTPSParticipantInfo{
  42. public:
  43. StaticRTPSParticipantInfo(){};
  44. virtual ~StaticRTPSParticipantInfo(){};
  45. //!RTPS PArticipant name
  46. std::string m_RTPSParticipantName;
  47. //!Vector of ReaderProxyData pointer
  48. std::vector<rtps::ReaderProxyData*> m_readers;
  49. //!Vector of ReaderProxyData pointer
  50. std::vector<rtps::WriterProxyData*> m_writers;
  51. };
  52. /**
  53. * Class XMLEndpointParser used to parse the XML file that contains information about remote endpoints.
  54. * @ingroup DISCVOERYMODULE
  55. */
  56. class XMLEndpointParser {
  57. public:
  58. XMLEndpointParser();
  59. virtual ~XMLEndpointParser();
  60. /**
  61. * Load the XML file
  62. * @param filename Name of the file to load and parse.
  63. * @return True if correct.
  64. */
  65. XMLP_ret loadXMLFile(std::string& filename);
  66. /**
  67. * Load the XML node
  68. * @param doc Node to parse.
  69. * @return True if correct.
  70. */
  71. XMLP_ret loadXMLNode(tinyxml2::XMLDocument& doc);
  72. void loadXMLParticipantEndpoint(tinyxml2::XMLElement* xml_endpoint, StaticRTPSParticipantInfo* pdata);
  73. /**
  74. * Load a Reader endpoint.
  75. * @param xml_endpoint Reference of a tree child for a reader.
  76. * @param pdata Pointer to the RTPSParticipantInfo where the reader must be added.
  77. * @return True if correctly added.
  78. */
  79. XMLP_ret loadXMLReaderEndpoint(tinyxml2::XMLElement* xml_endpoint,StaticRTPSParticipantInfo* pdata);
  80. /**
  81. * Load a Writer endpoint.
  82. * @param xml_endpoint Reference of a tree child for a writer.
  83. * @param pdata Pointer to the RTPSParticipantInfo where the reader must be added.
  84. * @return True if correctly added.
  85. */
  86. XMLP_ret loadXMLWriterEndpoint(tinyxml2::XMLElement* xml_endpoint, StaticRTPSParticipantInfo* pdata);
  87. /**
  88. * Look for a reader in the previously loaded endpoints.
  89. * @param[in] partname RTPSParticipant name
  90. * @param[in] id Id of the reader
  91. * @param[out] rdataptr Pointer to pointer to return the information.
  92. * @return True if found.
  93. */
  94. XMLP_ret lookforReader(const char* partname, uint16_t id, rtps::ReaderProxyData** rdataptr);
  95. /**
  96. * Look for a writer in the previously loaded endpoints.
  97. * @param[in] partname RTPSParticipant name
  98. * @param[in] id Id of the writer
  99. * @param[out] wdataptr Pointer to pointer to return the information.
  100. * @return True if found
  101. */
  102. XMLP_ret lookforWriter(const char* partname, uint16_t id, rtps::WriterProxyData** wdataptr);
  103. private:
  104. std::set<int16_t> m_endpointIds;
  105. std::set<uint32_t> m_entityIds;
  106. std::vector<StaticRTPSParticipantInfo*> m_RTPSParticipants;
  107. };
  108. } /* xmlparser */
  109. } /* namespace */
  110. } /* namespace eprosima */
  111. #endif
  112. #endif /* XMLENDPOINTPARSER_H_ */