Introduce Kind enumeration in Encoder. Introduce enumeration in Encoder to distinguish between data and file encoders rather than using a function pointer.
Review: https://reviews.apache.org/r/27962 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4a79a690 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4a79a690 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4a79a690 Branch: refs/heads/master Commit: 4a79a690d02f0910beba4125f0d0c4f0c2f01f46 Parents: 541e8e5 Author: Joris Van Remoortere <[email protected]> Authored: Sat Nov 15 16:47:49 2014 -0800 Committer: Benjamin Hindman <[email protected]> Committed: Sat Nov 15 17:38:22 2014 -0800 ---------------------------------------------------------------------- 3rdparty/libprocess/src/encoder.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/4a79a690/3rdparty/libprocess/src/encoder.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/src/encoder.hpp b/3rdparty/libprocess/src/encoder.hpp index 800f324..8040d23 100644 --- a/3rdparty/libprocess/src/encoder.hpp +++ b/3rdparty/libprocess/src/encoder.hpp @@ -37,11 +37,18 @@ typedef void (*Sender)(Encoder*); class Encoder { public: + enum Kind { + DATA, + FILE + }; + explicit Encoder(const Socket& _s) : s(_s) {} virtual ~Encoder() {} virtual Sender sender() = 0; + virtual Kind kind() const = 0; + Socket socket() const { return s; @@ -65,6 +72,11 @@ public: return send_data; } + virtual Kind kind() const + { + return Encoder::DATA; + } + virtual const char* next(size_t* length) { size_t temp = index; @@ -243,6 +255,11 @@ public: return send_file; } + virtual Kind kind() const + { + return Encoder::FILE; + } + virtual int next(off_t* offset, size_t* length) { off_t temp = index;
