]> git.proxmox.com Git - ceph.git/blame - ceph/src/common/buffer_instrumentation.h
update ceph source to reef 18.2.0
[ceph.git] / ceph / src / common / buffer_instrumentation.h
CommitLineData
20effc67
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3
4#include "include/buffer.h"
5#include "include/buffer_raw.h"
6
7namespace ceph::buffer_instrumentation {
8
9// this is nothing more than an intermediary for a class hierarchy which
10// can placed between a user's custom raw and the `ceph::buffer::raw` to
11// detect whether a given `ceph::buffer::ptr` instance wraps a particular
12// raw's implementation (via `dynamic_cast` or `typeid`).
13//
14// users are supposed to define marker type (e.g. `class my_marker{}`).
15// this marker. i
16template <class MarkerT>
17struct instrumented_raw : public ceph::buffer::raw {
18 using raw::raw;
19};
20
21struct instrumented_bptr : public ceph::buffer::ptr {
22 const ceph::buffer::raw* get_raw() const {
23 return _raw;
24 }
25
26 template <class MarkerT>
27 bool is_raw_marked() const {
28 return dynamic_cast<const instrumented_raw<MarkerT>*>(get_raw()) != nullptr;
29 }
30};
31
32} // namespace ceph::buffer_instrumentation