activemq-cpp-3.6.0
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_*/