Ported messages from gear racing controller
[apps/native/gear-racing-car.git] / inc / messages / message_factory.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_FACTORY_H
18 #define MESSAGE_FACTORY_H
19
20 #include "messages/message.h"
21
22 /**
23  * @brief the factory handle.
24  */
25 typedef struct _message_factory message_factory_t;
26
27 /**
28  * @brief Creates new instance of message factory.
29  *
30  * @return new factory pointer or NULL on error.
31  */
32 message_factory_t *message_factory_create();
33
34 /**
35  * @brief Destroys factory instance.
36  *
37  * @param[in] factory factory pointer.
38  */
39 void message_factory_destroy(message_factory_t *factory);
40
41 /**
42  * @brief Returns message poiner.
43  *
44  * @param[in] factory factory pointer.
45  * @param[in] type of message to be created.
46  *
47  * @note only ONE message instance returned by a factory is considered
48  * valid at time. User should destroy previous message returned by
49  * this function with @message_destroy function.
50  *
51  * @return message pointer or NULL on error.
52  */
53 message_t *message_factory_create_message(message_factory_t *factory, message_type_e type);
54
55 #endif /* end of include guard: MESSAGE_FACTORY_H */