activemq-cpp-3.8.2
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 
21 #include <decaf/io/IOException.h>
22 #include <decaf/io/Closeable.h>
28 #include <decaf/util/Config.h>
29 
30 namespace decaf{
31 namespace io{
32 
40  private:
41 
42  // Synchronization object.
44 
45  private:
46 
47  InputStream(const InputStream&);
48  InputStream& operator=(const InputStream&);
49 
50  public:
51 
52  InputStream();
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_*/
virtual bool tryLock()
Attempts to Lock the object, if the lock is already held by another thread than this method returns f...
Mutex object that offers recursive support on all platforms as well as providing the ability to use t...
Definition: Mutex.h:39
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 markSupported() const
Determines if this input stream supports the mark and reset methods.
Definition: InputStream.h:122
virtual void lock()
Locks the object.
Definition: InputStream.h:277
virtual void unlock()
Unlocks the object.
virtual void wait()
Waits on a signal from this object, which is generated by a call to Notify.
virtual void unlock()
Unlocks the object.
Definition: InputStream.h:285
A base class that must be implemented by all classes wishing to provide a class that reads in a strea...
Definition: InputStream.h:39
virtual void notifyAll()
Signals the waiters on this object that it can now wake up and continue.
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.
virtual void lock()
Locks the object.
virtual int available() const
Indicates the number of bytes available.
Definition: InputStream.h:139
virtual void notify()
Signals a waiter on this object that it can now wake up and continue.
Definition: InputStream.h:301
#define DECAF_API
Definition: Config.h:29
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
The interface for all synchronizable objects (that is, objects that can be locked and unlocked)...
Definition: Synchronizable.h:37
virtual void notifyAll()
Signals the waiters on this object that it can now wake up and continue.
Definition: InputStream.h:305
virtual void wait()
Waits on a signal from this object, which is generated by a call to Notify.
Definition: InputStream.h:289
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25
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