Commit | Line | Data |
---|---|---|
dcfc2f5c PP |
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 | ||
8047a175 PP |
10 | #include <type_traits> |
11 | ||
12 | #include <babeltrace2/babeltrace.h> | |
13 | ||
9a8d4dcc | 14 | #include "cpp-common/bt2/exc.hpp" |
dcfc2f5c PP |
15 | |
16 | namespace bt2 { | |
8047a175 PP |
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 | ||
dcfc2f5c PP |
30 | namespace internal { |
31 | ||
32 | template <typename LibObjPtrT> | |
33 | void validateCreatedObjPtr(const LibObjPtrT libOjbPtr) | |
34 | { | |
35 | if (!libOjbPtr) { | |
39278ebc | 36 | throw MemoryError {}; |
dcfc2f5c PP |
37 | } |
38 | } | |
39 | ||
8047a175 PP |
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 | ||
4927bae7 PP |
57 | template <typename ObjT> |
58 | struct TypeDescr; | |
59 | ||
b5f55e9f PP |
60 | } /* namespace internal */ |
61 | } /* namespace bt2 */ | |
dcfc2f5c | 62 | |
b5f55e9f | 63 | #endif /* BABELTRACE_CPP_COMMON_BT2_INTERNAL_UTILS_HPP */ |