libzypp  17.35.8
asyncdatasource.h
Go to the documentation of this file.
1 #ifndef ASYNCDATASOURCE_H
2 #define ASYNCDATASOURCE_H
3 
4 #include <zypp-core/zyppng/base/Base>
5 #include <zypp-core/zyppng/io/IODevice>
6 
7 namespace zyppng {
8 
9  class AsyncDataSourcePrivate;
10 
11  class AsyncDataSource : public IODevice
12  {
14  public:
15 
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 
42 
43  virtual void closeWriteChannel ();
44 
51  bool waitForReadyRead(uint channel, int timeout) override;
52 
59  void flush ();
60 
67 
74 
78  bool readFdOpen () const;
79 
83  bool readFdOpen ( uint channel ) const;
84 
88  int64_t bytesPending() const override;
89 
90  protected:
91  AsyncDataSource ( );
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
std::weak_ptr< Base > WeakPtr
Definition: base.h:66
SignalProxy< void(AsyncDataSource::ChannelCloseReason)> sigWriteFdClosed()
virtual bool open(const OpenMode mode)
Definition: iodevice.cc:16
SignalProxy< void(uint, AsyncDataSource::ChannelCloseReason)> sigReadFdClosed()
int64_t rawBytesAvailable(uint channel) const override
int64_t writeData(const char *data, int64_t count) override
void readChannelChanged(uint channel) override
virtual void closeWriteChannel()
int64_t readData(uint channel, char *buffer, int64_t bufsize) override
int64_t bytesPending() const override
bool openFds(const std::vector< int > &readFds, int writeFd=-1)
ZYPP_DECLARE_PRIVATE(AsyncDataSource)
bool waitForReadyRead(int timeout)
Definition: iodevice.cc:359
std::shared_ptr< Base > Ptr
Definition: base.h:65
bool waitForReadyRead(uint channel, int timeout) override