class ugcs::vsm::File_processor::Stream::Native_handle

Overview

Interface for platform native file handle. More…

#include <file_processor.h>

class Native_handle
{
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();
};

// direct descendants

class Posix_file_handle;
class Windows_file_handle;

Detailed Documentation

Interface for platform native file handle.

Platform-dependent class should be derived from this one.

Typedefs

typedef std::unique_ptr<Native_handle> Unique_ptr

Unique pointer type.

Fields

Read_request::Ptr cur_read_request

Current read request.

Write_request::Ptr cur_write_request

Current write request.

Io_request::Ptr cur_lock_request

Current lock request.

Io_request::Ptr cur_unlock_request

Current unlock request.

bool is_closed = false

Is the handle already closed.

Stream::Ptr stream

Related stream.

Stream::Ptr write_active

Holds reference to a stream while write operation is in progress.

Stream::Ptr read_active

Holds reference to a stream while read operation is in progress.

Methods

void Set_stream(Stream::Ptr stream)

Set associated stream.

virtual void Write() = 0

Platform-specific handling for write operation.

Handle_write_completion() method should be invoked in associated stream upon operation completion. Request should be provided in cur_write_request member.

virtual void Read() = 0

Platform-specific handling for read operation.

Handle_read_completion() method should be invoked in associated stream upon operation completion. Request should be provided in cur_read_request member.

virtual Lock_result Try_lock() = 0

Platform-specific handling for lock operation.

Should not block.

virtual bool Lock() = 0

Platform-specific handling for lock operation.

Can block if file is locked by another process.

virtual bool Unlock() = 0

Platform-specific handling for unlock operation.

Handle_lock_completion() method should be invoked in associated stream upon operation completion. Request should be provided in cur_lock_request member.

virtual bool Cancel_write() = 0

Cancel current write operation.

Returns:

true if the operation was canceled, false if unable to cancel it now.

virtual bool Cancel_read() = 0

Cancel current read operation.

Returns:

true if the operation was canceled, false if unable to cancel it now.

virtual void Close() = 0

Close the handle.

Cancel all pending operations.

void Handle_write_abort()

Process write operation abortion.

void Handle_read_abort()

Process write operation abortion.