Topics.cxx 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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 Topics.cpp
  16. * This source file contains the definition of the described types in the IDL file.
  17. *
  18. * This file was generated by the tool gen.
  19. */
  20. #ifdef USE_FASTRTPS
  21. #ifdef _WIN32
  22. // Remove linker warning LNK4221 on Visual Studio
  23. namespace { char dummy; }
  24. #endif
  25. #include "Topics.h"
  26. #include <fastcdr/Cdr.h>
  27. #include <fastcdr/exceptions/BadParamException.h>
  28. using namespace eprosima::fastcdr::exception;
  29. #include <utility>
  30. TopicSample::Message::Message()
  31. {
  32. // m_msgname com.eprosima.idl.parser.typecode.StringTypeCode@76329302
  33. m_msgname ="";
  34. // m_counter com.eprosima.idl.parser.typecode.PrimitiveTypeCode@5e25a92e
  35. m_counter = 0;
  36. // m_sendtime com.eprosima.idl.parser.typecode.PrimitiveTypeCode@4df828d7
  37. m_sendtime = 0;
  38. // m_xdata com.eprosima.idl.parser.typecode.AliasTypeCode@b59d31
  39. m_xdata.push_back(1);
  40. m_xdata.push_back(2);
  41. }
  42. TopicSample::Message::~Message()
  43. {
  44. }
  45. TopicSample::Message::Message(const Message &x)
  46. {
  47. m_msgname = x.m_msgname;
  48. m_counter = x.m_counter;
  49. m_sendtime = x.m_sendtime;
  50. m_xdata = x.m_xdata;
  51. }
  52. TopicSample::Message::Message(Message &&x)
  53. {
  54. m_msgname = std::move(x.m_msgname);
  55. m_counter = x.m_counter;
  56. m_sendtime = x.m_sendtime;
  57. m_xdata = std::move(x.m_xdata);
  58. }
  59. TopicSample::Message& TopicSample::Message::operator=(const Message &x)
  60. {
  61. m_msgname = x.m_msgname;
  62. m_counter = x.m_counter;
  63. m_sendtime = x.m_sendtime;
  64. m_xdata = x.m_xdata;
  65. return *this;
  66. }
  67. TopicSample::Message& TopicSample::Message::operator=(Message &&x)
  68. {
  69. m_msgname = std::move(x.m_msgname);
  70. m_counter = x.m_counter;
  71. m_sendtime = x.m_sendtime;
  72. m_xdata = std::move(x.m_xdata);
  73. return *this;
  74. }
  75. size_t TopicSample::Message::getMaxCdrSerializedSize(size_t current_alignment)
  76. {
  77. size_t initial_alignment = current_alignment;
  78. current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + 255 + 1;
  79. current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
  80. current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8);
  81. current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
  82. current_alignment += (100 * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
  83. return 10000000;
  84. // return current_alignment - initial_alignment;
  85. }
  86. size_t TopicSample::Message::getCdrSerializedSize(const TopicSample::Message& data, size_t current_alignment)
  87. {
  88. (void)data;
  89. size_t initial_alignment = current_alignment;
  90. current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.msgname().size() + 1;
  91. current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
  92. current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8);
  93. current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
  94. if (data.xdata().size() > 0)
  95. {
  96. current_alignment += (data.xdata().size() * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
  97. }
  98. return current_alignment - initial_alignment;
  99. }
  100. void TopicSample::Message::serialize(eprosima::fastcdr::Cdr &scdr) const
  101. {
  102. scdr << m_msgname;
  103. scdr << m_counter;
  104. scdr << m_sendtime;
  105. scdr << m_xdata;
  106. // std::cout<<"serialize."<<std::endl;
  107. }
  108. void TopicSample::Message::deserialize(eprosima::fastcdr::Cdr &dcdr)
  109. {
  110. dcdr >> m_msgname;
  111. dcdr >> m_counter;
  112. dcdr >> m_sendtime;
  113. dcdr >> m_xdata;
  114. }
  115. /*!
  116. * @brief This function copies the value in member msgname
  117. * @param _msgname New value to be copied in member msgname
  118. */
  119. void TopicSample::Message::msgname(const std::string &_msgname)
  120. {
  121. m_msgname = _msgname;
  122. }
  123. /*!
  124. * @brief This function moves the value in member msgname
  125. * @param _msgname New value to be moved in member msgname
  126. */
  127. void TopicSample::Message::msgname(std::string &&_msgname)
  128. {
  129. m_msgname = std::move(_msgname);
  130. }
  131. /*!
  132. * @brief This function returns a constant reference to member msgname
  133. * @return Constant reference to member msgname
  134. */
  135. const std::string& TopicSample::Message::msgname() const
  136. {
  137. return m_msgname;
  138. }
  139. /*!
  140. * @brief This function returns a reference to member msgname
  141. * @return Reference to member msgname
  142. */
  143. std::string& TopicSample::Message::msgname()
  144. {
  145. return m_msgname;
  146. }
  147. /*!
  148. * @brief This function sets a value in member counter
  149. * @param _counter New value for member counter
  150. */
  151. void TopicSample::Message::counter(int32_t _counter)
  152. {
  153. m_counter = _counter;
  154. }
  155. /*!
  156. * @brief This function returns the value of member counter
  157. * @return Value of member counter
  158. */
  159. int32_t TopicSample::Message::counter() const
  160. {
  161. return m_counter;
  162. }
  163. /*!
  164. * @brief This function returns a reference to member counter
  165. * @return Reference to member counter
  166. */
  167. int32_t& TopicSample::Message::counter()
  168. {
  169. return m_counter;
  170. }
  171. /*!
  172. * @brief This function sets a value in member sendtime
  173. * @param _sendtime New value for member sendtime
  174. */
  175. void TopicSample::Message::sendtime(int64_t _sendtime)
  176. {
  177. m_sendtime = _sendtime;
  178. }
  179. /*!
  180. * @brief This function returns the value of member sendtime
  181. * @return Value of member sendtime
  182. */
  183. int64_t TopicSample::Message::sendtime() const
  184. {
  185. return m_sendtime;
  186. }
  187. /*!
  188. * @brief This function returns a reference to member sendtime
  189. * @return Reference to member sendtime
  190. */
  191. int64_t& TopicSample::Message::sendtime()
  192. {
  193. return m_sendtime;
  194. }
  195. /*!
  196. * @brief This function copies the value in member xdata
  197. * @param _xdata New value to be copied in member xdata
  198. */
  199. void TopicSample::Message::xdata(const TopicSample::SomeBytes &_xdata)
  200. {
  201. // return;
  202. m_xdata = _xdata;
  203. //int i;
  204. //for(i=0;i<300;i++)
  205. // m_xdata.push_back(_xdata.at(i));
  206. }
  207. /*!
  208. * @brief This function moves the value in member xdata
  209. * @param _xdata New value to be moved in member xdata
  210. */
  211. void TopicSample::Message::xdata(TopicSample::SomeBytes &&_xdata)
  212. {
  213. m_xdata = std::move(_xdata);
  214. }
  215. /*!
  216. * @brief This function returns a constant reference to member xdata
  217. * @return Constant reference to member xdata
  218. */
  219. const TopicSample::SomeBytes& TopicSample::Message::xdata() const
  220. {
  221. return m_xdata;
  222. }
  223. /*!
  224. * @brief This function returns a reference to member xdata
  225. * @return Reference to member xdata
  226. */
  227. TopicSample::SomeBytes& TopicSample::Message::xdata()
  228. {
  229. return m_xdata;
  230. }
  231. size_t TopicSample::Message::getKeyMaxCdrSerializedSize(size_t current_alignment)
  232. {
  233. size_t current_align = current_alignment;
  234. return current_align;
  235. }
  236. bool TopicSample::Message::isKeyDefined()
  237. {
  238. return false;
  239. }
  240. void TopicSample::Message::serializeKey(eprosima::fastcdr::Cdr &scdr) const
  241. {
  242. (void) scdr;
  243. }
  244. #endif