activemq-cpp-3.8.2
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*/
virtual void wait()
Waits on a signal from this object, which is generated by a call to Notify.
Definition: OutputStream.h:160
virtual void wait(long long millisecs, int nanos)
Waits on a signal from this object, which is generated by a call to Notify.
Definition: OutputStream.h:168
Mutex object that offers recursive support on all platforms as well as providing the ability to use t...
Definition: Mutex.h:39
virtual void notifyAll()
Signals the waiters on this object that it can now wake up and continue.
Definition: OutputStream.h:176
virtual void lock()
Locks the object.
Definition: OutputStream.h:148
virtual void unlock()
Unlocks the object.
Definition: OutputStream.h:156
virtual void wait(long long millisecs)
Waits on a signal from this object, which is generated by a call to Notify.
Definition: OutputStream.h:164
Interface for a class that implements the close method.
Definition: Closeable.h:30
virtual void notify()
Signals a waiter on this object that it can now wake up and continue.
Definition: OutputStream.h:172
#define DECAF_API
Definition: Config.h:29
Base interface for any class that wants to represent an output stream of bytes.
Definition: OutputStream.h:39
virtual bool tryLock()
Attempts to Lock the object, if the lock is already held by another thread than this method returns f...
Definition: OutputStream.h:152
The interface for all synchronizable objects (that is, objects that can be locked and unlocked)...
Definition: Synchronizable.h:37
A Flushable is a destination of data that can be flushed.
Definition: Flushable.h:34