diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-01-11 16:31:56 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-01-29 20:58:25 +0100 |
| commit | 50314d71c36895cab87c44be772589fafea894f8 (patch) | |
| tree | d7ee9c95e85e08b45e0a5992e0acae418808f75b /src/lib/disk_writer_messages.h | |
| parent | 7aab34abcab28ca38a5354dec075b56d430e82db (diff) | |
Add DiskWriterBackEndResponse.
Diffstat (limited to 'src/lib/disk_writer_messages.h')
| -rw-r--r-- | src/lib/disk_writer_messages.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/lib/disk_writer_messages.h b/src/lib/disk_writer_messages.h index ab86f083e..ff6a0b394 100644 --- a/src/lib/disk_writer_messages.h +++ b/src/lib/disk_writer_messages.h @@ -18,6 +18,14 @@ */ + +#include <boost/optional.hpp> +#include <string> + + +class Nanomsg; + + /* We have the front-end application dcpomatic2_disk and the back-end * dcpomatic2_disk_writer. The communication is line-based, separated * by \n. @@ -81,3 +89,78 @@ // or // DISK_WRITER_ERROR + +class DiskWriterBackEndResponse +{ +public: + enum class Type { + OK, + ERROR, + PONG, + FORMAT_PROGRESS, + COPY_PROGRESS, + VERIFY_PROGRESS + }; + + static DiskWriterBackEndResponse ok() { + return DiskWriterBackEndResponse(Type::OK); + } + + static DiskWriterBackEndResponse error(std::string message, int number) { + auto r = DiskWriterBackEndResponse(Type::ERROR); + r._error_message = message; + r._error_number = number; + return r; + } + + static DiskWriterBackEndResponse pong() { + return DiskWriterBackEndResponse(Type::PONG); + } + + static DiskWriterBackEndResponse format_progress(float p) { + auto r = DiskWriterBackEndResponse(Type::FORMAT_PROGRESS); + r._progress = p; + return r; + } + + static DiskWriterBackEndResponse copy_progress(float p) { + auto r = DiskWriterBackEndResponse(Type::COPY_PROGRESS); + r._progress = p; + return r; + } + + static DiskWriterBackEndResponse verify_progress(float p) { + auto r = DiskWriterBackEndResponse(Type::VERIFY_PROGRESS); + r._progress = p; + return r; + } + + static boost::optional<DiskWriterBackEndResponse> read_from_nanomsg(Nanomsg& nanomsg, int timeout); + + Type type() const { + return _type; + } + + std::string error_message() const { + return _error_message; + } + + int error_number() const { + return _error_number; + } + + float progress() const { + return _progress; + } + +private: + DiskWriterBackEndResponse(Type type) + : _type(type) + {} + + Type _type; + std::string _error_message; + int _error_number = 0; + float _progress = 0; +}; + |
