summaryrefslogtreecommitdiff
path: root/interface/vsomeip/payload.hpp
blob: 9b8ea95768e3993192ee5ae5b698f85793b9c768 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef VSOMEIP_V3_PAYLOAD_HPP_
#define VSOMEIP_V3_PAYLOAD_HPP_

#include <vector>

#include <vsomeip/export.hpp>
#include <vsomeip/primitive_types.hpp>

#include <vsomeip/internal/deserializable.hpp>
#include <vsomeip/internal/serializable.hpp>

namespace vsomeip_v3 {

/**
 *
 * \defgroup vsomeip
 *
 * @{
 *
 */

/**
 *
 * \brief This class implements an array of bytes to be used as
 * payload for SOME/IP messages.
 *
*/
class payload: public serializable, public deserializable {
public:
    VSOMEIP_EXPORT virtual ~payload() {}

    /**
     * \brief Returns true if the given payload is equal to this one.
     *
     * \param _other Payload that shall be compared to this payload.
     */
    VSOMEIP_EXPORT virtual bool operator ==(const payload &_other) = 0;

    /**
     * \brief Returns pointer to the payload content
     */
    VSOMEIP_EXPORT virtual byte_t * get_data() = 0;

    /**
     * \brief Returns constant pointer to the payload content
     */
    VSOMEIP_EXPORT virtual const byte_t * get_data() const = 0;

    /**
     * \brief Copies the given data array to the payload object.
     *
     * The current payload content is replaced by the data provided.
     * The given buffer remains untouched.
     *
     * \param _data Pointer to a data buffer.
     * \param _length Length of the data buffer.
     */
    VSOMEIP_EXPORT virtual void set_data(const byte_t *_data,
            length_t _length) = 0;

    /**
     * \brief Copies the given data array to the payload object.
     *
     * The current payload content is replaced by the data provided.
     * The given buffer remains untouched.
     *
     * \param _data Vector containing the data
     */
    VSOMEIP_EXPORT virtual void set_data(
            const std::vector<byte_t> &_data) = 0;

    /**
     * \brief Returns the length of the payload content.
     */
    VSOMEIP_EXPORT virtual length_t get_length() const = 0;

    /**
     * \brief Set the maximum length of the payload content.
     *
     * This function must be called before directly copying data using the
     * pointer to the internal buffer.
     */
    VSOMEIP_EXPORT virtual void set_capacity(length_t _length) = 0;

    /**
     * \brief Moves the given data array to the payload object.
     *
     * The current payload content is replaced by the data provided.
     * The given buffer is owned by the payload object afterwards.
     *
     * \param _data Vector containing the data
     */
    VSOMEIP_EXPORT virtual void set_data(
            std::vector<byte_t> &&_data) = 0;    
};

/** @} */

} // namespace vsomeip_v3

#endif // VSOMEIP_V3_PAYLOAD_HPP_