From 6152c3dd8879e8dd0ecb354b442d16123c1de3db Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Tue, 25 Aug 2015 15:39:43 +0200 Subject: ucoo/intf: add Sink --- ucoo/intf/sink.hh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ucoo/intf/sink.hh (limited to 'ucoo') diff --git a/ucoo/intf/sink.hh b/ucoo/intf/sink.hh new file mode 100644 index 0000000..54cf6f2 --- /dev/null +++ b/ucoo/intf/sink.hh @@ -0,0 +1,43 @@ +#ifndef ucoo_intf_sink_hh +#define ucoo_intf_sink_hh +// ucoolib - Microcontroller object oriented library. {{{ +// +// Copyright (C) 2015 Nicolas Schodet +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// }}} + +namespace ucoo { + +/// Data sink, looks like a stream, but only sink data. +class Sink +{ + public: + /// Write up to COUNT bytes of data from BUF to sink. Return the number + /// of written bytes or -1 on error. + virtual int write (const char *buf, int count) = 0; + protected: + /// Default constructor. + Sink () { } +}; + +} // namespace ucoo + +#endif // ucoo_intf_sink_hh -- cgit v1.2.3