00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _DECAF_IO_OUTPUTSTREAM_H
00019 #define _DECAF_IO_OUTPUTSTREAM_H
00020
00021 #include <decaf/io/Closeable.h>
00022 #include <decaf/io/Flushable.h>
00023 #include <decaf/io/IOException.h>
00024 #include <decaf/util/concurrent/Synchronizable.h>
00025 #include <decaf/util/concurrent/Mutex.h>
00026 #include <decaf/util/Config.h>
00027
00028 #include <decaf/lang/exceptions/NullPointerException.h>
00029 #include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
00030
00031 namespace decaf{
00032 namespace io{
00033
00039 class DECAF_API OutputStream: public Closeable, public Flushable, public util::concurrent::Synchronizable {
00040 private:
00041
00042
00043 util::concurrent::Mutex mutex;
00044
00045 private:
00046
00047 OutputStream(const OutputStream&);
00048 OutputStream& operator=(const OutputStream&);
00049
00050 public:
00051
00052 OutputStream();
00053
00054 virtual ~OutputStream();
00055
00061 virtual void close();
00062
00068 virtual void flush();
00069
00081 virtual void write(unsigned char c);
00082
00101 virtual void write(const unsigned char* buffer, int size);
00102
00127 virtual void write(const unsigned char* buffer, int size, int offset, int length);
00128
00136 virtual std::string toString() const;
00137
00138 protected:
00139
00140 virtual void doWriteByte(unsigned char value) = 0;
00141
00142 virtual void doWriteArray(const unsigned char* buffer, int size);
00143
00144 virtual void doWriteArrayBounded(const unsigned char* buffer, int size, int offset, int length);
00145
00146 public:
00147
00148 virtual void lock() {
00149 mutex.lock();
00150 }
00151
00152 virtual bool tryLock() {
00153 return mutex.tryLock();
00154 }
00155
00156 virtual void unlock() {
00157 mutex.unlock();
00158 }
00159
00160 virtual void wait() {
00161 mutex.wait();
00162 }
00163
00164 virtual void wait(long long millisecs) {
00165 mutex.wait(millisecs);
00166 }
00167
00168 virtual void wait(long long millisecs, int nanos) {
00169 mutex.wait(millisecs, nanos);
00170 }
00171
00172 virtual void notify() {
00173 mutex.notify();
00174 }
00175
00176 virtual void notifyAll() {
00177 mutex.notifyAll();
00178 }
00179
00180 };
00181
00182 }}
00183
00184 #endif