VSM C++ SDK
Vehicle Specific Modules SDK
ugcs::vsm::File_processor::Stream::Native_handle Class Referenceabstract

Interface for platform native file handle. More...

#include <file_processor.h>

Inheritance diagram for ugcs::vsm::File_processor::Stream::Native_handle:
ugcs::vsm::internal::Posix_file_handle ugcs::vsm::internal::Windows_file_handle

Classes

class  Stream_ref_holder
 Helper class to hold reference to a stream and optionally release a lock before releasing the reference to a stream. More...
 

Public Types

typedef std::unique_ptr< Native_handleUnique_ptr
 Unique pointer type. More...
 

Public Member Functions

void Set_stream (Stream::Ptr stream)
 Set associated stream. More...
 
virtual void Write ()=0
 Platform-specific handling for write operation. More...
 
virtual void Read ()=0
 Platform-specific handling for read operation. More...
 
virtual Lock_result Try_lock ()=0
 Platform-specific handling for lock operation. More...
 
virtual bool Lock ()=0
 Platform-specific handling for lock operation. More...
 
virtual bool Unlock ()=0
 Platform-specific handling for unlock operation. More...
 
virtual bool Cancel_write ()=0
 Cancel current write operation. More...
 
virtual bool Cancel_read ()=0
 Cancel current read operation. More...
 
virtual void Close ()=0
 Close the handle. More...
 
void Handle_write_abort ()
 Process write operation abortion. More...
 
void Handle_read_abort ()
 Process write operation abortion. More...
 

Public Attributes

Read_request::Ptr cur_read_request
 Current read request. More...
 
Write_request::Ptr cur_write_request
 Current write request. More...
 
Io_request::Ptr cur_lock_request
 Current lock request. More...
 
Io_request::Ptr cur_unlock_request
 Current unlock request. More...
 
bool is_closed = false
 Is the handle already closed. More...
 
Stream::Ptr stream
 Related stream. More...
 
Stream::Ptr write_active
 Holds reference to a stream while write operation is in progress. More...
 
Stream::Ptr read_active
 Holds reference to a stream while read operation is in progress. More...
 

Protected Member Functions

Stream_ref_holder Set_write_activity (bool is_active, std::unique_lock< std::mutex > &&lock=std::unique_lock< std::mutex >())
 Called by derived class to indicate whether platform call is currently active or not. More...
 
Stream_ref_holder Set_read_activity (bool is_active, std::unique_lock< std::mutex > &&lock=std::unique_lock< std::mutex >())
 Called by derived class to indicate whether platform call is currently active or not. More...
 
Native_controllerGet_native_controller () const
 Get native controlled of the related stream. More...
 

Detailed Description

Interface for platform native file handle.

Platform-dependent class should be derived from this one.

Member Typedef Documentation

Unique pointer type.

Member Function Documentation

virtual bool ugcs::vsm::File_processor::Stream::Native_handle::Cancel_read ( )
pure virtual

Cancel current read operation.

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

Implemented in ugcs::vsm::internal::Posix_file_handle, and ugcs::vsm::internal::Windows_file_handle.

virtual bool ugcs::vsm::File_processor::Stream::Native_handle::Cancel_write ( )
pure virtual

Cancel current write operation.

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

Implemented in ugcs::vsm::internal::Posix_file_handle, and ugcs::vsm::internal::Windows_file_handle.

virtual void ugcs::vsm::File_processor::Stream::Native_handle::Close ( )
pure virtual

Close the handle.

Cancel all pending operations.

Implemented in ugcs::vsm::internal::Posix_file_handle, and ugcs::vsm::internal::Windows_file_handle.

Native_controller& ugcs::vsm::File_processor::Stream::Native_handle::Get_native_controller ( ) const
inlineprotected

Get native controlled of the related stream.

void ugcs::vsm::File_processor::Stream::Native_handle::Handle_read_abort ( )

Process write operation abortion.

void ugcs::vsm::File_processor::Stream::Native_handle::Handle_write_abort ( )

Process write operation abortion.

virtual bool ugcs::vsm::File_processor::Stream::Native_handle::Lock ( )
pure virtual

Platform-specific handling for lock operation.

Can block if file is locked by another process.

Implemented in ugcs::vsm::internal::Posix_file_handle, and ugcs::vsm::internal::Windows_file_handle.

virtual void ugcs::vsm::File_processor::Stream::Native_handle::Read ( )
pure virtual

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.

Implemented in ugcs::vsm::internal::Posix_file_handle, and ugcs::vsm::internal::Windows_file_handle.

Stream_ref_holder ugcs::vsm::File_processor::Stream::Native_handle::Set_read_activity ( bool  is_active,
std::unique_lock< std::mutex > &&  lock = std::unique_lock< std::mutex >() 
)
protected

Called by derived class to indicate whether platform call is currently active or not.

Parameters
is_activeActivity flag. Only toggling is allowed.
lockLock to pass to returned object.
Returns
Reference holder for the stream.
void ugcs::vsm::File_processor::Stream::Native_handle::Set_stream ( Stream::Ptr  stream)

Set associated stream.

Stream_ref_holder ugcs::vsm::File_processor::Stream::Native_handle::Set_write_activity ( bool  is_active,
std::unique_lock< std::mutex > &&  lock = std::unique_lock< std::mutex >() 
)
protected

Called by derived class to indicate whether platform call is currently active or not.

Parameters
is_activeActivity flag. Only toggling is allowed.
lockLock to pass to returned object.
Returns
Reference holder for the stream.
virtual Lock_result ugcs::vsm::File_processor::Stream::Native_handle::Try_lock ( )
pure virtual

Platform-specific handling for lock operation.

Should not block.

Implemented in ugcs::vsm::internal::Posix_file_handle, and ugcs::vsm::internal::Windows_file_handle.

virtual bool ugcs::vsm::File_processor::Stream::Native_handle::Unlock ( )
pure virtual

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.

Implemented in ugcs::vsm::internal::Posix_file_handle, and ugcs::vsm::internal::Windows_file_handle.

virtual void ugcs::vsm::File_processor::Stream::Native_handle::Write ( )
pure virtual

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.

Implemented in ugcs::vsm::internal::Posix_file_handle, and ugcs::vsm::internal::Windows_file_handle.

Member Data Documentation

Io_request::Ptr ugcs::vsm::File_processor::Stream::Native_handle::cur_lock_request

Current lock request.

Read_request::Ptr ugcs::vsm::File_processor::Stream::Native_handle::cur_read_request

Current read request.

Io_request::Ptr ugcs::vsm::File_processor::Stream::Native_handle::cur_unlock_request

Current unlock request.

Write_request::Ptr ugcs::vsm::File_processor::Stream::Native_handle::cur_write_request

Current write request.

bool ugcs::vsm::File_processor::Stream::Native_handle::is_closed = false

Is the handle already closed.

Stream::Ptr ugcs::vsm::File_processor::Stream::Native_handle::read_active

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

Stream::Ptr ugcs::vsm::File_processor::Stream::Native_handle::stream

Related stream.

Stream::Ptr ugcs::vsm::File_processor::Stream::Native_handle::write_active

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


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