// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*! * @file ShapeCdrAux.ipp * This source file contains some declarations of CDR related functions. * * This file was generated by the tool fastddsgen. */ #ifndef _FAST_DDS_GENERATED_SHAPECDRAUX_IPP_ #define _FAST_DDS_GENERATED_SHAPECDRAUX_IPP_ #include "ShapeCdrAux.hpp" #include #include #include using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, const ShapeType& data, size_t& current_alignment) { static_cast(data); eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); size_t calculated_size {calculator.begin_calculate_type_serialized_size( eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, current_alignment)}; calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), data.color(), current_alignment); calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), data.x(), current_alignment); calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), data.y(), current_alignment); calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(3), data.shape_size(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); return calculated_size; } template<> eProsima_user_DllExport void serialize( eprosima::fastcdr::Cdr& scdr, const ShapeType& data) { eprosima::fastcdr::Cdr::state current_state(scdr); scdr.begin_serialize_type(current_state, eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); scdr << eprosima::fastcdr::MemberId(0) << data.color() << eprosima::fastcdr::MemberId(1) << data.x() << eprosima::fastcdr::MemberId(2) << data.y() << eprosima::fastcdr::MemberId(3) << data.shape_size() ; scdr.end_serialize_type(current_state); } template<> eProsima_user_DllExport void deserialize( eprosima::fastcdr::Cdr& cdr, ShapeType& data) { cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool { bool ret_value = true; switch (mid.id) { case 0: dcdr >> data.color(); break; case 1: dcdr >> data.x(); break; case 2: dcdr >> data.y(); break; case 3: dcdr >> data.shape_size(); break; default: ret_value = false; break; } return ret_value; }); } void serialize_key( eprosima::fastcdr::Cdr& scdr, const ShapeType& data) { static_cast(scdr); static_cast(data); scdr << data.color(); } } // namespace fastcdr } // namespace eprosima #endif // _FAST_DDS_GENERATED_SHAPECDRAUX_IPP_