1 //===- FDRLogBuilder.h - XRay FDR Log Building Utility --------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_INCLUDE_LLVM_XRAY_FDRLOGBUILDER_H_
10 #define LLVM_INCLUDE_LLVM_XRAY_FDRLOGBUILDER_H_
12 #include "llvm/XRay/FDRRecords.h"
17 /// The LogBuilder class allows for creating ad-hoc collections of records
18 /// through the `add<...>(...)` function. An example use of this API is in
19 /// crafting arbitrary sequences of records:
21 /// auto Records = LogBuilder()
22 /// .add<BufferExtents>(256)
23 /// .add<NewBufferRecord>(1)
27 std::vector<std::unique_ptr<Record>> Records;
30 template <class R, class... T> LogBuilder &add(T &&... A) {
31 Records.emplace_back(new R(std::forward<T>(A)...));
35 std::vector<std::unique_ptr<Record>> consume() { return std::move(Records); }
41 #endif // LLVM_INCLUDE_LLVM_XRAY_FDRLOGBUILDER_H_