Topics.cxx 7.2 KB

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