libzypp: zypp-core/ng/io/asyncdatasource.h Source File

libzypp 17.38.13

asyncdatasource.h
Go to the documentation of this file.
1#ifndef ASYNCDATASOURCE_H
2#define ASYNCDATASOURCE_H
3
4#include <zypp-core/ng/base/Base>
5#include <zypp-core/ng/io/IODevice>
6
7namespace zyppng {
8
9 class AsyncDataSourcePrivate;
10
11 class AsyncDataSource : public IODevice
12 {
13 ZYPP_DECLARE_PRIVATE(AsyncDataSource)
14 public:
15
16 enum ChannelCloseReason {
17 RemoteClose, // the other side of the fd was closed
18 AccessError, // we got an EACCESS when polling the fd
19 InternalError, // we got a unexpected errno when polling the fd
20 UserRequest // channel were closed because close() was called
21 };
22
23 using Ptr = std::shared_ptr<AsyncDataSource>;
24 using WeakPtr = std::weak_ptr<AsyncDataSource>;
25
26 static Ptr create ();
27
33 bool openFds ( const std::vector<int>& readFds, int writeFd = -1 );
34
39 void close () override;
40
41 using IODevice::waitForReadyRead;
42
43 virtual void closeWriteChannel ();
44
51 bool waitForReadyRead(uint channel, int timeout) override;
52
59 void flush ();
60
66 SignalProxy<void( AsyncDataSource::ChannelCloseReason )> sigWriteFdClosed();
67
73 SignalProxy<void( uint, AsyncDataSource::ChannelCloseReason )> sigReadFdClosed();
74
78 bool readFdOpen () const;
79
83 bool readFdOpen ( uint channel ) const;
84
88 int64_t bytesPending() const override;
89
90 protected:
91 AsyncDataSource ( );
92 AsyncDataSource( AsyncDataSourcePrivate &d );
93 int64_t writeData(const char *data, int64_t count) override;
94
95 private:
96 using IODevice::open;
97
98 int64_t readData( uint channel, char *buffer, int64_t bufsize ) override;
99 int64_t rawBytesAvailable( uint channel ) const override;
100 void readChannelChanged ( uint channel ) override;
101 };
102}
103
104
105#endif // ASYNCDATASOURCE_H
zyppng::AsyncDataSourcePrivate
Definition asyncdatasource_p.h:11
zyppng::AsyncDataSource::writeData
int64_t writeData(const char *data, int64_t count) override
Definition asyncdatasource.cpp:203
zyppng::AsyncDataSource::sigReadFdClosed
SignalProxy< void(uint, AsyncDataSource::ChannelCloseReason)> sigReadFdClosed()
Definition asyncdatasource.cpp:358
zyppng::AsyncDataSource::create
static Ptr create()
Definition asyncdatasource.cpp:146
zyppng::AsyncDataSource::bytesPending
int64_t bytesPending() const override
Definition asyncdatasource.cpp:382
zyppng::AsyncDataSource::readFdOpen
bool readFdOpen() const
Definition asyncdatasource.cpp:363
zyppng::AsyncDataSource::readChannelChanged
void readChannelChanged(uint channel) override
Definition asyncdatasource.cpp:251
zyppng::AsyncDataSource::close
void close() override
Definition asyncdatasource.cpp:260
zyppng::AsyncDataSource::waitForReadyRead
bool waitForReadyRead(uint channel, int timeout) override
Definition asyncdatasource.cpp:303
zyppng::AsyncDataSource::AsyncDataSource
AsyncDataSource()
Definition asyncdatasource.cpp:139
zyppng::AsyncDataSource::WeakPtr
std::weak_ptr< AsyncDataSource > WeakPtr
Definition asyncdatasource.h:24
zyppng::AsyncDataSource::openFds
bool openFds(const std::vector< int > &readFds, int writeFd=-1)
Definition asyncdatasource.cpp:152
zyppng::AsyncDataSource::closeWriteChannel
virtual void closeWriteChannel()
Definition asyncdatasource.cpp:283
zyppng::AsyncDataSource::flush
void flush()
Definition asyncdatasource.cpp:334
zyppng::AsyncDataSource::readData
int64_t readData(uint channel, char *buffer, int64_t bufsize) override
Definition asyncdatasource.cpp:214
zyppng::AsyncDataSource::ChannelCloseReason
ChannelCloseReason
Definition asyncdatasource.h:16
zyppng::AsyncDataSource::RemoteClose
@ RemoteClose
Definition asyncdatasource.h:17
zyppng::AsyncDataSource::AccessError
@ AccessError
Definition asyncdatasource.h:18
zyppng::AsyncDataSource::InternalError
@ InternalError
Definition asyncdatasource.h:19
zyppng::AsyncDataSource::UserRequest
@ UserRequest
Definition asyncdatasource.h:20
zyppng::AsyncDataSource::Ptr
std::shared_ptr< AsyncDataSource > Ptr
Definition asyncdatasource.h:23
zyppng::AsyncDataSource::sigWriteFdClosed
SignalProxy< void(AsyncDataSource::ChannelCloseReason)> sigWriteFdClosed()
Definition asyncdatasource.cpp:353
zyppng::AsyncDataSource::rawBytesAvailable
int64_t rawBytesAvailable(uint channel) const override
Definition asyncdatasource.cpp:237
zyppng::Base::data
void * data(uint32_t quark)
Definition base.cc:82
zyppng::IODevice::waitForReadyRead
bool waitForReadyRead(int timeout)
Definition iodevice.cc:359
zyppng::IODevice::IODevice
IODevice()
Definition iodevice.cc:10
zyppng::IODevice::open
virtual bool open(const OpenMode mode)
Definition iodevice.cc:16
zyppng::SignalProxy
Definition signals.h:325
zyppng
Definition MediaNetworkRequestExecutor.h:16
ZYPP_DECLARE_PRIVATE
#define ZYPP_DECLARE_PRIVATE(Class)
Definition zyppglobal.h:80