/usr/include/bamtools/api/IBamIODevice.h is in libbamtools-dev 2.4.0+dfsg-3build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | // ***************************************************************************
// IBamIODevice.h (c) 2011 Derek Barnett
// Marth Lab, Department of Biology, Boston College
// ---------------------------------------------------------------------------
// Last modified: 10 November 2011 (DB)
// ---------------------------------------------------------------------------
// Base class for all BAM I/O devices (e.g. local file, pipe, HTTP, FTP, etc.)
//
// Derived classes should provide protocol-specific implementations for
// reading/writing plain bytes, as well as other I/O-related behaviors.
//
// Since IBamIODevices may be defined in client code, the internal
// BamExceptions are NOT allowed to be thrown from devices, including the
// built-in ones. This keeps a consistent interface at the BgzfStream for
// handling any device type. Use the error string for relaying error messages.
// ***************************************************************************
#ifndef IBAMIODEVICE_H
#define IBAMIODEVICE_H
#include "api/api_global.h"
#include <cstdio>
#include <string>
namespace BamTools {
class API_EXPORT IBamIODevice {
// enums
public: enum OpenMode { NotOpen = 0x0000
, ReadOnly = 0x0001
, WriteOnly = 0x0002
, ReadWrite = ReadOnly | WriteOnly
};
// ctor & dtor
public:
virtual ~IBamIODevice(void) { }
// IBamIODevice interface
public:
// TODO: add seek(pos, *from*)
// pure virtuals
virtual void Close(void) =0;
virtual bool IsRandomAccess(void) const =0;
virtual bool Open(const OpenMode mode) =0;
virtual int64_t Read(char* data, const unsigned int numBytes) =0;
virtual bool Seek(const int64_t& position, const int origin = SEEK_SET) =0;
virtual int64_t Tell(void) const =0;
virtual int64_t Write(const char* data, const unsigned int numBytes) =0;
// default implementation provided
virtual std::string GetErrorString(void);
virtual bool IsOpen(void) const;
virtual OpenMode Mode(void) const;
// internal methods
protected:
IBamIODevice(void); // hidden ctor
void SetErrorString(const std::string& where, const std::string& what);
// data members
protected:
OpenMode m_mode;
std::string m_errorString;
};
inline
IBamIODevice::IBamIODevice(void)
: m_mode(IBamIODevice::NotOpen)
{ }
inline
std::string IBamIODevice::GetErrorString(void) {
return m_errorString;
}
inline
bool IBamIODevice::IsOpen(void) const {
return ( m_mode != IBamIODevice::NotOpen );
}
inline
IBamIODevice::OpenMode IBamIODevice::Mode(void) const {
return m_mode;
}
inline
void IBamIODevice::SetErrorString(const std::string& where, const std::string& what) {
static const std::string SEPARATOR = ": ";
m_errorString = where + SEPARATOR + what;
}
} // namespace BamTools
#endif // IBAMIODEVICE_H
|