Buffer traits: add `platform`
[platform/core/system/dlog.git] / include / buffer_traits.h
1 /*  MIT License
2  *
3  * Copyright (c) 2023 Samsung Electronics Co., Ltd
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this software and associated documentation files (the "Software"), to deal
7  * in the Software without restriction, including without limitation the rights
8  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9  * copies of the Software, and to permit persons to whom the Software is furnished
10  * to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21  * THE SOFTWARE. */
22
23 #pragma once
24
25 #include <dlog-internal.h>
26 #include <stdbool.h>
27
28 /**
29  * @brief Get buffer ID by name
30  * @details Returns the ID of the buffer with the given name
31  * @param[in] name The name of the buffer whose ID we seek
32  * @return If such buffer exists, its ID.
33  *         Else, LOG_ID_INVALID.
34  * @see log_name_by_id
35  */
36 log_id_t log_id_by_name(const char *name);
37
38 /**
39  * @brief Get buffer name by ID
40  * @details Returns the name of the buffer with the given ID
41  * @param[in] id The ID of the buffer whose name we seek
42  * @return If such buffer exists, its name.
43  *         Else, empty string.
44  * @see log_id_by_name
45  */
46 char * log_name_by_id(log_id_t id);
47
48 /**
49  * @brief Is core buffer
50  * @details Returns whether given buffer is one of the original four buffers
51  * @param[in] id The ID of the buffer
52  * @return boolean
53  */
54 bool is_core_buffer(log_id_t id);
55
56 /**
57  * @brief Is platform buffer
58  * @details Returns whether given buffer is meant for platform use
59  * @param[in] id The ID of the buffer
60  * @return boolean
61  */
62 bool is_platform_buffer(log_id_t id);
63
64 /**
65  * @brief Is buffer valid
66  * @details Returns whether given buffer ID represents an actual buffer
67  * @param[in] id The ID of the buffer
68  * @return boolean
69  */
70 bool is_buffer_valid(log_id_t id);
71