Merge branch 'feature/e-endstop' into merge-abc-with-homing
[clinton/Smoothieware.git] / src / libs / StreamOutput.h
CommitLineData
df27a6a3 1/*
38d375e7
AW
2 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
3 Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4 Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
df27a6a3 5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
38d375e7
AW
6*/
7
25a19381
AW
8#ifndef STREAMOUTPUT_H
9#define STREAMOUTPUT_H
10
99b9ed8a 11#include <cstdarg>
d0ef6382 12#include <cstring>
9a993543 13#include <stdio.h>
d0ef6382 14
93694d6b
AW
15// This is a base class for all StreamOutput objects.
16// StreamOutputs are basically "things you can sent strings to". They are passed along with gcodes for example so modules can answer to those gcodes.
17// They are usually associated with a command source, but can also be a NullStreamOutput if we just want to ignore whatever is sent
18
d0ef6382 19class NullStreamOutput;
99b9ed8a 20
04095259 21class StreamOutput {
25a19381 22 public:
99b9ed8a 23 StreamOutput(){}
04095259
JM
24 virtual ~StreamOutput(){}
25
fc7b9a7b 26 virtual int printf(const char *format, ...) __attribute__ ((format(printf, 2, 3)));
d0ef6382 27 virtual int _putc(int c) { return 1; }
99b9ed8a 28 virtual int _getc(void) { return 0; }
d0ef6382 29 virtual int puts(const char* str) = 0;
6d877d9b 30 virtual bool ready() { return true; };
d0ef6382
MM
31
32 static NullStreamOutput NullStream;
33};
34
35class NullStreamOutput : public StreamOutput {
36 public:
37 int puts(const char* str) { return strlen(str); }
25a19381
AW
38};
39
25a19381 40#endif