#ifndef __CUARRAY_HPP__
#define __CUARRAY_HPP__

namespace amscuda
{

template<typename T> class cuarray
{
public:
    int length;
    T* data;

    __device__ __host__ cuarray();
    __device__ __host__ ~cuarray();

    //Only call this on the device for thread/block local 
    // dynamic arrays
    __device__ __host__ int resize(const int _length);

    __device__ __host__ int size() const;
    __device__ __host__ T& at(const int I);
    __device__ __host__ const T& at(const int I) const;

    __device__ __host__ T& operator[](const int I);
    __device__ __host__ const T& operator[](const int I) const;
    
    

    __host__ int device_send(cuarray<T> **dptr);
    __host__ int _device_send_overwrite(cuarray<T> **dptr);
    __host__ int _device_send_copy(cuarray<T> *dptr);
    
    __host__ int device_pull(cuarray<T> *dptr);
    __host__ int device_free(cuarray<T> **dptr);

    __host__ int device_length(cuarray<T> *dptr);
    __host__ T* device_data_ptr(cuarray<T> *dptr);
    
};

void test_cuarray();

};

#include <amsculib2/amscuarray_impl.hpp>

#endif