PageRenderTime 166ms CodeModel.GetById 65ms app.highlight 6ms RepoModel.GetById 54ms app.codeStats 0ms

/mordor/streams/std.h

http://github.com/mozy/mordor
C Header | 80 lines | 67 code | 12 blank | 1 comment | 0 complexity | 509a3d17908c8adba053c6bc388c6178 MD5 | raw file
 1#ifndef __MORDOR_STD_STREAM_H__
 2#define __MORDOR_STD_STREAM_H__
 3// Copyright (c) 2009 - Mozy, Inc.
 4
 5#include "mordor/version.h"
 6
 7#ifdef WINDOWS
 8#include "handle.h"
 9#else
10#include "fd.h"
11#endif
12
13namespace Mordor {
14
15class StdStream : public NativeStream
16{
17protected:
18    StdStream(IOManager *ioManager, Scheduler *scheduler, int stream);
19};
20
21class StdinStream : public StdStream
22{
23public:
24    StdinStream()
25        : StdStream(NULL, NULL, MORDOR_NATIVE(STD_INPUT_HANDLE, STDIN_FILENO))
26    {}
27    StdinStream(IOManager &ioManager)
28        : StdStream(&ioManager, NULL, MORDOR_NATIVE(STD_INPUT_HANDLE, STDIN_FILENO))
29    {}
30    StdinStream(Scheduler &scheduler)
31        : StdStream(NULL, &scheduler, MORDOR_NATIVE(STD_INPUT_HANDLE, STDIN_FILENO))
32    {}
33    StdinStream(IOManager &ioManager, Scheduler &scheduler)
34        : StdStream(&ioManager, &scheduler, MORDOR_NATIVE(STD_INPUT_HANDLE, STDIN_FILENO))
35    {}
36
37    bool supportsWrite() { return false; }
38};
39
40class StdoutStream : public StdStream
41{
42public:
43    StdoutStream()
44        : StdStream(NULL, NULL, MORDOR_NATIVE(STD_OUTPUT_HANDLE, STDOUT_FILENO))
45    {}
46    StdoutStream(IOManager &ioManager)
47        : StdStream(&ioManager, NULL, MORDOR_NATIVE(STD_OUTPUT_HANDLE, STDOUT_FILENO))
48    {}
49    StdoutStream(Scheduler &scheduler)
50        : StdStream(NULL, &scheduler, MORDOR_NATIVE(STD_OUTPUT_HANDLE, STDOUT_FILENO))
51    {}
52    StdoutStream(IOManager &ioManager, Scheduler &scheduler)
53        : StdStream(&ioManager, &scheduler, MORDOR_NATIVE(STD_OUTPUT_HANDLE, STDOUT_FILENO))
54    {}
55
56    bool supportsRead() { return false; }
57};
58
59class StderrStream : public StdStream
60{
61public:
62    StderrStream()
63        : StdStream(NULL, NULL, MORDOR_NATIVE(STD_ERROR_HANDLE, STDERR_FILENO))
64    {}
65    StderrStream(IOManager &ioManager)
66        : StdStream(&ioManager, NULL, MORDOR_NATIVE(STD_ERROR_HANDLE, STDERR_FILENO))
67    {}
68    StderrStream(Scheduler &scheduler)
69        : StdStream(NULL, &scheduler, MORDOR_NATIVE(STD_ERROR_HANDLE, STDERR_FILENO))
70    {}
71    StderrStream(IOManager &ioManager, Scheduler &scheduler)
72        : StdStream(&ioManager, &scheduler, MORDOR_NATIVE(STD_ERROR_HANDLE, STDERR_FILENO))
73    {}
74
75    bool supportsRead() { return false; }
76};
77
78}
79
80#endif