Merge pull request #907 from lordofhyphens/deltagrid_cartesian
[clinton/Smoothieware.git] / src / libs / Network / uip / CallbackStream.h
1 #ifndef CALLBACKSTREAM_H
2 #define CALLBACKSTREAM_H
3
4 typedef int (*cb_t)(const char *, void *);
5
6 #ifdef __cplusplus
7 #include "libs/StreamOutput.h"
8
9
10 class CallbackStream : public StreamOutput {
11 public:
12 CallbackStream(cb_t cb, void *u);
13 virtual ~CallbackStream();
14 int puts(const char*);
15 void inc() { use_count++; }
16 void dec();
17 int get_count() { return use_count; }
18 void mark_closed();
19
20 private:
21 cb_t callback;
22 void *user;
23 bool closed;
24 int use_count;
25 };
26
27 #else
28
29 extern void *new_callback_stream(cb_t cb, void *);
30 extern void delete_callback_stream(void *);
31
32 #endif // __cplusplus
33
34 #endif