activemq-cpp-3.6.0
OutputStream.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _DECAF_IO_OUTPUTSTREAM_H
19 #define _DECAF_IO_OUTPUTSTREAM_H
20 
21 #include <decaf/io/Closeable.h>
22 #include <decaf/io/Flushable.h>
23 #include <decaf/io/IOException.h>
26 #include <decaf/util/Config.h>
27 
30 
31 namespace decaf{
32 namespace io{
33 
40  private:
41 
42  // Synchronization object.
44 
45  private:
46 
47  OutputStream(const OutputStream&);
48  OutputStream& operator=(const OutputStream&);
49 
50  public:
51 
52  OutputStream();
53 
54  virtual ~OutputStream();
55 
61  virtual void close();
62 
68  virtual void flush();
69 
81  virtual void write(unsigned char c);
82 
101  virtual void write(const unsigned char* buffer, int size);
102 
127  virtual void write(const unsigned char* buffer, int size, int offset, int length);
128 
136  virtual std::string toString() const;
137 
138  protected:
139 
140  virtual void doWriteByte(unsigned char value) = 0;
141 
142  virtual void doWriteArray(const unsigned char* buffer, int size);
143 
144  virtual void doWriteArrayBounded(const unsigned char* buffer, int size, int offset, int length);
145 
146  public:
147 
148  virtual void lock() {
149  mutex.lock();
150  }
151 
152  virtual bool tryLock() {
153  return mutex.tryLock();
154  }
155 
156  virtual void unlock() {
157  mutex.unlock();
158  }
159 
160  virtual void wait() {
161  mutex.wait();
162  }
163 
164  virtual void wait(long long millisecs) {
165  mutex.wait(millisecs);
166  }
167 
168  virtual void wait(long long millisecs, int nanos) {
169  mutex.wait(millisecs, nanos);
170  }
171 
172  virtual void notify() {
173  mutex.notify();
174  }
175 
176  virtual void notifyAll() {
177  mutex.notifyAll();
178  }
179 
180  };
181 
182 }}
183 
184 #endif /*_DECAF_IO_OUTPUTSTREAM_H*/