//
// This header file defines the container class openArrayT<> and
// its associated iterator. This container class represents an open
// array with packed and unpacked dimensions.
//

#ifndef SIZED_ARRAY_H
#define SIZED_ARRAY_H

#include "svdpi.h"
#include "array.h"

namespace DPI_OO {

	template <typename ARRAY_TYPE, typename ELEM_TYPE>
	class sizedArrayT : public arrayT<ARRAY_TYPE, ELEM_TYPE> {

	public:
		sizedArrayT();

		sizedArrayT(const sizedArrayT<ARRAY_TYPE, ELEM_TYPE>& from);

		~sizedArrayT();

		// Part select read and write
		virtual void getPartsel(int idx, int width, ARRAY_TYPE* val) = 0;
		virtual void putPartsel(int idx, int width, const ARRAY_TYPE* val) = 0;

	};

	class BitVecValT : public sizedArrayT<uint32_t, uint8_t> {

	public:
		BitVecValT(uint32_t* val);

		BitVecValT(const BitVecValT& from);

		~BitVecValT();

		// Bit select read and write 
		void getBitsel(int idx, uint8_t* val);
		void putBitsel(int idx, const uint8_t* val);

		// Part select read and write
		void getPartsel(int idx, int width, uint32_t* val);
		void putPartsel(int idx, int width, const uint32_t* val);

		uint8_t* operator [] (int idx);

		BitVecValT& operator= (const BitVecValT& other);

		uint32_t* operator* ();
	};

	class LogicVecValT : public sizedArrayT<s_vpi_vecval, uint8_t> {

	public:

		LogicVecValT(s_vpi_vecval* val);

		LogicVecValT(const LogicVecValT& from);

		~LogicVecValT();

		// Bit select read and write 
		void getBitsel(int idx, uint8_t* val);
		void putBitsel(int idx, const uint8_t* val);

		// Part select read and write
		void getPartsel(int idx, int width, s_vpi_vecval* val);
		void putPartsel(int idx, int width, const s_vpi_vecval* val);

		uint8_t* operator [] (int idx);

		LogicVecValT& operator= (const LogicVecValT& other);

		s_vpi_vecval* operator* ();
	};
};

#endif
