blob: 4655b1897e86138ce72ad88b8967c25c45de15b9 [file] [log] [blame]
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +01001/*
2 * Copyright (c) 2023 Arm Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010025#ifndef CKW_PROTOTYPE_EXAMPLES_COMMON_EXAMPLESCOPEDKERNELWRITER_H
26#define CKW_PROTOTYPE_EXAMPLES_COMMON_EXAMPLESCOPEDKERNELWRITER_H
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010027
28#include <cstdint>
29
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010030class ExampleKernelWriter;
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010031
32/** Helper to automatically manage kernel writer ID space. */
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010033class ExampleScopedKernelWriter
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010034{
35public:
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010036 /** Initialize a new instance of @ref ExampleScopedKernelWriter class. */
37 explicit ExampleScopedKernelWriter(ExampleKernelWriter *writer);
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010038
39 /** Create a new scope from the specified scoped kernel writer. */
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010040 ExampleScopedKernelWriter(const ExampleScopedKernelWriter &other);
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010041
42 /** Assignment is disallowed. */
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010043 ExampleScopedKernelWriter &operator=(const ExampleScopedKernelWriter &) = delete;
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010044
45 /** Access the underlying kernel writer. */
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010046 ExampleKernelWriter *operator->();
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010047
48 /** Access the underlying kernel writer. */
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010049 const ExampleKernelWriter *operator->() const;
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010050
51 /** Get the kernel writer. */
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010052 ExampleKernelWriter *writer();
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010053
54 /** Get the kernel writer. */
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010055 const ExampleKernelWriter *writer() const;
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010056
57private:
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010058 ExampleKernelWriter *_writer;
Nikolaj Jensenacea4072023-07-03 09:44:42 +010059 int32_t _parent_id_space;
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010060};
61
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010062#endif // CKW_PROTOTYPE_EXAMPLES_COMMON_EXAMPLESCOPEDKERNELWRITER_H