1 // File Description 2 /// \file IRecordWriter.h 3 /// \brief Defines the IRecordWriter interface. 4 // 5 // Author: Derek Barnett 6 7 #ifndef IRECORDWRITER_H 8 #define IRECORDWRITER_H 9 10 namespace PacBio { 11 namespace BAM { 12 13 class BamRecord; 14 class BamRecordImpl; 15 16 class IRecordWriter 17 { 18 public: 19 virtual ~IRecordWriter() = default; 20 21 public: 22 /// \brief Try to flush any buffered data to file. 23 /// 24 /// \note The underlying implementation may not necessarily flush buffered 25 /// data immediately, especially in a multithreaded writer situation. 26 /// Let the writer go out of scope to fully ensure flushing. 27 /// 28 /// \throws std::runtime_error if flush fails 29 /// 30 virtual void TryFlush() = 0; 31 32 /// \brief Write a record to the output %BAM file. 33 /// 34 /// \param[in] record BamRecord object 35 /// 36 /// \throws std::runtime_error on failure to write 37 /// 38 virtual void Write(const BamRecord& record) = 0; 39 40 /// \brief Write a record to the output %BAM file. 41 /// 42 /// \param[in] recordImpl BamRecordImpl object 43 /// 44 /// \throws std::runtime_error on failure to write 45 /// 46 virtual void Write(const BamRecordImpl& recordImpl) = 0; 47 48 protected: 49 IRecordWriter() = default; 50 }; 51 52 } // namespace BAM 53 } // namespace PacBio 54 55 #endif // IRECORDWRITER_H 56