NCBI C++ ToolKit
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
SH2S_ReaderWriter Struct Reference

Search Toolkit Book for SH2S_ReaderWriter

#include "ncbi_http2_session_impl.hpp"
(Private to src/connect.)

+ Inheritance diagram for SH2S_ReaderWriter:
+ Collaboration diagram for SH2S_ReaderWriter:

Public Types

using TUpdateResponse = function< void(CHttpHeaders::THeaders)>
 

Public Member Functions

 SH2S_ReaderWriter (TUpdateResponse update_response, shared_ptr< TH2S_ResponseQueue > response_queue, TH2S_RequestEvent request)
 
ERW_Result Read (void *buf, size_t count, size_t *bytes_read=0) override
 Read as many as "count" bytes into a buffer pointed to by the "buf" argument. More...
 
ERW_Result PendingCount (size_t *count) override
 Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that are ready to be read from the input device without blocking. More...
 
ERW_Result Write (const void *buf, size_t count, size_t *bytes_written=0) override
 Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device. More...
 
ERW_Result Flush () override
 Flush pending data (if any) down to the output device. More...
 
- Public Member Functions inherited from IReaderWriter
virtual ~IReaderWriter ()
 
- Public Member Functions inherited from IReader
virtual ERW_Result Pushback (const void *buf, size_t count, void *del_ptr=0)
 This method gets called by RStream buffer destructor to return buffered yet still unread (from the stream) portion of data back to the device. More...
 
virtual ~IReader ()
 
- Public Member Functions inherited from IWriter
virtual ~IWriter ()
 

Private Types

enum  EState {
  eWriting , eWaiting , eReading , eEof ,
  eError
}
 

Private Member Functions

ERW_Result ReadFsm (function< ERW_Result()> impl)
 
ERW_Result ReadImpl (void *buf, size_t count, size_t *bytes_read)
 
ERW_Result PendingCountImpl (size_t *count)
 
ERW_Result Receive (ERW_Result(SH2S_ReaderWriter::*member)(TH2S_ResponseEvent &))
 
ERW_Result ReceiveData (TH2S_ResponseEvent &incoming)
 
ERW_Result ReceiveResponse (TH2S_ResponseEvent &incoming)
 
void Push (TH2S_RequestEvent event)
 
void Process ()
 

Private Attributes

shared_ptr< SH2S_Iom_Io
 
TUpdateResponse m_UpdateResponse
 
shared_ptr< TH2S_ResponseQueuem_ResponseQueue
 
TH2S_Data m_OutgoingData
 
TH2S_Data m_IncomingData
 
EState m_State = eWriting
 

Detailed Description

Definition at line 269 of file ncbi_http2_session_impl.hpp.

Member Typedef Documentation

◆ TUpdateResponse

Definition at line 271 of file ncbi_http2_session_impl.hpp.

Member Enumeration Documentation

◆ EState

Enumerator
eWriting 
eWaiting 
eReading 
eEof 
eError 

Definition at line 289 of file ncbi_http2_session_impl.hpp.

Constructor & Destructor Documentation

◆ SH2S_ReaderWriter()

SH2S_ReaderWriter::SH2S_ReaderWriter ( TUpdateResponse  update_response,
shared_ptr< TH2S_ResponseQueue response_queue,
TH2S_RequestEvent  request 
)

Definition at line 87 of file ncbi_http2_session.cpp.

References _ASSERT, m_UpdateResponse, Process(), and Push().

Member Function Documentation

◆ Flush()

ERW_Result SH2S_ReaderWriter::Flush ( )
overridevirtual

Flush pending data (if any) down to the output device.

Implements IWriter.

Definition at line 115 of file ncbi_http2_session.cpp.

References eRW_Error, eRW_Success, eWriting, m_OutgoingData, m_ResponseQueue, m_State, Process(), and Push().

◆ PendingCount()

ERW_Result SH2S_ReaderWriter::PendingCount ( size_t *  count)
inlineoverridevirtual

Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that are ready to be read from the input device without blocking.

Return eRW_Success if the number of pending bytes has been stored at the location pointed to by "count". Return eRW_NotImplemented if the number cannot be determined. Otherwise, return other eRW_... condition to reflect the problem ("*count" does not need to be updated in the case of non-eRW_Success). Note that if reporting 0 bytes ready, the method may return either both eRW_Success and zero "*count", or return eRW_NotImplemented alone.

Implements IReader.

Definition at line 280 of file ncbi_http2_session_impl.hpp.

References count, PendingCountImpl(), and ReadFsm().

◆ PendingCountImpl()

ERW_Result SH2S_ReaderWriter::PendingCountImpl ( size_t *  count)
private

Definition at line 181 of file ncbi_http2_session.cpp.

References count, eRW_Success, and m_IncomingData.

Referenced by PendingCount().

◆ Process()

void SH2S_ReaderWriter::Process ( void  )
inlineprivate

Definition at line 305 of file ncbi_http2_session_impl.hpp.

References m_Io.

Referenced by Flush(), Receive(), and SH2S_ReaderWriter().

◆ Push()

void SH2S_ReaderWriter::Push ( TH2S_RequestEvent  event)
inlineprivate

Definition at line 299 of file ncbi_http2_session_impl.hpp.

References H2S_RW_TRACE, m_Io, and m_ResponseQueue.

Referenced by Flush(), ReadFsm(), and SH2S_ReaderWriter().

◆ Read()

ERW_Result SH2S_ReaderWriter::Read ( void *  buf,
size_t  count,
size_t *  bytes_read = 0 
)
inlineoverridevirtual

Read as many as "count" bytes into a buffer pointed to by the "buf" argument.

Always store the number of bytes actually read (0 if read none) via the pointer "bytes_read", if provided non-NULL. Return non-eRW_Success code if EOF / error condition has been encountered during the operation (some data may have been read, nevertheless, and reflected in "*bytes_read"). Special case: if "count" is passed as 0, then the value of "buf" must be ignored, and no change should be made to the state of the input device (but may return non-eRW_Success to indicate that the input device has already been in an error condition).

Note
Apparently, may not return eRW_Success if hasn't been able to read "count" bytes as requested, and "bytes_read" was provided as NULL.
When returning "*bytes_read" as zero for a non-zero "count" requested, the return status should not indicate eRW_Success.
Warning
"*bytes_read" may never be returned greater than "count".
Attention
It is implementation-dependent whether the call blocks until the entire buffer is read or the call returns when at least some data are available. In general, it is advised that this call is made within a loop that checks for EOF condition and proceeds with the reading until the required amount of data has been retrieved.

Implements IReader.

Definition at line 275 of file ncbi_http2_session_impl.hpp.

References buf, count, ReadFsm(), and ReadImpl().

◆ ReadFsm()

ERW_Result SH2S_ReaderWriter::ReadFsm ( function< ERW_Result()>  impl)
private

◆ ReadImpl()

ERW_Result SH2S_ReaderWriter::ReadImpl ( void *  buf,
size_t  count,
size_t *  bytes_read 
)
private

Definition at line 165 of file ncbi_http2_session.cpp.

References buf, count, data, eRW_Success, m_IncomingData, and min().

Referenced by Read().

◆ Receive()

ERW_Result SH2S_ReaderWriter::Receive ( ERW_Result(SH2S_ReaderWriter::*)(TH2S_ResponseEvent &)  member)
private

Definition at line 187 of file ncbi_http2_session.cpp.

References eRW_Success, m_ResponseQueue, and Process().

Referenced by ReadFsm().

◆ ReceiveData()

ERW_Result SH2S_ReaderWriter::ReceiveData ( TH2S_ResponseEvent incoming)
private

◆ ReceiveResponse()

ERW_Result SH2S_ReaderWriter::ReceiveResponse ( TH2S_ResponseEvent incoming)
private

◆ Write()

ERW_Result SH2S_ReaderWriter::Write ( const void *  buf,
size_t  count,
size_t *  bytes_written = 0 
)
overridevirtual

Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device.

Always store the number of bytes actually written, or 0 if "count" has been passed as 0 ("buf" must be ignored in this case), via the "bytes_written" pointer, if provided non-NULL. Note that the method can return non-eRW_Success in case of an I/O error along with indicating (some) data delivered to the output device (and reflected in "*bytes_written").

Note
Apparently, may not return eRW_Success if hasn't been able to write "count" bytes as requested, and "bytes_written" was passed as NULL.
When returning "*bytes_written" as zero for a non-zero "count" requested, the return status should not indicate eRW_Success.
Warning
"*bytes_written" may never be returned greater than "count".
Attention
It is implementation-dependent whether the call blocks until the entire buffer or only some data has been written out. In general, it is advised that this call is made within a loop that checks for errors and proceeds with the writing until the required amount of data has been sent.

Implements IWriter.

Definition at line 99 of file ncbi_http2_session.cpp.

References buf, count, eRW_Error, eRW_Success, eWriting, m_OutgoingData, and m_State.

Member Data Documentation

◆ m_IncomingData

TH2S_Data SH2S_ReaderWriter::m_IncomingData
private

Definition at line 311 of file ncbi_http2_session_impl.hpp.

Referenced by PendingCountImpl(), ReadFsm(), ReadImpl(), and ReceiveData().

◆ m_Io

shared_ptr<SH2S_Io> SH2S_ReaderWriter::m_Io
private

Definition at line 307 of file ncbi_http2_session_impl.hpp.

Referenced by Process(), and Push().

◆ m_OutgoingData

TH2S_Data SH2S_ReaderWriter::m_OutgoingData
private

Definition at line 310 of file ncbi_http2_session_impl.hpp.

Referenced by Flush(), and Write().

◆ m_ResponseQueue

shared_ptr<TH2S_ResponseQueue> SH2S_ReaderWriter::m_ResponseQueue
private

Definition at line 309 of file ncbi_http2_session_impl.hpp.

Referenced by Flush(), Push(), ReadFsm(), Receive(), ReceiveData(), and ReceiveResponse().

◆ m_State

EState SH2S_ReaderWriter::m_State = eWriting
private

Definition at line 312 of file ncbi_http2_session_impl.hpp.

Referenced by Flush(), ReadFsm(), ReceiveData(), ReceiveResponse(), and Write().

◆ m_UpdateResponse

TUpdateResponse SH2S_ReaderWriter::m_UpdateResponse
private

Definition at line 308 of file ncbi_http2_session_impl.hpp.

Referenced by ReceiveResponse(), and SH2S_ReaderWriter().


The documentation for this struct was generated from the following files:
Modified on Fri Sep 20 14:57:55 2024 by modify_doxy.py rev. 669887