activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r603599 - in /activemq/activemq-cpp/decaf/trunk/src/main/decaf: internal/nio/BufferFactory.cpp internal/nio/BufferFactory.h nio/DoubleBuffer.cpp nio/FloatBuffer.cpp nio/IntBuffer.cpp nio/LongBuffer.cpp nio/ShortBuffer.cpp
Date Wed, 12 Dec 2007 12:38:32 GMT
Author: tabish
Date: Wed Dec 12 04:38:32 2007
New Revision: 603599

URL: http://svn.apache.org/viewvc?rev=603599&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-153

Working on implementing the NIO package

Modified:
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/BufferFactory.cpp
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/BufferFactory.h
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/DoubleBuffer.cpp
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/FloatBuffer.cpp
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/IntBuffer.cpp
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/LongBuffer.cpp
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/ShortBuffer.cpp

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/BufferFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/BufferFactory.cpp?rev=603599&r1=603598&r2=603599&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/BufferFactory.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/BufferFactory.cpp Wed Dec
12 04:38:32 2007
@@ -21,6 +21,9 @@
 #include <decaf/internal/nio/CharArrayBuffer.h>
 #include <decaf/internal/nio/DoubleArrayBuffer.h>
 #include <decaf/internal/nio/FloatArrayBuffer.h>
+#include <decaf/internal/nio/LongArrayBuffer.h>
+#include <decaf/internal/nio/IntArrayBuffer.h>
+#include <decaf/internal/nio/ShortArrayBuffer.h>
 
 using namespace decaf;
 using namespace decaf::internal;
@@ -160,6 +163,108 @@
 
     try{
         return new FloatArrayBuffer( &buffer[0], 0, buffer.size(), false );
+    }
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+LongBuffer* BufferFactory::createLongBuffer( std::size_t capacity ) {
+
+    try{
+        return new LongArrayBuffer( capacity );
+    }
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+LongBuffer* BufferFactory::createLongBuffer( long long* buffer,
+                                             std::size_t offset,
+                                             std::size_t length )
+    throw( lang::exceptions::NullPointerException ) {
+
+    try{
+        return new LongArrayBuffer( buffer, offset, length, false );
+    }
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
+    DECAF_CATCHALL_THROW( NullPointerException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+LongBuffer* BufferFactory::createLongBuffer( std::vector<long long>& buffer ) {
+
+    try{
+        return new LongArrayBuffer( &buffer[0], 0, buffer.size(), false );
+    }
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+IntBuffer* BufferFactory::createIntBuffer( std::size_t capacity ) {
+
+    try{
+        return new IntArrayBuffer( capacity );
+    }
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+IntBuffer* BufferFactory::createIntBuffer( int* buffer,
+                                           std::size_t offset,
+                                           std::size_t length )
+    throw( lang::exceptions::NullPointerException ) {
+
+    try{
+        return new IntArrayBuffer( buffer, offset, length, false );
+    }
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
+    DECAF_CATCHALL_THROW( NullPointerException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+IntBuffer* BufferFactory::createIntBuffer( std::vector<int>& buffer ) {
+
+    try{
+        return new IntArrayBuffer( &buffer[0], 0, buffer.size(), false );
+    }
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ShortBuffer* BufferFactory::createShortBuffer( std::size_t capacity ) {
+
+    try{
+        return new ShortArrayBuffer( capacity );
+    }
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ShortBuffer* BufferFactory::createShortBuffer( short* buffer,
+                                               std::size_t offset,
+                                               std::size_t length )
+    throw( lang::exceptions::NullPointerException ) {
+
+    try{
+        return new ShortArrayBuffer( buffer, offset, length, false );
+    }
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
+    DECAF_CATCHALL_THROW( NullPointerException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ShortBuffer* BufferFactory::createShortBuffer( std::vector<short>& buffer ) {
+
+    try{
+        return new ShortArrayBuffer( &buffer[0], 0, buffer.size(), false );
     }
     DECAF_CATCH_RETHROW( Exception )
     DECAF_CATCHALL_THROW( Exception )

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/BufferFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/BufferFactory.h?rev=603599&r1=603598&r2=603599&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/BufferFactory.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/BufferFactory.h Wed Dec
12 04:38:32 2007
@@ -186,7 +186,7 @@
             throw( lang::exceptions::NullPointerException );
 
         /**
-         * Wraps the passed STL Float Vector in a DoubleBuffer.
+         * Wraps the passed STL Float Vector in a FloatBuffer.
          * <p>
          * The new buffer will be backed by the given byte array; modifications to the
          * buffer will cause the array to be modified and vice versa. The new buffer's
@@ -198,6 +198,126 @@
          * @returns a new DoubleBuffer that is backed by buffer, caller owns.
          */
         static decaf::nio::FloatBuffer* createFloatBuffer( std::vector<float>&
buffer );
+
+        /**
+         * Allocates a new long long buffer whose position will be zero its limit will
+         * be its capacity and its mark is not set.
+         * @param capacity - the internal buffer's capacity.
+         * @returns a newly allocated DoubleBuffer which the caller owns.
+         */
+        static decaf::nio::LongBuffer* createLongBuffer( std::size_t capacity );
+
+        /**
+         * Wraps the passed buffer with a new LongBuffer.
+         * <p>
+         * The new buffer will be backed by the given byte array; that is, modifications
+         * to the buffer will cause the array to be modified and vice versa. The new
+         * buffer's capacity will be array.length, its position will be offset, its limit
+         * will be offset + length, and its mark will be undefined. Its backing array
+         * will be the given array, and its array offset will be zero.
+         * @param buffer - The array that will back the new buffer
+         * @param offset - The offset of the subarray to be used
+         * @param length - The length of the subarray to be used
+         * @returns a new DoubleBuffer that is backed by buffer, caller owns.
+         */
+        static decaf::nio::LongBuffer* createLongBuffer( long long* buffer,
+                                                           std::size_t offset,
+                                                           std::size_t length )
+            throw( lang::exceptions::NullPointerException );
+
+        /**
+         * Wraps the passed STL Long Vector in a LongBuffer.
+         * <p>
+         * The new buffer will be backed by the given byte array; modifications to the
+         * buffer will cause the array to be modified and vice versa. The new buffer's
+         * capacity and limit will be buffer.size(), its position will be zero, and its
+         * mark will be undefined. Its backing array will be the given array, and its
+         * array offset will be zero.
+         * @param buffer - The vector that will back the new buffer, the vector must
+         * have been sized to the desired size already by calling vector.resize( N ).
+         * @returns a new DoubleBuffer that is backed by buffer, caller owns.
+         */
+        static decaf::nio::LongBuffer* createLongBuffer( std::vector<long long>&
buffer );
+
+        /**
+         * Allocates a new int buffer whose position will be zero its limit will
+         * be its capacity and its mark is not set.
+         * @param capacity - the internal buffer's capacity.
+         * @returns a newly allocated DoubleBuffer which the caller owns.
+         */
+        static decaf::nio::IntBuffer* createIntBuffer( std::size_t capacity );
+
+        /**
+         * Wraps the passed buffer with a new IntBuffer.
+         * <p>
+         * The new buffer will be backed by the given byte array; that is, modifications
+         * to the buffer will cause the array to be modified and vice versa. The new
+         * buffer's capacity will be array.length, its position will be offset, its limit
+         * will be offset + length, and its mark will be undefined. Its backing array
+         * will be the given array, and its array offset will be zero.
+         * @param buffer - The array that will back the new buffer
+         * @param offset - The offset of the subarray to be used
+         * @param length - The length of the subarray to be used
+         * @returns a new DoubleBuffer that is backed by buffer, caller owns.
+         */
+        static decaf::nio::IntBuffer* createIntBuffer( int* buffer,
+                                                       std::size_t offset,
+                                                       std::size_t length )
+            throw( lang::exceptions::NullPointerException );
+
+        /**
+         * Wraps the passed STL int Vector in a IntBuffer.
+         * <p>
+         * The new buffer will be backed by the given byte array; modifications to the
+         * buffer will cause the array to be modified and vice versa. The new buffer's
+         * capacity and limit will be buffer.size(), its position will be zero, and its
+         * mark will be undefined. Its backing array will be the given array, and its
+         * array offset will be zero.
+         * @param buffer - The vector that will back the new buffer, the vector must
+         * have been sized to the desired size already by calling vector.resize( N ).
+         * @returns a new DoubleBuffer that is backed by buffer, caller owns.
+         */
+        static decaf::nio::IntBuffer* createIntBuffer( std::vector<int>& buffer
);
+
+        /**
+         * Allocates a new short buffer whose position will be zero its limit will
+         * be its capacity and its mark is not set.
+         * @param capacity - the internal buffer's capacity.
+         * @returns a newly allocated DoubleBuffer which the caller owns.
+         */
+        static decaf::nio::ShortBuffer* createShortBuffer( std::size_t capacity );
+
+        /**
+         * Wraps the passed buffer with a new ShortBuffer.
+         * <p>
+         * The new buffer will be backed by the given byte array; that is, modifications
+         * to the buffer will cause the array to be modified and vice versa. The new
+         * buffer's capacity will be array.length, its position will be offset, its limit
+         * will be offset + length, and its mark will be undefined. Its backing array
+         * will be the given array, and its array offset will be zero.
+         * @param buffer - The array that will back the new buffer
+         * @param offset - The offset of the subarray to be used
+         * @param length - The length of the subarray to be used
+         * @returns a new DoubleBuffer that is backed by buffer, caller owns.
+         */
+        static decaf::nio::ShortBuffer* createShortBuffer( short* buffer,
+                                                           std::size_t offset,
+                                                           std::size_t length )
+            throw( lang::exceptions::NullPointerException );
+
+        /**
+         * Wraps the passed STL Short Vector in a ShortBuffer.
+         * <p>
+         * The new buffer will be backed by the given byte array; modifications to the
+         * buffer will cause the array to be modified and vice versa. The new buffer's
+         * capacity and limit will be buffer.size(), its position will be zero, and its
+         * mark will be undefined. Its backing array will be the given array, and its
+         * array offset will be zero.
+         * @param buffer - The vector that will back the new buffer, the vector must
+         * have been sized to the desired size already by calling vector.resize( N ).
+         * @returns a new DoubleBuffer that is backed by buffer, caller owns.
+         */
+        static decaf::nio::ShortBuffer* createShortBuffer( std::vector<short>&
buffer );
 
     };
 

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/DoubleBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/DoubleBuffer.cpp?rev=603599&r1=603598&r2=603599&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/DoubleBuffer.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/DoubleBuffer.cpp Wed Dec 12 04:38:32
2007
@@ -54,7 +54,7 @@
         if( buffer == NULL ) {
             throw NullPointerException(
                 __FILE__, __LINE__,
-                "CharBuffer::wrap - Passed Buffer is Null.");
+                "DoubleBuffer::wrap - Passed Buffer is Null.");
         }
 
         return BufferFactory::createDoubleBuffer( buffer, offset, length );

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/FloatBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/FloatBuffer.cpp?rev=603599&r1=603598&r2=603599&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/FloatBuffer.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/FloatBuffer.cpp Wed Dec 12 04:38:32
2007
@@ -54,7 +54,7 @@
         if( buffer == NULL ) {
             throw NullPointerException(
                 __FILE__, __LINE__,
-                "CharBuffer::wrap - Passed Buffer is Null.");
+                "FloatBuffer::wrap - Passed Buffer is Null.");
         }
 
         return BufferFactory::createFloatBuffer( buffer, offset, length );
@@ -72,7 +72,7 @@
         if( buffer.empty() ) {
             throw NullPointerException(
                 __FILE__, __LINE__,
-                "DoubleBuffer::wrap - Passed Buffer is Empty.");
+                "FloatBuffer::wrap - Passed Buffer is Empty.");
         }
 
         return BufferFactory::createFloatBuffer( &buffer[0], 0, buffer.size() );

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/IntBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/IntBuffer.cpp?rev=603599&r1=603598&r2=603599&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/IntBuffer.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/IntBuffer.cpp Wed Dec 12 04:38:32
2007
@@ -19,17 +19,67 @@
 
 #include <decaf/lang/Integer.h>
 #include <decaf/lang/Math.h>
+#include "decaf/internal/nio/BufferFactory.h"
 
 using namespace std;
 using namespace decaf;
 using namespace decaf::nio;
 using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
+using namespace decaf::internal::nio;
 
 ////////////////////////////////////////////////////////////////////////////////
 IntBuffer::IntBuffer( std::size_t capacity )
  :  Buffer( capacity ) {
 
+}
+
+////////////////////////////////////////////////////////////////////////////////
+IntBuffer* IntBuffer::allocate( std::size_t capacity ) {
+
+    try{
+
+        return BufferFactory::createIntBuffer( capacity );
+    }
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+IntBuffer* IntBuffer::wrap( int* buffer, std::size_t offset, std::size_t length )
+    throw( lang::exceptions::NullPointerException ) {
+
+    try{
+
+        if( buffer == NULL ) {
+            throw NullPointerException(
+                __FILE__, __LINE__,
+                "IntBuffer::wrap - Passed Buffer is Null.");
+        }
+
+        return BufferFactory::createIntBuffer( buffer, offset, length );
+    }
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
+    DECAF_CATCHALL_THROW( NullPointerException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+IntBuffer* IntBuffer::wrap( std::vector<int>& buffer ) {
+
+    try{
+
+        if( buffer.empty() ) {
+            throw NullPointerException(
+                __FILE__, __LINE__,
+                "IntBuffer::wrap - Passed Buffer is Empty.");
+        }
+
+        return BufferFactory::createIntBuffer( &buffer[0], 0, buffer.size() );
+    }
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
+    DECAF_CATCHALL_THROW( NullPointerException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/LongBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/LongBuffer.cpp?rev=603599&r1=603598&r2=603599&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/LongBuffer.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/LongBuffer.cpp Wed Dec 12 04:38:32
2007
@@ -19,17 +19,67 @@
 
 #include <decaf/lang/Long.h>
 #include <decaf/lang/Math.h>
+#include "decaf/internal/nio/BufferFactory.h"
 
 using namespace std;
 using namespace decaf;
 using namespace decaf::nio;
 using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
+using namespace decaf::internal::nio;
 
 ////////////////////////////////////////////////////////////////////////////////
 LongBuffer::LongBuffer( std::size_t capacity )
  :  Buffer( capacity ) {
 
+}
+
+////////////////////////////////////////////////////////////////////////////////
+LongBuffer* LongBuffer::allocate( std::size_t capacity ) {
+
+    try{
+
+        return BufferFactory::createLongBuffer( capacity );
+    }
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+LongBuffer* LongBuffer::wrap( long long* buffer, std::size_t offset, std::size_t length )
+    throw( lang::exceptions::NullPointerException ) {
+
+    try{
+
+        if( buffer == NULL ) {
+            throw NullPointerException(
+                __FILE__, __LINE__,
+                "LongBuffer::wrap - Passed Buffer is Null.");
+        }
+
+        return BufferFactory::createLongBuffer( buffer, offset, length );
+    }
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
+    DECAF_CATCHALL_THROW( NullPointerException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+LongBuffer* LongBuffer::wrap( std::vector<long long>& buffer ) {
+
+    try{
+
+        if( buffer.empty() ) {
+            throw NullPointerException(
+                __FILE__, __LINE__,
+                "LongBuffer::wrap - Passed Buffer is Empty.");
+        }
+
+        return BufferFactory::createLongBuffer( &buffer[0], 0, buffer.size() );
+    }
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
+    DECAF_CATCHALL_THROW( NullPointerException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/ShortBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/ShortBuffer.cpp?rev=603599&r1=603598&r2=603599&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/ShortBuffer.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/ShortBuffer.cpp Wed Dec 12 04:38:32
2007
@@ -19,17 +19,67 @@
 
 #include <decaf/lang/Float.h>
 #include <decaf/lang/Math.h>
+#include "decaf/internal/nio/BufferFactory.h"
 
 using namespace std;
 using namespace decaf;
 using namespace decaf::nio;
 using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
+using namespace decaf::internal::nio;
 
 ////////////////////////////////////////////////////////////////////////////////
 ShortBuffer::ShortBuffer( std::size_t capacity )
  :  Buffer( capacity ) {
 
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ShortBuffer* ShortBuffer::allocate( std::size_t capacity ) {
+
+    try{
+
+        return BufferFactory::createShortBuffer( capacity );
+    }
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ShortBuffer* ShortBuffer::wrap( short* buffer, std::size_t offset, std::size_t length )
+    throw( lang::exceptions::NullPointerException ) {
+
+    try{
+
+        if( buffer == NULL ) {
+            throw NullPointerException(
+                __FILE__, __LINE__,
+                "ShortBuffer::wrap - Passed Buffer is Null.");
+        }
+
+        return BufferFactory::createShortBuffer( buffer, offset, length );
+    }
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
+    DECAF_CATCHALL_THROW( NullPointerException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ShortBuffer* ShortBuffer::wrap( std::vector<short>& buffer ) {
+
+    try{
+
+        if( buffer.empty() ) {
+            throw NullPointerException(
+                __FILE__, __LINE__,
+                "ShortBuffer::wrap - Passed Buffer is Empty.");
+        }
+
+        return BufferFactory::createShortBuffer( &buffer[0], 0, buffer.size() );
+    }
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
+    DECAF_CATCHALL_THROW( NullPointerException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////



Mime
View raw message