LLVM  14.0.0git
FDRRecordConsumer.h
Go to the documentation of this file.
1 //===- FDRRecordConsumer.h - XRay Flight Data Recorder Mode Records -------===//
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_FDRRECORDCONSUMER_H
9 #define LLVM_XRAY_FDRRECORDCONSUMER_H
10 
11 #include "llvm/Support/Error.h"
12 #include "llvm/XRay/FDRRecords.h"
13 #include <algorithm>
14 #include <memory>
15 #include <vector>
16 
17 namespace llvm {
18 namespace xray {
19 
21 public:
22  virtual Error consume(std::unique_ptr<Record> R) = 0;
23  virtual ~RecordConsumer() = default;
24 };
25 
26 // This consumer will collect all the records into a vector of records, in
27 // arrival order.
29  std::vector<std::unique_ptr<Record>> &Records;
30 
31 public:
32  explicit LogBuilderConsumer(std::vector<std::unique_ptr<Record>> &R)
33  : RecordConsumer(), Records(R) {}
34 
35  Error consume(std::unique_ptr<Record> R) override;
36 };
37 
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
40 // appearance.
42  std::vector<RecordVisitor *> Visitors;
43 
44 public:
45  PipelineConsumer(std::initializer_list<RecordVisitor *> V)
46  : RecordConsumer(), Visitors(V) {}
47 
48  Error consume(std::unique_ptr<Record> R) override;
49 };
50 
51 } // namespace xray
52 } // namespace llvm
53 
54 #endif // LLVM_XRAY_FDRRECORDCONSUMER_H
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::xray::LogBuilderConsumer
Definition: FDRRecordConsumer.h:28
Error.h
llvm::xray::RecordConsumer::~RecordConsumer
virtual ~RecordConsumer()=default
llvm::xray::LogBuilderConsumer::LogBuilderConsumer
LogBuilderConsumer(std::vector< std::unique_ptr< Record >> &R)
Definition: FDRRecordConsumer.h:32
llvm::xray::RecordConsumer
Definition: FDRRecordConsumer.h:20
llvm::xray::PipelineConsumer::consume
Error consume(std::unique_ptr< Record > R) override
Definition: LogBuilderConsumer.cpp:22
llvm::xray::RecordConsumer::consume
virtual Error consume(std::unique_ptr< Record > R)=0
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::xray::PipelineConsumer
Definition: FDRRecordConsumer.h:41
llvm::xray::LogBuilderConsumer::consume
Error consume(std::unique_ptr< Record > R) override
Definition: LogBuilderConsumer.cpp:13
FDRRecords.h
llvm::xray::PipelineConsumer::PipelineConsumer
PipelineConsumer(std::initializer_list< RecordVisitor * > V)
Definition: FDRRecordConsumer.h:45