Ported messages from gear racing controller
[apps/native/gear-racing-car.git] / inc / messages / message_ack.h
1 /*
2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3 *
4 * Licensed under the Flora License, Version 1.1 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://floralicense.org/license/
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef MESSAGE_ACK_H
18 #define MESSAGE_ACK_H
19
20 #include "messages/message.h"
21
22 /**
23  * @brief Ack message data
24  */
25 typedef struct message_ack {
26         message_t base;       /** Base class */
27         int64_t ack_serial;   /** The serial of message which reception is confirmed */
28 } message_ack_t;
29
30 /**
31  * @brief Initializes message_ack_t object.
32  *
33  * @param[in] message ack message.
34  */
35 void message_ack_init(message_ack_t *message);
36
37 /**
38  * @brief initializes message_ack_t message form other message.
39  * The serial number returned by @message_ack_get_ack_serial will
40  * be set to @request's serial.
41  *
42  * @param[in] message ack message.
43  * @param[in] request the message which reception will be confirmed by
44  * message_ack_t.
45  */
46 void message_ack_init_from_request(message_ack_t *message, message_t *request);
47
48 /**
49  * @brief Gets serial number of confirmed message.
50  *
51  * @return the serial number.
52  */
53 int64_t message_ack_get_ack_serial(message_ack_t *message);
54
55 /**
56  * @brief Destroys message_ack_t object.
57  *
58  * @param[in] message ack message.
59  */
60 void message_ack_destroy(message_ack_t *message);
61
62 /**
63  * @brief Deserializes message_ack_t from reader's buffer.
64  *
65  * @param[in] message ack message.
66  * @param[in] reader reader object.
67  *
68  * @return 0 on success, other value on failure.
69  */
70 int message_ack_deserialize(message_ack_t *message, reader_t *reader);
71
72 /**
73  * @brief Serializes message_ack_t into writer's buffer.
74  *
75  * @param[in] message message object.
76  * @param[in] writer writer object.
77  *
78  * @return 0 on success, other value on failure.
79  */
80 int message_ack_serialize(message_ack_t *message, writer_t *writer);
81
82 #endif /* end of include guard: MESSAGE_ACK_H */