> On Dec. 22, 2015, 4:52 a.m., Benjamin Hindman wrote:
> > 3rdparty/libprocess/3rdparty/stout/include/stout/jsonify.hpp, line 116
> > <https://reviews.apache.org/r/41593/diff/2/?file=1173648#file1173648line116>
> >
> >     Why not s/: Writer/: public Writer/ here and elsewhere?
> 
> Michael Park wrote:
>     It's because I don't want `BooleanWriter` to be a `Writer`, but rather 
> simply inherit the common data `std::ostream*` and the deleted 
> constructors/assignment operators. We could do one of the following here:
>     
>     (1) Aggregate the `std::ostream*` and delete the constructors/assignment 
> operators in each of the writers rather than factoring it out.
>     
>     ```cpp
>     class BooleanWriter
>     {
>     public:
>       BooleanWriter(std::ostream* stream) : stream_(stream), value_(false) {}
>       
>       BooleanWriter(const BooleanWriter&) = delete;
>       BooleanWriter(BooleanWriter&&) = delete;
>       
>       BooleanWriter& operator=(const BooleanWriter&) = delete;
>       BooleanWriter& operator=(BooleanWriter&&) = delete;
>       
>       ~BooleanWriter() { *stream_ << (value_ ? "true" : "false"); }
>       void set(bool value) { value_ = value; }
>     
>     private:
>       std::ostream* stream_;
>       bool value_;
>     };
>     ```
>     
>     (2) Aggregate `Writer` instead of private inheritance. In this case the 
> only thing that changes is `s/*stream_/*writer.stream_/`.
>     
>     ```cpp
>     class BooleanWriter
>     {
>     public:
>       BooleanWriter(std::ostream* stream) : writer_(stream), value_(false) {}
>       
>       ~BooleanWriter() { *writer.stream_ << (value_ ? "true" : "false"); }
>       void set(bool value) { value_ = value; }
>     
>     private:
>       Writer writer_;
>       bool value_;
>     };
>     ```
>     
>     (3) Keep the current "implemented-in-terms-of" semantics of private 
> inheritance.
>     
>     ```cpp
>     class BooleanWriter : Writer
>     {
>     public:
>       BooleanWriter(std::ostream* stream) : Writer(stream), value_(false) {}
>       
>       ~BooleanWriter() { *stream_ << (value_ ? "true" : "false"); }
>       void set(bool value) { value_ = value; }
>     
>     private:
>       bool value_;
>     };
>     ```
>     
>     Which one do you think is cleanest and/or simplest?

Decided to remove the `Writer` class and repeat the declarations in each of the 
writers.


- Michael


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/41593/#review111575
-----------------------------------------------------------


On Jan. 4, 2016, 7:23 p.m., Michael Park wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/41593/
> -----------------------------------------------------------
> 
> (Updated Jan. 4, 2016, 7:23 p.m.)
> 
> 
> Review request for mesos and Benjamin Hindman.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> See summary.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/stout/README.md 
> a2a3dc6120b10c8fe82088b9f0ebecfa5642f945 
>   3rdparty/libprocess/3rdparty/stout/include/Makefile.am 
> b2dea9b93adfa3ea0415a0b5c81a369dd29b6cfe 
>   3rdparty/libprocess/3rdparty/stout/include/stout/jsonify.hpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/41593/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Michael Park
> 
>

Reply via email to