EDPStatic.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 EDPStatic.h
  16. *
  17. */
  18. #ifndef _FASTDDS_RTPS_EDPSTATIC_H_
  19. #define _FASTDDS_RTPS_EDPSTATIC_H_
  20. #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
  21. #include <fastdds/rtps/builtin/discovery/endpoint/EDP.h>
  22. namespace eprosima {
  23. namespace fastrtps{
  24. namespace xmlparser{
  25. class XMLEndpointParser;
  26. }
  27. namespace rtps {
  28. /**
  29. * Class EDPStaticProperty, used to read and write the strings from the properties used to transmit the EntityId_t.
  30. *@ingroup DISCOVERY_MODULE
  31. */
  32. class EDPStaticProperty
  33. {
  34. public:
  35. EDPStaticProperty():m_userId(0){};
  36. ~EDPStaticProperty(){};
  37. //!Endpoint type
  38. std::string m_endpointType;
  39. //!Status
  40. std::string m_status;
  41. //!User ID as string
  42. std::string m_userIdStr;
  43. //!User ID
  44. uint16_t m_userId;
  45. //!Entity ID
  46. EntityId_t m_entityId;
  47. /**
  48. * Convert information to a property
  49. * @param type Type of endpoint
  50. * @param status Status of the endpoint
  51. * @param id User Id
  52. * @param ent EntityId
  53. * @return Pair of two strings.
  54. */
  55. static std::pair<std::string,std::string> toProperty(std::string type,std::string status,uint16_t id,const EntityId_t& ent);
  56. /**
  57. * @param in_property Input property-
  58. * @return True if correctly read
  59. */
  60. bool fromProperty(std::pair<std::string,std::string> in_property);
  61. };
  62. /**
  63. * Class EDPStatic, implements a static endpoint discovery module.
  64. * @ingroup DISCOVERYMODULE
  65. */
  66. class EDPStatic : public EDP {
  67. public:
  68. /**
  69. * Constructor.
  70. * @param p Pointer to the PDPSimple.
  71. * @param part Pointer to the RTPSParticipantImpl.
  72. */
  73. EDPStatic(PDP* p,RTPSParticipantImpl* part);
  74. virtual ~EDPStatic();
  75. /**
  76. * Abstract method to initialize the EDP.
  77. * @param attributes DiscoveryAttributes structure.
  78. * @return True if correct.
  79. */
  80. bool initEDP(BuiltinAttributes& attributes) override;
  81. /**
  82. * Abstract method that assigns remote endpoints when a new RTPSParticipantProxyData is discovered.
  83. * @param pdata Pointer to the ParticipantProxyData.
  84. */
  85. void assignRemoteEndpoints(const ParticipantProxyData& pdata) override;
  86. /**
  87. * Abstract method that removes a local Reader from the discovery method
  88. * @param R Pointer to the Reader to remove.
  89. * @return True if correctly removed.
  90. */
  91. bool removeLocalReader(RTPSReader* R) override;
  92. /**
  93. * Abstract method that removes a local Writer from the discovery method
  94. * @param W Pointer to the Writer to remove.
  95. * @return True if correctly removed.
  96. */
  97. bool removeLocalWriter(RTPSWriter*W) override;
  98. /**
  99. * After a new local ReaderProxyData has been created some processing is needed (depends on the implementation).
  100. * @param reader Pointer to the RTPSReader object.
  101. * @param rdata Pointer to the ReaderProxyData object.
  102. * @return True if correct.
  103. */
  104. bool processLocalReaderProxyData(RTPSReader* reader, ReaderProxyData* rdata) override;
  105. /**
  106. * After a new local WriterProxyData has been created some processing is needed (depends on the implementation).
  107. * @param writer Pointer to the RTPSWriter object.
  108. * @param wdata Pointer to the Writer ProxyData object.
  109. * @return True if correct.
  110. */
  111. bool processLocalWriterProxyData(RTPSWriter* writer, WriterProxyData* wdata) override;
  112. /**
  113. * New Remote Writer has been found and this method process it and calls the pairing methods.
  114. * @param participant_guid GUID of the participant.
  115. * @param participant_name Name of the participant.
  116. * @param user_id User Id.
  117. * @param ent_id Entity Id.
  118. * @return True if correct.
  119. */
  120. bool newRemoteWriter(
  121. const GUID_t& participant_guid,
  122. const string_255& participant_name,
  123. uint16_t user_id,
  124. EntityId_t ent_id = c_EntityId_Unknown);
  125. /**
  126. * New Remote Reader has been found and this method process it and calls the pairing methods.
  127. * @param participant_guid GUID of the participant.
  128. * @param participant_name Name of the participant.
  129. * @param user_id User Id.
  130. * @param ent_id Entity Id.
  131. * @return true if correct.
  132. */
  133. bool newRemoteReader(
  134. const GUID_t& participant_guid,
  135. const string_255& participant_name,
  136. uint16_t user_id,
  137. EntityId_t ent_id = c_EntityId_Unknown);
  138. /**
  139. * This method checks the provided entityId against the topic type to see if it matches
  140. * @param rdata Pointer to the readerProxyData
  141. * @return True if its correct.
  142. **/
  143. bool checkEntityId(ReaderProxyData* rdata);
  144. /**
  145. * This method checks the provided entityId against the topic type to see if it matches
  146. * @param wdata Pointer to the writerProxyData
  147. * @return True if its correct.
  148. **/
  149. bool checkEntityId(WriterProxyData* wdata);
  150. private:
  151. xmlparser::XMLEndpointParser* mp_edpXML;
  152. BuiltinAttributes m_attributes;
  153. };
  154. }
  155. } /* namespace rtps */
  156. } /* namespace eprosima */
  157. #endif
  158. #endif /* _FASTDDS_RTPS_EDPSTATIC_H_ */