00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef LIBMUTH_IOSTREAM_DECLS_H
00020 #define LIBMUTH_IOSTREAM_DECLS_H
00021
00022 #include <iostream>
00023 #include "basescheduler_decls.h"
00024
00030 template<class C=char, class T=std::char_traits<C> >
00031 class BasicScheduledStreambuf
00032 : public std::basic_streambuf<C, T> {
00033 private:
00034 typedef C char_type;
00035 typedef T traits_type;
00036 typedef typename traits_type::int_type int_type;
00037 int fd;
00038 BaseScheduler &sched;
00039 std::ios_base::openmode mode;
00040 std::streamsize ibufsize;
00041 char_type *ibuf;
00042 char_type *obuf;
00043 protected:
00044
00049 int_type underflow();
00055 int_type pbackfail(int_type ch);
00056
00061 int sync();
00067 int_type overflow(int_type ch=traits_type::eof());
00068 #if 0
00069 std::streamsize xsputn(const char_type *str, std::streamsize n);
00070 #endif
00071 public:
00080 BasicScheduledStreambuf(int f, BaseScheduler &s,
00081 std::ios_base::openmode m = std::ios_base::in |
00082 std::ios_base::out, std::streamsize insize=4096,
00083 std::streamsize outsize=4096);
00084
00085 ~BasicScheduledStreambuf();
00090 operator int() const;
00091 };
00092
00098 template<class C=char, class T=std::char_traits<C> > class BasicScheduledIStream
00099 : public std::basic_istream<C, T> {
00100 private:
00101 BasicScheduledStreambuf<C, T> streambuf;
00102 public:
00109 BasicScheduledIStream(int f, BaseScheduler &s,
00110 std::streamsize size=4096);
00115 operator int() const;
00116 };
00117
00123 template<class C=char, class T=std::char_traits<C> > class BasicScheduledOStream
00124 : public std::basic_ostream<C, T> {
00125 private:
00126 BasicScheduledStreambuf<C, T> streambuf;
00127 public:
00134 BasicScheduledOStream(int f, BaseScheduler &s,
00135 std::streamsize size=4096);
00140 operator int() const;
00141 };
00142
00148 template<class C=char, class T=std::char_traits<C> >
00149 class BasicScheduledIOStream
00150 : public std::basic_iostream<C, T> {
00151 private:
00152 BasicScheduledStreambuf<C, T> streambuf;
00153 public:
00161 BasicScheduledIOStream(int f, BaseScheduler &s,
00162 std::streamsize insize=4096,
00163 std::streamsize outsize=4096);
00168 operator int() const;
00169 };
00170
00171 typedef BasicScheduledStreambuf<> ScheduledStreambuf;
00172 typedef BasicScheduledIStream<> ScheduledIStream;
00173 typedef BasicScheduledOStream<> ScheduledOStream;
00174 typedef BasicScheduledIOStream<> ScheduledIOStream;
00175
00176 #endif