activemq-cpp-3.9.5
InputStream.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_INPUTSTREAM_H_
19#define _DECAF_IO_INPUTSTREAM_H_
20
22#include <decaf/io/Closeable.h>
28#include <decaf/util/Config.h>
29
30namespace decaf{
31namespace io{
32
39 class DECAF_API InputStream: public Closeable, virtual public util::concurrent::Synchronizable {
40 private:
41
42 // Synchronization object.
44
45 private:
46
47 InputStream(const InputStream&);
48 InputStream& operator=(const InputStream&);
49
50 public:
51
53
54 virtual ~InputStream();
55
64 virtual void close();
65
82 virtual void mark(int readLimit);
83
111 virtual void reset();
112
122 virtual bool markSupported() const {
123 return false;
124 }
125
139 virtual int available() const {
140 return 0;
141 }
142
156 virtual int read();
157
186 virtual int read(unsigned char* buffer, int size);
187
233 virtual int read(unsigned char* buffer, int size, int offset, int length);
234
256 virtual long long skip(long long num);
257
265 virtual std::string toString() const;
266
267 protected: // Virtual doRead methods that can be overridden to customize subclasses.
268
269 virtual int doReadByte() = 0;
270
271 virtual int doReadArray(unsigned char* buffer, int size);
272
273 virtual int doReadArrayBounded(unsigned char* buffer, int size, int offset, int length);
274
275 public: // Synchronizable
276
277 virtual void lock() {
278 mutex.lock();
279 }
280
281 virtual bool tryLock() {
282 return mutex.tryLock();
283 }
284
285 virtual void unlock() {
286 mutex.unlock();
287 }
288
289 virtual void wait() {
290 mutex.wait();
291 }
292
293 virtual void wait(long long millisecs) {
294 mutex.wait(millisecs);
295 }
296
297 virtual void wait(long long millisecs, int nanos) {
298 mutex.wait(millisecs, nanos);
299 }
300
301 virtual void notify() {
302 mutex.notify();
303 }
304
305 virtual void notifyAll() {
306 mutex.notifyAll();
307 }
308
309 };
310
311}}
312
313#endif /*_DECAF_IO_INPUTSTREAM_H_*/
Interface for a class that implements the close method.
Definition Closeable.h:30
virtual bool markSupported() const
Determines if this input stream supports the mark and reset methods.
Definition InputStream.h:122
virtual void wait(long long millisecs, int nanos)
Waits on a signal from this object, which is generated by a call to Notify.
Definition InputStream.h:297
virtual bool tryLock()
Attempts to Lock the object, if the lock is already held by another thread than this method returns f...
Definition InputStream.h:281
virtual int doReadArrayBounded(unsigned char *buffer, int size, int offset, int length)
virtual int doReadArray(unsigned char *buffer, int size)
virtual int read(unsigned char *buffer, int size)
Reads up to size bytes of data from the input stream into an array of bytes.
virtual void lock()
Locks the object.
Definition InputStream.h:277
virtual void mark(int readLimit)
Marks the current position in the stream A subsequent call to the reset method repositions this strea...
virtual long long skip(long long num)
Skips over and discards n bytes of data from this input stream.
virtual void close()
Closes the InputStream freeing any resources that might have been acquired during the lifetime of thi...
virtual void notify()
Signals a waiter on this object that it can now wake up and continue.
Definition InputStream.h:301
virtual int doReadByte()=0
virtual void wait()
Waits on a signal from this object, which is generated by a call to Notify.
Definition InputStream.h:289
virtual void wait(long long millisecs)
Waits on a signal from this object, which is generated by a call to Notify.
Definition InputStream.h:293
virtual void reset()
Repositions this stream to the position at the time the mark method was last called on this input str...
virtual void unlock()
Unlocks the object.
Definition InputStream.h:285
virtual int read(unsigned char *buffer, int size, int offset, int length)
Reads up to length bytes of data from the input stream into an array of bytes.
virtual void notifyAll()
Signals the waiters on this object that it can now wake up and continue.
Definition InputStream.h:305
virtual std::string toString() const
Output a String representation of this object.
virtual int available() const
Indicates the number of bytes available.
Definition InputStream.h:139
virtual int read()
Reads a single byte from the buffer.
Mutex object that offers recursive support on all platforms as well as providing the ability to use t...
Definition Mutex.h:39
The interface for all synchronizable objects (that is, objects that can be locked and unlocked).
Definition Synchronizable.h:37
#define DECAF_API
Definition Config.h:29
Definition BlockingByteArrayInputStream.h:25
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25