report-json-serializer: app and top serializers
[apps/native/ttsd-worker-task.git] / src / task.h
1 /*
2 * Copyright 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 __TASK_H_
18 #define __TASK_H_
19
20 #include <stddef.h>
21 #include "report-generator.h"
22
23 /**
24  * @brief The task template.
25  */
26 typedef struct task task_t;
27
28 /**
29  * @brief Called on the task execution.
30  */
31 typedef void(*task_execute_cb)(task_t *task);
32
33 /**
34  * @brief Called on the task release.
35  */
36 typedef void(*task_release_cb)(task_t *task);
37
38 /**
39  * @brief Base task structure.
40  */
41 struct task
42 {
43     task_execute_cb execute;
44     task_release_cb release;
45 };
46
47 /**
48  * @brief System task structure.
49  */
50 typedef struct system_task
51 {
52     task_t task;
53     report_generator_system_t *report_generator;
54 } system_task_t;
55
56 /**
57  * @brief Application task structure.
58  */
59 typedef struct app_task
60 {
61     task_t task;
62     report_generator_app_t *report_generator;
63 } app_task_t;
64
65 /**
66  * @brief Process task structure.
67  */
68 typedef struct process_task
69 {
70     task_t task;
71     report_generator_process_t *report_generator;
72 } process_task_t;
73
74
75 /**
76  * @brief Releases the task.
77  * @param[in] task The task handle.
78  */
79 void task_release(task_t *task);
80
81 /**
82  * @brief Executes the task.
83  * @param[in] task The task handle.
84  */
85 void task_execute(task_t *task);
86
87 #endif