1 //===- FDRRecordConsumer.h - XRay Flight Data Recorder Mode Records -------===//
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
7 //===----------------------------------------------------------------------===//
8 #ifndef LLVM_INCLUDE_LLVM_XRAY_FDRRECORDCONSUMER_H_
9 #define LLVM_INCLUDE_LLVM_XRAY_FDRRECORDCONSUMER_H_
11 #include "llvm/Support/Error.h"
12 #include "llvm/XRay/FDRRecords.h"
20 class RecordConsumer
{
22 virtual Error
consume(std::unique_ptr
<Record
> R
) = 0;
23 virtual ~RecordConsumer() = default;
26 // This consumer will collect all the records into a vector of records, in
28 class LogBuilderConsumer
: public RecordConsumer
{
29 std::vector
<std::unique_ptr
<Record
>> &Records
;
32 explicit LogBuilderConsumer(std::vector
<std::unique_ptr
<Record
>> &R
)
33 : RecordConsumer(), Records(R
) {}
35 Error
consume(std::unique_ptr
<Record
> R
) override
;
38 // A PipelineConsumer applies a set of visitors to every consumed Record, in the
39 // order by which the visitors are added to the pipeline in the order of
41 class PipelineConsumer
: public RecordConsumer
{
42 std::vector
<RecordVisitor
*> Visitors
;
45 PipelineConsumer(std::initializer_list
<RecordVisitor
*> V
)
46 : RecordConsumer(), Visitors(V
) {}
48 Error
consume(std::unique_ptr
<Record
> R
) override
;
54 #endif // LLVM_INCLUDE_LLVM_XRAY_FDRRECORDCONSUMER_H_