X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fdcpomatic_socket.h;h=49a27858892153e860ae46e3f3f557909da6a917;hp=6f7c05e225e880321ef4adfb1fdcea2baec46c78;hb=dd9be86db6cde0afa5da0d1d1ac43b42e05dca26;hpb=c6871fe8617b3de03662b7630355059393bf8043 diff --git a/src/lib/dcpomatic_socket.h b/src/lib/dcpomatic_socket.h index 6f7c05e22..49a278588 100644 --- a/src/lib/dcpomatic_socket.h +++ b/src/lib/dcpomatic_socket.h @@ -18,7 +18,10 @@ */ +#include "digester.h" #include +#include +#include /** @class Socket * @brief A class to wrap a boost::asio::ip::tcp::socket with some things @@ -45,8 +48,36 @@ public: void read (uint8_t* data, int size); uint32_t read_uint32 (); + class ReadDigestScope + { + public: + ReadDigestScope (std::shared_ptr socket); + bool check (); + private: + std::weak_ptr _socket; + }; + + /** After one of these is created everything that is sent from the socket will be + * added to a digest. When the DigestScope is destroyed the digest will be sent + * from the socket. + */ + class WriteDigestScope + { + public: + WriteDigestScope (std::shared_ptr socket); + ~WriteDigestScope (); + private: + std::weak_ptr _socket; + }; + private: + friend class DigestScope; + void check (); + void start_read_digest (); + bool check_read_digest (); + void start_write_digest (); + void finish_write_digest (); Socket (Socket const &); @@ -54,4 +85,6 @@ private: boost::asio::deadline_timer _deadline; boost::asio::ip::tcp::socket _socket; int _timeout; + boost::scoped_ptr _read_digester; + boost::scoped_ptr _write_digester; };