activemq-cpp-3.3.0

src/main/decaf/internal/nio/FloatArrayBuffer.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef _DECAF_INTERNAL_NIO_FLOATARRAYBUFFER_H_
00019 #define _DECAF_INTERNAL_NIO_FLOATARRAYBUFFER_H_
00020 
00021 #include <decaf/nio/FloatBuffer.h>
00022 #include <decaf/lang/exceptions/NullPointerException.h>
00023 #include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
00024 #include <decaf/nio/BufferUnderflowException.h>
00025 #include <decaf/nio/BufferOverflowException.h>
00026 #include <decaf/nio/ReadOnlyBufferException.h>
00027 #include <decaf/internal/util/ByteArrayAdapter.h>
00028 
00029 #include <decaf/lang/Pointer.h>
00030 
00031 namespace decaf{
00032 namespace internal{
00033 namespace nio{
00034 
00035     using decaf::internal::util::ByteArrayAdapter;
00036 
00037     class DECAF_API FloatArrayBuffer : public decaf::nio::FloatBuffer{
00038     private:
00039 
00040         // The reference array object that backs this buffer.
00041         decaf::lang::Pointer<ByteArrayAdapter> _array;
00042 
00043         // Offset into the array that we are to start from
00044         int offset;
00045 
00046         // Number of bytes to read past the offset, or Limit.
00047         int length;
00048 
00049         // Read / Write flag
00050         bool readOnly;
00051 
00052     public:
00053 
00066         FloatArrayBuffer( int size, bool readOnly = false );
00067 
00086         FloatArrayBuffer( float* array, int size, int offset, int length, bool readOnly = false );
00087 
00105         FloatArrayBuffer( const decaf::lang::Pointer<ByteArrayAdapter>& array, int offset, int capacity,
00106                           bool readOnly = false );
00107 
00116         FloatArrayBuffer( const FloatArrayBuffer& other );
00117 
00118         virtual ~FloatArrayBuffer();
00119 
00120     public:
00121 
00125         virtual float* array();
00126 
00130         virtual int arrayOffset();
00131 
00135         virtual FloatBuffer* asReadOnlyBuffer() const;
00136 
00140         virtual FloatBuffer& compact();
00141 
00145         virtual FloatBuffer* duplicate();
00146 
00150         virtual float get();
00151 
00155         virtual float get( int index ) const;
00156 
00160         virtual bool hasArray() const { return true; }
00161 
00165         virtual bool isReadOnly() const {
00166             return this->readOnly;
00167         }
00168 
00172         virtual FloatBuffer& put( float value );
00173 
00177         virtual FloatBuffer& put( int index, float value );
00178 
00182         virtual FloatBuffer* slice() const;
00183 
00184     protected:
00185 
00192         virtual void setReadOnly( bool value ) {
00193             this->readOnly = value;
00194         }
00195 
00196     };
00197 
00198 }}}
00199 
00200 #endif /*_DECAF_INTERNAL_NIO_FLOATARRAYBUFFER_H_*/