LLVM 22.0.0git
FDRLogBuilder.h
Go to the documentation of this file.
1//===- FDRLogBuilder.h - XRay FDR Log Building Utility --------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8#ifndef LLVM_XRAY_FDRLOGBUILDER_H
9#define LLVM_XRAY_FDRLOGBUILDER_H
10
12
13namespace llvm::xray {
14
15/// The LogBuilder class allows for creating ad-hoc collections of records
16/// through the `add<...>(...)` function. An example use of this API is in
17/// crafting arbitrary sequences of records:
18///
19/// auto Records = LogBuilder()
20/// .add<BufferExtents>(256)
21/// .add<NewBufferRecord>(1)
22/// .consume();
23///
25 std::vector<std::unique_ptr<Record>> Records;
26
27public:
28 template <class R, class... T> LogBuilder &add(T &&... A) {
29 Records.emplace_back(new R(std::forward<T>(A)...));
30 return *this;
31 }
32
33 std::vector<std::unique_ptr<Record>> consume() { return std::move(Records); }
34};
35
36} // namespace llvm::xray
37
38#endif // LLVM_XRAY_FDRLOGBUILDER_H
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define T
The LogBuilder class allows for creating ad-hoc collections of records through the add<....
LogBuilder & add(T &&... A)
std::vector< std::unique_ptr< Record > > consume()