]>
git.proxmox.com Git - ceph.git/blob - ceph/src/common/buffer_instrumentation.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #include "include/buffer.h"
5 #include "include/buffer_raw.h"
7 namespace ceph::buffer_instrumentation
{
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`).
14 // users are supposed to define marker type (e.g. `class my_marker{}`).
16 template <class MarkerT
>
17 struct instrumented_raw
: public ceph::buffer::raw
{
21 struct instrumented_bptr
: public ceph::buffer::ptr
{
22 const ceph::buffer::raw
* get_raw() const {
26 template <class MarkerT
>
27 bool is_raw_marked() const {
28 return dynamic_cast<const instrumented_raw
<MarkerT
>*>(get_raw()) != nullptr;
32 } // namespace ceph::buffer_instrumentation