X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fslice.h;h=2965f9899a8252c8415b5c776e31dee8b6c490fd;hp=f6115851c4c4c0637dcc262191c15e51cdcec81c;hb=HEAD;hpb=eedad559456b8e62ed3b9bd9e8253e5f8bcc02d6 diff --git a/source/io/slice.h b/source/io/slice.h index f611585..272fa2c 100644 --- a/source/io/slice.h +++ b/source/io/slice.h @@ -1,6 +1,7 @@ #ifndef MSP_IO_SLICE_H_ #define MSP_IO_SLICE_H_ +#include #include "seekable.h" namespace Msp { @@ -16,32 +17,37 @@ its range. If the offset of the underlying object is changed, the Slice will restore it before the next access. This enables multiple Slices to be created on top of the same object. */ -class Slice: public Seekable +class MSPCORE_API Slice: public Seekable, public sigc::trackable { private: Seekable &below; - SeekOffset start_offset; - SeekOffset length; - SeekOffset position; - bool sync_position; + SeekOffset start_offset = 0; + SeekOffset length = 0; + SeekOffset position = 0; + bool sync_position = true; public: Slice(Seekable &, SeekOffset, SeekOffset); + void set_block(bool) override; + void set_inherit(bool) override; + private: void flush(); unsigned prepare_op(unsigned, Mode); protected: - virtual unsigned do_write(const char *, unsigned); - virtual unsigned do_read(char *, unsigned); + std::size_t do_write(const char *, std::size_t) override; + std::size_t do_read(char *, std::size_t) override; public: - virtual unsigned put(char); - virtual int get(); + std::size_t put(char) override; + int get() override; + + const Handle &get_handle(Mode) override; - virtual SeekOffset seek(SeekOffset, SeekType); - virtual SeekOffset tell() const { return position; } + SeekOffset seek(SeekOffset, SeekType) override; + SeekOffset tell() const override { return position; } }; } // namespace IO