Program Listing for File serialized_message.hpp

Return to documentation for file (include/rclcpp/serialized_message.hpp)

// Copyright 2020 Open Source Robotics Foundation, Inc.
//
// 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.

#ifndef RCLCPP__SERIALIZED_MESSAGE_HPP_
#define RCLCPP__SERIALIZED_MESSAGE_HPP_

#include "rcl/allocator.h"
#include "rcl/types.h"

#include "rclcpp/visibility_control.hpp"

namespace rclcpp
{

class RCLCPP_PUBLIC_TYPE SerializedMessage
{
public:

  explicit SerializedMessage(
    const rcl_allocator_t & allocator = rcl_get_default_allocator());


  explicit SerializedMessage(
    size_t initial_capacity,
    const rcl_allocator_t & allocator = rcl_get_default_allocator());

  SerializedMessage(const SerializedMessage & other);

  explicit SerializedMessage(const rcl_serialized_message_t & other);

  SerializedMessage(SerializedMessage && other);

  explicit SerializedMessage(rcl_serialized_message_t && other);

  SerializedMessage & operator=(const SerializedMessage & other);

  SerializedMessage & operator=(const rcl_serialized_message_t & other);

  SerializedMessage & operator=(SerializedMessage && other);

  SerializedMessage & operator=(rcl_serialized_message_t && other);

  virtual ~SerializedMessage();

  rcl_serialized_message_t & get_rcl_serialized_message();

  // Get a const handle to the underlying rcl_serialized_message_t
  const rcl_serialized_message_t & get_rcl_serialized_message() const;


  size_t size() const;


  size_t capacity() const;


  void reserve(size_t capacity);


  rcl_serialized_message_t release_rcl_serialized_message();

private:
  rcl_serialized_message_t serialized_message_;
};

}  // namespace rclcpp

#endif  // RCLCPP__SERIALIZED_MESSAGE_HPP_