summaryrefslogtreecommitdiff
path: root/ucoo/intf
diff options
context:
space:
mode:
authorNicolas Schodet2015-08-25 15:39:43 +0200
committerNicolas Schodet2019-10-07 00:44:50 +0200
commit6152c3dd8879e8dd0ecb354b442d16123c1de3db (patch)
tree46c47f333ca18b6414678b032a4bdd269178df9b /ucoo/intf
parent6e72fb26efbb45f1244d95d33d459566a8af57fe (diff)
ucoo/intf: add Sink
Diffstat (limited to 'ucoo/intf')
-rw-r--r--ucoo/intf/sink.hh43
1 files changed, 43 insertions, 0 deletions
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