Line data Source code
1 : //===- FDRRecordProducer.h - XRay FDR Mode Record Producer ----------------===//
2 : //
3 : // The LLVM Compiler Infrastructure
4 : //
5 : // This file is distributed under the University of Illinois Open Source
6 : // License. See LICENSE.TXT for details.
7 : //
8 : //===----------------------------------------------------------------------===//
9 : #ifndef LLVM_INCLUDE_LLVM_XRAY_FDRRECORDPRODUCER_H_
10 : #define LLVM_INCLUDE_LLVM_XRAY_FDRRECORDPRODUCER_H_
11 :
12 : #include "llvm/Support/Error.h"
13 : #include "llvm/XRay/FDRRecords.h"
14 : #include "llvm/XRay/XRayRecord.h"
15 : #include <memory>
16 :
17 : namespace llvm {
18 : namespace xray {
19 :
20 : class RecordProducer {
21 : public:
22 : /// All producer implementations must yield either an Error or a non-nullptr
23 : /// unique_ptr<Record>.
24 : virtual Expected<std::unique_ptr<Record>> produce() = 0;
25 0 : virtual ~RecordProducer() = default;
26 : };
27 :
28 10 : class FileBasedRecordProducer : public RecordProducer {
29 : const XRayFileHeader &Header;
30 : DataExtractor &E;
31 : uint32_t &OffsetPtr;
32 :
33 : public:
34 : FileBasedRecordProducer(const XRayFileHeader &FH, DataExtractor &DE,
35 : uint32_t &OP)
36 17 : : Header(FH), E(DE), OffsetPtr(OP) {}
37 :
38 : /// This producer encapsulates the logic for loading a File-backed
39 : /// RecordProducer hidden behind a DataExtractor.
40 : Expected<std::unique_ptr<Record>> produce() override;
41 : };
42 :
43 : } // namespace xray
44 : } // namespace llvm
45 :
46 : #endif // LLVM_INCLUDE_LLVM_XRAY_FDRRECORDPRODUCER_H_
|