libzypp  17.34.1
zyppng::AsyncDataSource Class Reference

#include <zypp-core/zyppng/io/asyncdatasource.h>

Inheritance diagram for zyppng::AsyncDataSource:

Public Types

enum  ChannelCloseReason { RemoteClose, AccessError, InternalError, UserRequest }
 
using Ptr = std::shared_ptr< AsyncDataSource >
 
using WeakPtr = std::weak_ptr< AsyncDataSource >
 
- Public Types inherited from zyppng::IODevice
enum  OpenModeFlag { Closed = 0x0, ReadOnly = 0x1, WriteOnly = 0x2, ReadWrite = ReadOnly | WriteOnly }
 
using Ptr = std::shared_ptr< IODevice >
 
using WeakPtr = std::weak_ptr< IODevice >
 
- Public Types inherited from zyppng::Base
using Ptr = std::shared_ptr< Base >
 
using WeakPtr = std::weak_ptr< Base >
 

Public Member Functions

bool openFds (const std::vector< int > &readFds, int writeFd=-1)
 
void close () override
 
virtual void closeWriteChannel ()
 
bool waitForReadyRead (uint channel, int timeout) override
 
void flush ()
 
SignalProxy< void(AsyncDataSource::ChannelCloseReason)> sigWriteFdClosed ()
 
SignalProxy< void(uint, AsyncDataSource::ChannelCloseReason)> sigReadFdClosed ()
 
bool readFdOpen () const
 
bool readFdOpen (uint channel) const
 
bool waitForReadyRead (int timeout)
 
virtual bool waitForReadyRead (uint channel, int timeout)=0
 
- Public Member Functions inherited from zyppng::IODevice
 ZYPP_DECLARE_FLAGS (OpenMode, OpenModeFlag)
 
 IODevice ()
 
void setReadChannel (uint channel)
 
uint currentReadChannel () const
 
int readChannelCount () const
 
bool canRead () const
 
bool canWrite () const
 
bool isOpen () const
 
ByteArray readAll ()
 
ByteArray read (int64_t maxSize)
 
int64_t read (char *buf, int64_t maxSize)
 
virtual ByteArray readLine (const int64_t maxSize=0)
 
virtual int64_t bytesAvailable () const
 
bool canReadLine () const
 
ByteArray readAll (uint channel)
 
ByteArray read (uint channel, int64_t maxSize)
 
int64_t read (uint channel, char *buf, int64_t maxSize)
 
ByteArray channelReadLine (uint channel, int64_t maxSize=0)
 
virtual int64_t channelReadLine (uint channel, char *buf, const int64_t maxSize)
 
virtual int64_t bytesAvailable (uint channel) const
 
bool canReadLine (uint channel) const
 
int64_t write (const ByteArray &data)
 
int64_t write (const char *data, int64_t len)
 
bool waitForReadyRead (int timeout)
 
SignalProxy< void()> sigReadyRead ()
 
SignalProxy< void(uint)> sigChannelReadyRead ()
 
SignalProxy< void(int64_t)> sigBytesWritten ()
 
SignalProxy< void()> sigAllBytesWritten ()
 
- Public Member Functions inherited from zyppng::Base
 Base ()
 
virtual ~Base ()
 
WeakPtr parent () const
 
void addChild (const Base::Ptr &child)
 
void removeChild (const Ptr &child)
 
const std::unordered_set< Ptr > & children () const
 
std::thread::id threadId () const
 
template<typename T >
std::vector< std::weak_ptr< T > > findChildren () const
 
template<typename T >
std::shared_ptr< T > shared_this () const
 
template<typename T >
std::shared_ptr< T > shared_this ()
 
template<typename T >
std::weak_ptr< T > weak_this () const
 
template<typename T >
std::weak_ptr< T > weak_this ()
 
template<typename SenderFunc , typename ReceiverFunc >
auto connect (SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
 
template<typename SenderFunc , typename ReceiverFunc , typename ... Tracker>
std::enable_if_t< std::is_member_function_pointer_v< SenderFunc >, connectionconnectFunc (SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)
 

Static Public Member Functions

static Ptr create ()
 
- Static Public Member Functions inherited from zyppng::Base
template<typename Obj , typename Functor >
static decltype(auto) make_base_slot (Obj *o, Functor &&f)
 
template<typename SenderFunc , typename ReceiverFunc >
static auto connect (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
 
template<typename SenderFunc , typename ReceiverFunc , typename ... Tracker>
static auto connectFunc (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)
 

Protected Member Functions

 AsyncDataSource ()
 
 AsyncDataSource (AsyncDataSourcePrivate &d)
 
int64_t writeData (const char *data, int64_t count) override
 
- Protected Member Functions inherited from zyppng::IODevice
 IODevice (IODevicePrivate &d)
 
virtual bool open (const OpenMode mode)
 
void setReadChannelCount (uint channels)
 
- Protected Member Functions inherited from zyppng::Base
 Base (BasePrivate &dd)
 

Private Member Functions

 ZYPP_DECLARE_PRIVATE (AsyncDataSource)
 
int64_t readData (uint channel, char *buffer, int64_t bufsize) override
 
int64_t rawBytesAvailable (uint channel) const override
 
void readChannelChanged (uint channel) override
 
virtual bool open (const OpenMode mode)
 

Additional Inherited Members

- Protected Attributes inherited from zyppng::Base
std::unique_ptr< BasePrivated_ptr
 

Detailed Description

Definition at line 11 of file asyncdatasource.h.

Member Typedef Documentation

◆ Ptr

Definition at line 23 of file asyncdatasource.h.

◆ WeakPtr

Definition at line 24 of file asyncdatasource.h.

Member Enumeration Documentation

◆ ChannelCloseReason

Enumerator
RemoteClose 
AccessError 
InternalError 
UserRequest 

Definition at line 16 of file asyncdatasource.h.

Constructor & Destructor Documentation

◆ AsyncDataSource() [1/2]

zyppng::AsyncDataSource::AsyncDataSource ( )
protected

Definition at line 137 of file asyncdatasource.cpp.

◆ AsyncDataSource() [2/2]

zyppng::AsyncDataSource::AsyncDataSource ( AsyncDataSourcePrivate d)
protected

Definition at line 140 of file asyncdatasource.cpp.

Member Function Documentation

◆ ZYPP_DECLARE_PRIVATE()

zyppng::AsyncDataSource::ZYPP_DECLARE_PRIVATE ( AsyncDataSource  )
private

◆ create()

AsyncDataSource::Ptr zyppng::AsyncDataSource::create ( )
static

Definition at line 144 of file asyncdatasource.cpp.

◆ openFds()

bool zyppng::AsyncDataSource::openFds ( const std::vector< int > &  readFds,
int  writeFd = -1 
)

Definition at line 150 of file asyncdatasource.cpp.

◆ close()

void zyppng::AsyncDataSource::close ( )
overridevirtual

Reimplemented from zyppng::IODevice.

Reimplemented in zyppng::Process.

Definition at line 258 of file asyncdatasource.cpp.

◆ closeWriteChannel()

void zyppng::AsyncDataSource::closeWriteChannel ( )
virtual

Reimplemented in zyppng::Process.

Definition at line 279 of file asyncdatasource.cpp.

◆ waitForReadyRead() [1/3]

bool zyppng::AsyncDataSource::waitForReadyRead ( uint  channel,
int  timeout 
)
overridevirtual

Blocks the current event loop to wait until all bytes currently in the buffer have been written to the write fd.

Note
do not use until there is a very good reason, like event processing should not continue until readyRead was sent

Implements zyppng::IODevice.

Definition at line 299 of file asyncdatasource.cpp.

◆ flush()

void zyppng::AsyncDataSource::flush ( )

Blocks the current event loop to wait until all bytes currently in the buffer have been written to the write fd.

Note
do not use until there is a very good reason, like event processing should not continue until bytesWritten was sent

Definition at line 330 of file asyncdatasource.cpp.

◆ sigWriteFdClosed()

SignalProxy< void(AsyncDataSource::ChannelCloseReason)> zyppng::AsyncDataSource::sigWriteFdClosed ( )

Signal is emitted always when the write channel is closed. All data that was not written yet will be discarded and canWrite() will return false.

Definition at line 349 of file asyncdatasource.cpp.

◆ sigReadFdClosed()

SignalProxy< void(uint, AsyncDataSource::ChannelCloseReason)> zyppng::AsyncDataSource::sigReadFdClosed ( )

Signal is emitted always when the write channel is closed, for example when the write side of a pipe is closed. All data still residing in the read buffer can still be read.

Definition at line 354 of file asyncdatasource.cpp.

◆ readFdOpen() [1/2]

bool zyppng::AsyncDataSource::readFdOpen ( ) const

Returns true as long as the default read channel was not closed ( e.g. sigReadFdClosed was emitted )

Definition at line 359 of file asyncdatasource.cpp.

◆ readFdOpen() [2/2]

bool zyppng::AsyncDataSource::readFdOpen ( uint  channel) const

Returns true as long as the given read channel was not closed ( e.g. sigReadFdClosed was emitted )

Definition at line 367 of file asyncdatasource.cpp.

◆ writeData()

int64_t zyppng::AsyncDataSource::writeData ( const char *  data,
int64_t  count 
)
overrideprotectedvirtual

Implements zyppng::IODevice.

Definition at line 201 of file asyncdatasource.cpp.

◆ readData()

int64_t zyppng::AsyncDataSource::readData ( uint  channel,
char *  buffer,
int64_t  bufsize 
)
overrideprivatevirtual

Implements zyppng::IODevice.

Definition at line 212 of file asyncdatasource.cpp.

◆ rawBytesAvailable()

int64_t zyppng::AsyncDataSource::rawBytesAvailable ( uint  channel) const
overrideprivatevirtual

Implements zyppng::IODevice.

Definition at line 235 of file asyncdatasource.cpp.

◆ readChannelChanged()

void zyppng::AsyncDataSource::readChannelChanged ( uint  channel)
overrideprivatevirtual

Implements zyppng::IODevice.

Definition at line 249 of file asyncdatasource.cpp.

◆ waitForReadyRead() [2/3]

bool zyppng::IODevice::waitForReadyRead

Blocks the current event loop to wait until there are bytes available to read from the device. This always operates on the read channel that is selected as the default when the function is first called, even if the default channel would be changed during the wait.

See also
zyppng::IODevice::currentReadChannel
Note
do not use until there is a very good reason, like event processing should not continue until readyRead was sent

Definition at line 315 of file iodevice.cc.

◆ waitForReadyRead() [3/3]

virtual bool zyppng::IODevice::waitForReadyRead

Blocks the current event loop to wait until there are bytes available to read from the given read channel.

Note
do not use until there is a very good reason, like event processing should not continue until readyRead was sent

◆ open()

bool zyppng::IODevice::open
private

Definition at line 16 of file iodevice.cc.


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