cpp-common/bt2c/fmt.hpp: use `wise_enum::string_type` in `EnableIfIsWiseEnum` definition
[babeltrace.git] / src / cpp-common / bt2 / internal / utils.hpp
1 /*
2 * Copyright 2019-2020 (c) Philippe Proulx <pproulx@efficios.com>
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7 #ifndef BABELTRACE_CPP_COMMON_BT2_INTERNAL_UTILS_HPP
8 #define BABELTRACE_CPP_COMMON_BT2_INTERNAL_UTILS_HPP
9
10 #include <type_traits>
11
12 #include <babeltrace2/babeltrace.h>
13
14 #include "cpp-common/bt2/exc.hpp"
15
16 namespace bt2 {
17
18 template <typename>
19 class CommonMapValue;
20
21 template <typename>
22 class CommonFieldClass;
23
24 template <typename>
25 class CommonPacket;
26
27 template <typename>
28 class CommonStream;
29
30 namespace internal {
31
32 template <typename LibObjPtrT>
33 void validateCreatedObjPtr(const LibObjPtrT libOjbPtr)
34 {
35 if (!libOjbPtr) {
36 throw MemoryError {};
37 }
38 }
39
40 template <typename LibObjT, typename DepObjT, typename ConstDepObjT>
41 using DepType =
42 typename std::conditional<std::is_const<LibObjT>::value, ConstDepObjT, DepObjT>::type;
43
44 template <typename LibObjT>
45 using DepUserAttrs = DepType<LibObjT, CommonMapValue<bt_value>, CommonMapValue<const bt_value>>;
46
47 template <typename LibObjT>
48 using DepFc =
49 DepType<LibObjT, CommonFieldClass<bt_field_class>, CommonFieldClass<const bt_field_class>>;
50
51 template <typename LibObjT>
52 using DepPacket = DepType<LibObjT, CommonPacket<bt_packet>, CommonPacket<const bt_packet>>;
53
54 template <typename LibObjT>
55 using DepStream = DepType<LibObjT, CommonStream<bt_stream>, CommonStream<const bt_stream>>;
56
57 template <typename ObjT>
58 struct TypeDescr;
59
60 } /* namespace internal */
61 } /* namespace bt2 */
62
63 #endif /* BABELTRACE_CPP_COMMON_BT2_INTERNAL_UTILS_HPP */
This page took 0.030262 seconds and 4 git commands to generate.