mFrame
載入中...
搜尋中...
無符合項目
InputStream.h
1
7#ifndef MFRAME_029349A4_F909_41C7_AC18_0DE3B02FAB01
8#define MFRAME_029349A4_F909_41C7_AC18_0DE3B02FAB01
9
10/* ***************************************************************************************
11 * Include
12 */
13
14//----------------------------------------------------------------------------------------
15// 引入必要的頭文件
16//----------------------------------------------------------------------------------------
17#include "./../io/CompletionHandler.h"
18#include "./../lang/Appendable.h"
19#include "./../util/Future.h"
20
21/* ***************************************************************************************
22 * Namespace
23 */
24namespace ufm::io {
25 struct InputStream; // 定義InputStream結構體
26} // namespace ufm::io
27
28/* ***************************************************************************************
29 * Class/Interface/Struct/Enum
30 */
31
44 virtual bool abortRead(void) abstract;
45
52 virtual bool readBusy(void) abstract;
53
67 virtual bool read(ufm::lang::Appendable& appendable,
68 void* attachment,
69 ufm::io::CompletionHandler<int>* handler) abstract;
70
79 inline bool read(ufm::lang::Appendable& appendable, ufm::util::Future<int>& future) {
80 if (future.isBusy()) return false;
81
82 future.setWait();
83 if (this->read(appendable, nullptr, &future)) return true;
84
85 future.failed(nullptr);
86 return false;
87 }
88};
89
90/* ***************************************************************************************
91 * End of file
92 */
93
94#endif /* MFRAME_029349A4_F909_41C7_AC18_0DE3B02FAB01 */
Definition Buffer.h:24
[Interface] 非同步操作完成事件處理器模板介面
Definition CompletionHandler.h:42
virtual void failed(void *attachment) override
當非同步操作失敗時呼叫
[Interface] 定義了輸入流的基本操作
Definition InputStream.h:37
virtual bool readBusy(void) override
檢查讀取操作是否忙碌。
virtual bool read(ufm::lang::Appendable &appendable, void *attachment, ufm::io::CompletionHandler< int > *handler) override
非同步讀取。從輸入串流中讀取一些字節數,並將他們存到寫入緩衝區writeBuffer。
bool read(ufm::lang::Appendable &appendable, ufm::util::Future< int > &future)
同步讀取。從輸入串流中讀取一些字節數,並將他們存到寫入緩衝區appendable。
Definition InputStream.h:79
virtual bool abortRead(void) override
中止讀取操作。
資料附加介面 (Appendable)
Definition Appendable.h:43
[Interface] 非同步操作結果介面
Definition Future.h:43
virtual bool setWait(void) override
設置為等待狀態
bool isBusy(void)
檢查操作是否處於忙碌(等待)狀態
Definition Future.h:157