Joedb 10.3.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Attributes | List of all members
joedb::Abstract_File Class Reference

#include <joedb/journal/Abstract_File.h>

Inheritance diagram for joedb::Abstract_File:
Inheritance graph
[legend]

Public Member Functions

 Abstract_File (Open_Mode mode)
 
bool is_shared () const noexcept
 
bool is_readonly () const noexcept
 
Open_Mode get_mode () const noexcept
 
virtual int64_t get_size () const
 Get the size of the file, or -1 if it is unknown.
 
virtual size_t pread (char *data, size_t size, int64_t offset) const
 Read a range of bytes.
 
virtual void pwrite (const char *data, size_t size, int64_t offset)
 Write a range of bytes. Extend file size if necessary.
 
virtual void sync ()
 Write data durably (including file-size change)
 
virtual void datasync ()
 Write data durably (no file-size change)
 
virtual void shared_lock (int64_t start, int64_t size)
 Lock a range of bytes for reading (prevents writes, not reads)
 
virtual void exclusive_lock (int64_t start, int64_t size)
 Lock a range of bytes for writing (prevents both writes and reads)
 
virtual void unlock (int64_t start, int64_t size) noexcept
 Remove a lock. The range should match the range of a corresponding lock.
 
void exclusive_lock_tail ()
 
void unlock_tail () noexcept
 
void exclusive_lock_head ()
 
void shared_lock_head ()
 
void unlock_head () noexcept
 
std::string read_blob (Blob blob) const
 
virtual void copy_to (Abstract_File &destination, int64_t start, int64_t size) const
 
virtual bool equal_to (const Abstract_File &destination, int64_t from, int64_t until) const
 
void copy_to (Abstract_File &destination) const
 
virtual ~Abstract_File ()=default
 

Static Public Member Functions

static void reading_past_end_of_file ()
 

Protected Member Functions

void make_readonly ()
 
void make_writable ()
 

Static Protected Attributes

static constexpr int64_t last_position = (1ULL << 63) - 1
 

Detailed Description

Definition at line 14 of file Abstract_File.h.

Constructor & Destructor Documentation

◆ Abstract_File()

joedb::Abstract_File::Abstract_File ( Open_Mode  mode)
inline

Definition at line 25 of file Abstract_File.h.

◆ ~Abstract_File()

virtual joedb::Abstract_File::~Abstract_File ( )
virtualdefault

Member Function Documentation

◆ copy_to() [1/2]

void joedb::Abstract_File::copy_to ( Abstract_File destination) const
inline

Definition at line 99 of file Abstract_File.h.

◆ copy_to() [2/2]

void joedb::Abstract_File::copy_to ( Abstract_File destination,
int64_t  start,
int64_t  size 
) const
virtual

Definition at line 13 of file Abstract_File.cpp.

◆ datasync()

virtual void joedb::Abstract_File::datasync ( )
inlinevirtual

Definition at line 63 of file Abstract_File.h.

◆ equal_to()

bool joedb::Abstract_File::equal_to ( const Abstract_File destination,
int64_t  from,
int64_t  until 
) const
virtual

Definition at line 44 of file Abstract_File.cpp.

◆ exclusive_lock()

virtual void joedb::Abstract_File::exclusive_lock ( int64_t  start,
int64_t  size 
)
inlinevirtual

Reimplemented in joedb::Abstract_Interpreted_File, joedb::Posix_FD, and joedb::Windows_Handle.

Definition at line 69 of file Abstract_File.h.

◆ exclusive_lock_head()

void joedb::Abstract_File::exclusive_lock_head ( )
inline

Definition at line 77 of file Abstract_File.h.

◆ exclusive_lock_tail()

void joedb::Abstract_File::exclusive_lock_tail ( )
inline

Definition at line 74 of file Abstract_File.h.

◆ get_mode()

Open_Mode joedb::Abstract_File::get_mode ( ) const
inlinenoexcept

Definition at line 40 of file Abstract_File.h.

◆ get_size()

virtual int64_t joedb::Abstract_File::get_size ( ) const
inlinevirtual

◆ is_readonly()

bool joedb::Abstract_File::is_readonly ( ) const
inlinenoexcept

Definition at line 35 of file Abstract_File.h.

◆ is_shared()

bool joedb::Abstract_File::is_shared ( ) const
inlinenoexcept

Definition at line 30 of file Abstract_File.h.

◆ make_readonly()

void joedb::Abstract_File::make_readonly ( )
inlineprotected

Definition at line 20 of file Abstract_File.h.

◆ make_writable()

void joedb::Abstract_File::make_writable ( )
inlineprotected

Definition at line 21 of file Abstract_File.h.

◆ pread()

virtual size_t joedb::Abstract_File::pread ( char *  data,
size_t  size,
int64_t  offset 
) const
inlinevirtual

For very large reads, the returned value may be less than size, even if the end of the file is not reached. It is assumed that small reads (such as the 41 bytes of the joedb header) will not be truncated. 0 is returned if the end of the file is reached.

Reimplemented in joedb::Encoded_File, joedb::Memory_File, joedb::Posix_FD, joedb::Readonly_Encoded_File, joedb::Readonly_Memory_File, joedb::Server_File, joedb::Abstract_Interpreted_File, joedb::SFTP_File, joedb::Stream_File, and joedb::Windows_Handle.

Definition at line 54 of file Abstract_File.h.

◆ pwrite()

virtual void joedb::Abstract_File::pwrite ( const char *  data,
size_t  size,
int64_t  offset 
)
inlinevirtual

◆ read_blob()

std::string joedb::Abstract_File::read_blob ( Blob  blob) const

Definition at line 111 of file Abstract_File.cpp.

◆ reading_past_end_of_file()

void joedb::Abstract_File::reading_past_end_of_file ( )
static

Definition at line 104 of file Abstract_File.cpp.

◆ shared_lock()

virtual void joedb::Abstract_File::shared_lock ( int64_t  start,
int64_t  size 
)
inlinevirtual

Reimplemented in joedb::Abstract_Interpreted_File, joedb::Posix_FD, and joedb::Windows_Handle.

Definition at line 66 of file Abstract_File.h.

◆ shared_lock_head()

void joedb::Abstract_File::shared_lock_head ( )
inline

Definition at line 78 of file Abstract_File.h.

◆ sync()

virtual void joedb::Abstract_File::sync ( )
inlinevirtual

◆ unlock()

virtual void joedb::Abstract_File::unlock ( int64_t  start,
int64_t  size 
)
inlinevirtualnoexcept

Reimplemented in joedb::Abstract_Interpreted_File, joedb::Posix_FD, and joedb::Windows_Handle.

Definition at line 72 of file Abstract_File.h.

◆ unlock_head()

void joedb::Abstract_File::unlock_head ( )
inlinenoexcept

Definition at line 79 of file Abstract_File.h.

◆ unlock_tail()

void joedb::Abstract_File::unlock_tail ( )
inlinenoexcept

Definition at line 75 of file Abstract_File.h.

Member Data Documentation

◆ last_position

constexpr int64_t joedb::Abstract_File::last_position = (1ULL << 63) - 1
staticconstexprprotected

Definition at line 22 of file Abstract_File.h.


The documentation for this class was generated from the following files: