acl/lib_acl_cpp/include/acl_cpp/stream/stream_hook.hpp

61 lines
2.1 KiB
C++
Raw Normal View History

#pragma once
2017-06-02 14:47:24 +08:00
#include "../acl_cpp_define.hpp"
#include "../stdlib/noncopyable.hpp"
namespace acl {
/**
* IO setup_hook
* IO stream/aio_stream IO 使
* stream/aio_stream setup_hook stream/aio_stream
* IO
* XXX
*/
class ACL_CPP_API stream_hook : public noncopyable
{
public:
2019-07-07 11:00:12 +08:00
stream_hook(void) {}
/**
*
* @param buf {void*}
* @param len {size_t} buf
* @return {int} < 0
*/
virtual int read(void* buf, size_t len) = 0;
/**
*
* @param buf {const void*}
* @param len {size_t} buf ( > 0)
* @return {int} < 
*/
virtual int send(const void* buf, size_t len) = 0;
/**
* stream/aio_stream setup_hook stream_hook::open
* 便
* @param s {ACL_VSTREAM*} setup_hook
*
* @return {bool} false setup_hook
*/
virtual bool open(ACL_VSTREAM* s) = 0;
/**
* stream/aio_stream 便
* @param alive {bool}
* @return {bool}
*/
virtual bool on_close(bool alive) { (void) alive; return true; }
/**
* stream/aio_stream stream_hook
*/
2019-07-07 11:00:12 +08:00
virtual void destroy(void) {}
protected:
2019-07-07 11:00:12 +08:00
virtual ~stream_hook(void) {}
};
} // namespace acl