奥特QT DDS 插件库
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

132 řádky
4.4KB

  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 HelloWorldCdrAux.ipp
  16. * This source file contains some declarations of CDR related functions.
  17. *
  18. * This file was generated by the tool fastddsgen.
  19. */
  20. #ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP
  21. #define FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP
  22. #include "HelloWorldCdrAux.hpp"
  23. #include <fastcdr/Cdr.h>
  24. #include <fastcdr/CdrSizeCalculator.hpp>
  25. #include <fastcdr/exceptions/BadParamException.h>
  26. using namespace eprosima::fastcdr::exception;
  27. namespace eprosima {
  28. namespace fastcdr {
  29. template<>
  30. eProsima_user_DllExport size_t calculate_serialized_size(
  31. eprosima::fastcdr::CdrSizeCalculator& calculator,
  32. const HelloWorld& data,
  33. size_t& current_alignment)
  34. {
  35. static_cast<void>(data);
  36. eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding();
  37. size_t calculated_size {calculator.begin_calculate_type_serialized_size(
  38. eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ?
  39. eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 :
  40. eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR,
  41. current_alignment)};
  42. calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0),
  43. data.index(), current_alignment);
  44. calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1),
  45. data.message(), current_alignment);
  46. calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment);
  47. return calculated_size;
  48. }
  49. template<>
  50. eProsima_user_DllExport void serialize(
  51. eprosima::fastcdr::Cdr& scdr,
  52. const HelloWorld& data)
  53. {
  54. eprosima::fastcdr::Cdr::state current_state(scdr);
  55. scdr.begin_serialize_type(current_state,
  56. eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ?
  57. eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 :
  58. eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR);
  59. scdr
  60. << eprosima::fastcdr::MemberId(0) << data.index()
  61. << eprosima::fastcdr::MemberId(1) << data.message()
  62. ;
  63. scdr.end_serialize_type(current_state);
  64. }
  65. template<>
  66. eProsima_user_DllExport void deserialize(
  67. eprosima::fastcdr::Cdr& cdr,
  68. HelloWorld& data)
  69. {
  70. cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ?
  71. eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 :
  72. eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR,
  73. [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool
  74. {
  75. bool ret_value = true;
  76. switch (mid.id)
  77. {
  78. case 0:
  79. dcdr >> data.index();
  80. break;
  81. case 1:
  82. dcdr >> data.message();
  83. break;
  84. default:
  85. ret_value = false;
  86. break;
  87. }
  88. return ret_value;
  89. });
  90. }
  91. void serialize_key(
  92. eprosima::fastcdr::Cdr& scdr,
  93. const HelloWorld& data)
  94. {
  95. static_cast<void>(scdr);
  96. static_cast<void>(data);
  97. scdr << data.index();
  98. scdr << data.message();
  99. }
  100. } // namespace fastcdr
  101. } // namespace eprosima
  102. #endif // FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP