Ported messages from gear racing controller
[apps/native/gear-racing-car.git] / inc / messages / message_command.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_COMMAND_H
18 #define MESSAGE_COMMAND_H
19
20 #include "command.h"
21 #include "messages/message.h"
22
23 /**
24  * @brief Command message data
25  */
26 typedef struct message_command {
27         message_t base;    /** Base class */
28         command_s command; /** Command carried by message */
29 } message_command_t;
30
31 /**
32  * @brief Initializes message_command_t object.
33  *
34  * @param[in] message ack message.
35  */
36 void message_command_init(message_command_t *message);
37
38 /**
39  * @brief Get command for mesage.
40  *
41  * @param[in] message ack message.
42  *
43  * @return command const pointer.
44  */
45 const command_s *message_command_get_command(message_command_t *message);
46
47 /**
48  * @brief Set command for mesage.
49  *
50  * @param[in] message ack message.
51  * @param[in] command command to be set.
52  */
53 void message_command_set_command(message_command_t *message, const command_s *cmd);
54
55 /**
56  * @brief Destroys message_command_t object.
57  *
58  * @param[in] message ack message.
59  */
60 void message_command_destroy(message_command_t *message);
61
62 /**
63  * @brief Deserializes message_command_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_command_deserialize(message_command_t *message, reader_t *reader);
71
72 /**
73  * @brief Serializes message_command_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_command_serialize(message_command_t *message, writer_t *writer);
81
82 #endif /* end of include guard: MESSAGE_COMMAND_H */