class ugcs::vsm::internal::Windows_file_handle

Overview

Windows-specific implementation of system native file handle. More…

#include <windows_file_handle.h>

class Windows_file_handle: public ugcs::vsm::File_processor::Stream::Native_handle
{
public:
    // construction

    Windows_file_handle(HANDLE handle, HANDLE write_handle = INVALID_HANDLE_VALUE);
    Windows_file_handle(const std::string& path, File_processor::Stream::Mode mode);

    // methods

    virtual void Write();
    virtual void Read();
    virtual File_processor::Stream::Lock_result Try_lock();
    virtual bool Lock();
    virtual bool Unlock();
    virtual bool Cancel_write();
    virtual bool Cancel_read();
    void Cancel_io(bool write);
    void Write_complete_cbk(size_t transfer_size, DWORD error);
    void Read_complete_cbk(size_t transfer_size, DWORD error);
    void Lock_complete_cbk(DWORD error);
    void Io_complete_cbk(OVERLAPPED* io_cb, size_t transfer_size, DWORD error);
    virtual void Close();
    static Io_result Map_error(DWORD error);
};

Inherited Members

public:
    // typedefs

    typedef std::unique_ptr<Native_handle> Unique_ptr;

    // classes

    class Stream_ref_holder;

    // fields

    Read_request::Ptr cur_read_request;
    Write_request::Ptr cur_write_request;
    Io_request::Ptr cur_lock_request;
    Io_request::Ptr cur_unlock_request;
    bool is_closed = false;
    Stream::Ptr stream;
    Stream::Ptr write_active;
    Stream::Ptr read_active;

    // methods

    void Set_stream(Stream::Ptr stream);
    virtual void Write() = 0;
    virtual void Read() = 0;
    virtual Lock_result Try_lock() = 0;
    virtual bool Lock() = 0;
    virtual bool Unlock() = 0;
    virtual bool Cancel_write() = 0;
    virtual bool Cancel_read() = 0;
    virtual void Close() = 0;
    void Handle_write_abort();
    void Handle_read_abort();

Detailed Documentation

Windows-specific implementation of system native file handle.

Construction

Windows_file_handle(HANDLE handle, HANDLE write_handle = INVALID_HANDLE_VALUE)

Construct an instance based on already opened handles.

Windows_file_handle(const std::string& path, File_processor::Stream::Mode mode)

Construct an instance by opening a file specified by path.

Methods

virtual void Write()

Schedule write operation based on current write request.

virtual void Read()

Schedule read operation based on current read request.

virtual File_processor::Stream::Lock_result Try_lock()

Schedule lock operation based on current lock request.

virtual bool Lock()

Schedule lock operation based on current lock request.

virtual bool Unlock()

Schedule unlock operation based on current lock request.

virtual bool Cancel_write()

Cancel current write operation.

virtual bool Cancel_read()

Cancel current read operation.

void Cancel_io(bool write)

Cancel all pending I/O operations.

void Write_complete_cbk(size_t transfer_size, DWORD error)

Completion handler for platform write call.

Parameters:

transfer_size

Number of bytes transferred during I/O call.

error

Error code if the operation has failed.

void Read_complete_cbk(size_t transfer_size, DWORD error)

Completion handler for platform read call.

Parameters:

transfer_size

Number of bytes transferred during I/O call.

error

Error code if the operation has failed.

void Lock_complete_cbk(DWORD error)

Completion handler for platform lock call.

Parameters:

error

Error code if the operation has failed.

void Io_complete_cbk(OVERLAPPED* io_cb, size_t transfer_size, DWORD error)

Completion handler for platform I/O call.

Parameters:

io_cb

Pointer to I/O operation control block.

transfer_size

Number of bytes transferred during I/O call.

error

Error code if the operation has failed.

virtual void Close()

Close the handle.

static Io_result Map_error(DWORD error)

Map error value to Io_result.