summaryrefslogtreecommitdiff
path: root/interface/vsomeip/message_base.hpp
blob: b6efa8bc32654cc51aad0ca41bb1cf39731addb3 (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
// Copyright (C) 2014-2017 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_MESSAGE_BASE_HPP_
#define VSOMEIP_V3_MESSAGE_BASE_HPP_

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

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

namespace vsomeip_v3 {

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

/**
 * \brief Base class to implement SOME/IP messages.
 *
 * This class implements the SOME/IP message header and connects to the
 * serialzing/deserializing functionalities. The class is inherited by
 * the message classes within ::vsomeip and vsomeip::sd that add the
 * payload representations for regular and Service Discovery messages.
 */
class message_base
        : public serializable,
          public deserializable {
public:
    VSOMEIP_EXPORT virtual ~message_base() {};

    /**
     * \brief Returns the message identifier.
     *
     * The method returns the message identifier that consists of
     * service identifier and method identifier.
     */
    VSOMEIP_EXPORT virtual message_t get_message() const = 0;
    /**
     * \brief Set the message identifier.
     *
     * The methods sets service identifier and method identifier in
     * a single call.
     *
     * \param _message The new message identifier.
     */
    VSOMEIP_EXPORT virtual void set_message(message_t _message) = 0;

    /**
     * \brief Returns the service identifier from the message header.
     */
    VSOMEIP_EXPORT virtual service_t get_service() const = 0;

    /**
     * \brief Set the service identifier in the message header.
     */
    VSOMEIP_EXPORT virtual void set_service(service_t _service) = 0;

    /**
     * \brief Returns the instance identifier.
     *
     * The instance identifier is _not_ part of the SOME/IP header. It is
     * either derived from the incoming message (local) or from the port
     * that was used to send a message (external).
     */
    VSOMEIP_EXPORT virtual instance_t get_instance() const = 0;

    /**
     * \brief Set the instance identifier in the message header.
     *
     * To address the correct service instance, vsomeip uses the instance
     * identifier. For external services it is mapped to a IP address and port
     * combination before the message is sent. For internal messages is
     * transferred as additional data appended to the SOME/IP messages.
     * Therefore, before sending a message, a user application must set the
     * instance identifier.
     */
    VSOMEIP_EXPORT virtual void set_instance(instance_t _instance) = 0;

    /**
     * \brief Get the method/event identifier from the message header.
     */
    VSOMEIP_EXPORT virtual method_t get_method() const = 0;

    /**
     * \brief Set the method/event identifier in the message header.
     */
    VSOMEIP_EXPORT virtual void set_method(method_t _method) = 0;

    /**
     * \brief Get the payload length from the message header.
     */
    VSOMEIP_EXPORT virtual length_t get_length() const = 0;

    /**
     * \brief Get the request identifier from the message header.
     *
     * The request identifier consists of the client identifier and the
     * session identifier. As it does really make sense to set it as
     * a whole, setting is not supported.
     */
    VSOMEIP_EXPORT virtual request_t get_request() const = 0;

    /**
     * \brief Set the client identifier in the message header.
     */
    VSOMEIP_EXPORT virtual client_t get_client() const = 0;

    /**
     * \brief Set the client identifier in the message header.
     *
     * For requests this is automatically done by @ref application::send.
     * For notications this is not needed.
     */
    VSOMEIP_EXPORT virtual void set_client(client_t _client) = 0;

    /**
     * \brief Get the session identifier from the message header.
     */
    VSOMEIP_EXPORT virtual session_t get_session() const = 0;

    /**
     * \brief Set the session identifier in the message header.
     *
     * For requests this is automatically done by @ref application::send
     * For notifications it is not needed to set the session identifier.
     */
    VSOMEIP_EXPORT virtual void set_session(session_t _session) = 0;

    /**
     * \brief Get the protocol version from the message header.
     *
     * As the protocol version is a fixed value for a vsomeip implementation,
     * it cannot be set.
     */
    VSOMEIP_EXPORT virtual protocol_version_t get_protocol_version() const = 0;

    /**
     * \brief Get the interface version from the message header.
     */
    VSOMEIP_EXPORT virtual interface_version_t get_interface_version() const = 0;

    /**
     * \brief Set the interface version in the message header.
     */
    VSOMEIP_EXPORT virtual void set_interface_version(interface_version_t _version) = 0;

    /**
     * \brief Get the message type from the message header.
     */
    VSOMEIP_EXPORT virtual message_type_e get_message_type() const = 0;

    /**
     * \brief Set the message type in the message header.
     */
    VSOMEIP_EXPORT virtual void set_message_type(message_type_e _type) = 0;

    /**
     * \brief Get the return code from the message header.
     */
    VSOMEIP_EXPORT virtual return_code_e get_return_code() const = 0;

    /**
     * \brief Set the return code in the message header.
     */
    VSOMEIP_EXPORT virtual void set_return_code(return_code_e _code) = 0;

    /**
     * \brief Return the transport mode that was/will be used to send the message.
     */
    VSOMEIP_EXPORT virtual bool is_reliable() const = 0;

    /**
     * \brief Set the transport mode that will be used to send the message.
     */
    VSOMEIP_EXPORT virtual void set_reliable(bool _is_reliable) = 0;

    /**
     * \brief Return whether or not the message is an initial event.
     */
    VSOMEIP_EXPORT virtual bool is_initial() const = 0;

    /**
     * \brief Set whether or not the message is an initial event.
     */
    VSOMEIP_EXPORT virtual void set_initial(bool _is_initial) = 0;

};

} // namespace vsomeip_v3

#endif // VSOMEIP_V3_MESSAGE_BASE_HPP_