Commit 430c1fad authored by Dominik Charousset's avatar Dominik Charousset

documentation

parent 303e1841
...@@ -39,15 +39,36 @@ ...@@ -39,15 +39,36 @@
namespace cppa { namespace util { namespace cppa { namespace util {
/**
* @brief A pair of input and output stream pointers.
*/
typedef std::pair<input_stream_ptr, output_stream_ptr> io_stream_ptr_pair; typedef std::pair<input_stream_ptr, output_stream_ptr> io_stream_ptr_pair;
/**
* @brief Accepts connections from client processes.
*/
class acceptor { class acceptor {
public: public:
virtual ~acceptor() { } virtual ~acceptor() { }
/**
* @brief Returns the internal file descriptor. This descriptor is needed
* for socket multiplexing using select().
*/
virtual native_socket_type acceptor_file_handle() const = 0; virtual native_socket_type acceptor_file_handle() const = 0;
/**
* @brief Accepts a new connection and returns an input/output stream pair.
* @note This member function blocks until a new connection was established.
*/
virtual io_stream_ptr_pair accept_connection() = 0; virtual io_stream_ptr_pair accept_connection() = 0;
/**
* @brief Tries to accept a new connection but immediately returns if
* there is no pending connection.
*/
virtual option<io_stream_ptr_pair> try_accept_connection() = 0; virtual option<io_stream_ptr_pair> try_accept_connection() = 0;
}; };
......
...@@ -37,21 +37,38 @@ ...@@ -37,21 +37,38 @@
namespace cppa { namespace util { namespace cppa { namespace util {
/**
* @brief An abstract input stream interface.
*/
class input_stream : public virtual ref_counted { class input_stream : public virtual ref_counted {
public: public:
/**
* @brief Returns the internal file descriptor. This descriptor is needed
* for socket multiplexing using select().
*/
virtual native_socket_type read_file_handle() const = 0; virtual native_socket_type read_file_handle() const = 0;
/** /**
* @brief Reads exactly @p num_bytes from the data source and blocks the
* caller if needed.
* @throws std::ios_base::failure * @throws std::ios_base::failure
*/ */
virtual void read(void* buf, size_t num_bytes) = 0; virtual void read(void* buf, size_t num_bytes) = 0;
/**
* @brief Tries to read up to @p num_bytes from the data source.
* @returns The number of read bytes.
* @throws std::ios_base::failure
*/
virtual size_t read_some(void* buf, size_t num_bytes) = 0; virtual size_t read_some(void* buf, size_t num_bytes) = 0;
}; };
/**
* @brief An input stream pointer.
*/
typedef intrusive_ptr<input_stream> input_stream_ptr; typedef intrusive_ptr<input_stream> input_stream_ptr;
} } // namespace cppa::util } } // namespace cppa::util
......
...@@ -36,8 +36,14 @@ ...@@ -36,8 +36,14 @@
namespace cppa { namespace util { namespace cppa { namespace util {
/**
* @brief A stream capable of both reading and writing.
*/
class io_stream : public input_stream, public output_stream { }; class io_stream : public input_stream, public output_stream { };
/**
* @brief An IO stream pointer.
*/
typedef intrusive_ptr<io_stream> io_stream_ptr; typedef intrusive_ptr<io_stream> io_stream_ptr;
} } // namespace cppa::util } } // namespace cppa::util
......
...@@ -37,16 +37,39 @@ ...@@ -37,16 +37,39 @@
namespace cppa { namespace util { namespace cppa { namespace util {
/**
* @brief An abstract output stream interface.
*/
class output_stream : public virtual ref_counted { class output_stream : public virtual ref_counted {
public: public:
/**
* @brief Returns the internal file descriptor. This descriptor is needed
* for socket multiplexing using select().
*/
virtual native_socket_type write_file_handle() const = 0; virtual native_socket_type write_file_handle() const = 0;
/**
* @brief Writes @p num_bytes bytes from @p buf to the data sink.
* @note This member function blocks until @p num_bytes were successfully
* written.
* @throws std::ios_base::failure
*/
virtual void write(const void* buf, size_t num_bytes) = 0; virtual void write(const void* buf, size_t num_bytes) = 0;
/**
* @brief Tries to write up to @p num_bytes bytes from @p buf.
* @returns The number of written bytes.
* @throws std::ios_base::failure
*/
virtual size_t write_some(const void* buf, size_t num_bytes) = 0; virtual size_t write_some(const void* buf, size_t num_bytes) = 0;
}; };
/**
* @brief An output stream pointer.
*/
typedef intrusive_ptr<output_stream> output_stream_ptr; typedef intrusive_ptr<output_stream> output_stream_ptr;
} } // namespace cppa::util } } // namespace cppa::util
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment