| 1 | #ifndef BABELTRACE2_GRAPH_SELF_COMPONENT_CLASS_H |
| 2 | #define BABELTRACE2_GRAPH_SELF_COMPONENT_CLASS_H |
| 3 | |
| 4 | /* |
| 5 | * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation |
| 6 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | * of this software and associated documentation files (the "Software"), to deal |
| 9 | * in the Software without restriction, including without limitation the rights |
| 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | * copies of the Software, and to permit persons to whom the Software is |
| 12 | * furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice shall be included in |
| 15 | * all copies or substantial portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | * SOFTWARE. |
| 24 | */ |
| 25 | |
| 26 | #ifndef __BT_IN_BABELTRACE_H |
| 27 | # error "Please include <babeltrace2/babeltrace.h> instead." |
| 28 | #endif |
| 29 | |
| 30 | #include <babeltrace2/types.h> |
| 31 | |
| 32 | #ifdef __cplusplus |
| 33 | extern "C" { |
| 34 | #endif |
| 35 | |
| 36 | /*! |
| 37 | @defgroup api-self-comp-cls Self component classes |
| 38 | @ingroup api-comp-cls-dev |
| 39 | |
| 40 | @brief |
| 41 | Private views of \bt_p_comp_cls for class methods. |
| 42 | |
| 43 | The #bt_self_component_class, #bt_self_component_class_source, |
| 44 | #bt_self_component_class_filter, #bt_self_component_class_sink types are |
| 45 | private views of a \bt_comp_cls from within a component class |
| 46 | \ref api-comp-cls-dev-class-meth "class method". |
| 47 | |
| 48 | As of \bt_name_version_min_maj, this module only contains functions |
| 49 | to \ref api-fund-c-typing "upcast" the "self" (private) types to their |
| 50 | public #bt_component_class, #bt_component_class_source, |
| 51 | #bt_component_class_filter, and #bt_component_class_sink counterparts. |
| 52 | */ |
| 53 | |
| 54 | /*! @{ */ |
| 55 | |
| 56 | /*! |
| 57 | @name Types |
| 58 | @{ |
| 59 | |
| 60 | @typedef struct bt_self_component_class bt_self_component_class; |
| 61 | |
| 62 | @brief |
| 63 | Self \bt_comp_cls. |
| 64 | |
| 65 | @typedef struct bt_self_component_class_source bt_self_component_class_source; |
| 66 | |
| 67 | @brief |
| 68 | Self \bt_src_comp_cls. |
| 69 | |
| 70 | @typedef struct bt_self_component_class_filter bt_self_component_class_filter; |
| 71 | |
| 72 | @brief |
| 73 | Self \bt_flt_comp_cls. |
| 74 | |
| 75 | @typedef struct bt_self_component_class_sink bt_self_component_class_sink; |
| 76 | |
| 77 | @brief |
| 78 | Self \bt_sink_comp_cls. |
| 79 | |
| 80 | @} |
| 81 | */ |
| 82 | |
| 83 | /*! |
| 84 | @name Self to public upcast |
| 85 | @{ |
| 86 | */ |
| 87 | |
| 88 | /*! |
| 89 | @brief |
| 90 | \ref api-fund-c-typing "Upcasts" the self \bt_comp_cls |
| 91 | \bt_p{self_component_class} to the public #bt_component_class type. |
| 92 | |
| 93 | @param[in] self_component_class |
| 94 | @parblock |
| 95 | Component class to upcast. |
| 96 | |
| 97 | Can be \c NULL. |
| 98 | @endparblock |
| 99 | |
| 100 | @returns |
| 101 | \bt_p{self_component_class} as a public component class. |
| 102 | */ |
| 103 | static inline |
| 104 | const bt_component_class *bt_self_component_class_as_component_class( |
| 105 | bt_self_component_class *self_component_class) |
| 106 | { |
| 107 | return __BT_UPCAST(bt_component_class, self_component_class); |
| 108 | } |
| 109 | |
| 110 | /*! |
| 111 | @brief |
| 112 | \ref api-fund-c-typing "Upcasts" the self \bt_src_comp_cls |
| 113 | \bt_p{self_component_class} to the public #bt_component_class_source |
| 114 | type. |
| 115 | |
| 116 | @param[in] self_component_class |
| 117 | @parblock |
| 118 | Source component class to upcast. |
| 119 | |
| 120 | Can be \c NULL. |
| 121 | @endparblock |
| 122 | |
| 123 | @returns |
| 124 | \bt_p{self_component_class} as a public source component class. |
| 125 | */ |
| 126 | static inline |
| 127 | const bt_component_class_source * |
| 128 | bt_self_component_class_source_as_component_class_source( |
| 129 | bt_self_component_class_source *self_component_class) |
| 130 | { |
| 131 | return __BT_UPCAST_CONST(bt_component_class_source, |
| 132 | self_component_class); |
| 133 | } |
| 134 | |
| 135 | /*! |
| 136 | @brief |
| 137 | \ref api-fund-c-typing "Upcasts" the self \bt_flt_comp_cls |
| 138 | \bt_p{self_component_class} to the public #bt_component_class_filter |
| 139 | type. |
| 140 | |
| 141 | @param[in] self_component_class |
| 142 | @parblock |
| 143 | Filter component class to upcast. |
| 144 | |
| 145 | Can be \c NULL. |
| 146 | @endparblock |
| 147 | |
| 148 | @returns |
| 149 | \bt_p{self_component_class} as a public filter component class. |
| 150 | */ |
| 151 | static inline |
| 152 | const bt_component_class_filter * |
| 153 | bt_self_component_class_filter_as_component_class_filter( |
| 154 | bt_self_component_class_filter *self_component_class) |
| 155 | { |
| 156 | return __BT_UPCAST_CONST(bt_component_class_filter, |
| 157 | self_component_class); |
| 158 | } |
| 159 | |
| 160 | /*! |
| 161 | @brief |
| 162 | \ref api-fund-c-typing "Upcasts" the self \bt_sink_comp_cls |
| 163 | \bt_p{self_component_class} to the public #bt_component_class_sink |
| 164 | type. |
| 165 | |
| 166 | @param[in] self_component_class |
| 167 | @parblock |
| 168 | Sink component class to upcast. |
| 169 | |
| 170 | Can be \c NULL. |
| 171 | @endparblock |
| 172 | |
| 173 | @returns |
| 174 | \bt_p{self_component_class} as a public sink component class. |
| 175 | */ |
| 176 | static inline |
| 177 | const bt_component_class_sink * |
| 178 | bt_self_component_class_sink_as_component_class_sink( |
| 179 | bt_self_component_class_sink *self_component_class) |
| 180 | { |
| 181 | return __BT_UPCAST_CONST(bt_component_class_sink, self_component_class); |
| 182 | } |
| 183 | |
| 184 | /*! @} */ |
| 185 | |
| 186 | /*! |
| 187 | @name Self to common self upcast |
| 188 | @{ |
| 189 | */ |
| 190 | |
| 191 | /*! |
| 192 | @brief |
| 193 | \ref api-fund-c-typing "Upcasts" the self \bt_src_comp_cls |
| 194 | \bt_p{self_component_class} to the common #bt_self_component_class |
| 195 | type. |
| 196 | |
| 197 | @param[in] self_component_class |
| 198 | @parblock |
| 199 | Source component class to upcast. |
| 200 | |
| 201 | Can be \c NULL. |
| 202 | @endparblock |
| 203 | |
| 204 | @returns |
| 205 | \bt_p{self_component_class} as a common self component class. |
| 206 | */ |
| 207 | static inline |
| 208 | bt_self_component_class* |
| 209 | bt_self_component_class_source_as_self_component_class( |
| 210 | bt_self_component_class_source *self_component_class) |
| 211 | { |
| 212 | return __BT_UPCAST(bt_self_component_class, self_component_class); |
| 213 | } |
| 214 | |
| 215 | /*! |
| 216 | @brief |
| 217 | \ref api-fund-c-typing "Upcasts" the self \bt_flt_comp_cls |
| 218 | \bt_p{self_component_class} to the common #bt_self_component_class |
| 219 | type. |
| 220 | |
| 221 | @param[in] self_component_class |
| 222 | @parblock |
| 223 | Filter component class to upcast. |
| 224 | |
| 225 | Can be \c NULL. |
| 226 | @endparblock |
| 227 | |
| 228 | @returns |
| 229 | \bt_p{self_component_class} as a common self component class. |
| 230 | */ |
| 231 | static inline |
| 232 | bt_self_component_class* |
| 233 | bt_self_component_class_filter_as_self_component_class( |
| 234 | bt_self_component_class_filter *self_component_class) |
| 235 | { |
| 236 | return __BT_UPCAST(bt_self_component_class, self_component_class); |
| 237 | } |
| 238 | |
| 239 | /*! |
| 240 | @brief |
| 241 | \ref api-fund-c-typing "Upcasts" the self \bt_sink_comp_cls |
| 242 | \bt_p{self_component_class} to the common #bt_self_component_class |
| 243 | type. |
| 244 | |
| 245 | @param[in] self_component_class |
| 246 | @parblock |
| 247 | Sink component class to upcast. |
| 248 | |
| 249 | Can be \c NULL. |
| 250 | @endparblock |
| 251 | |
| 252 | @returns |
| 253 | \bt_p{self_component_class} as a common self component class. |
| 254 | */ |
| 255 | static inline |
| 256 | bt_self_component_class* |
| 257 | bt_self_component_class_sink_as_self_component_class( |
| 258 | bt_self_component_class_sink *self_component_class) |
| 259 | { |
| 260 | return __BT_UPCAST(bt_self_component_class, self_component_class); |
| 261 | } |
| 262 | |
| 263 | /*! @} */ |
| 264 | |
| 265 | /*! @} */ |
| 266 | |
| 267 | #ifdef __cplusplus |
| 268 | } |
| 269 | #endif |
| 270 | |
| 271 | #endif /* BABELTRACE2_GRAPH_SELF_COMPONENT_CLASS_H */ |