#pragma once

#include <stm32f4xx_hal.h>

#include <stdint.h>
#include <string>
#include <string.h>
using namespace std;
	
class FIFOQueue
{
public:
	FIFOQueue(uint32_t depth, uint32_t width, string id)
	{
		qDepth = depth;
		qWidth = width;
		qID = id;
		queue = new QRecord[depth];
	}
	
	//TODO seems like QRecord should be available to instantiated objects
    struct QRecord
	{
		string msgID;
		RTC_DateTypeDef dateStamp;
		RTC_TimeTypeDef timeStamp;
		string msg;
	};
	QRecord qRecord;
	
	int32_t dequeue(QRecord* qRecord);
	int32_t enqueue(QRecord* qRecord);
	int32_t getCount()
	{
		return(count);
	}
	
private:
	uint32_t qDepth;
	uint32_t qWidth;
	uint32_t head = 0;
	uint32_t tail = 0;
	int32_t count = 0;
	string qID;

	QRecord* queue;

	int32_t pushQueue(QRecord* qRecord);
	int32_t popQueue(QRecord* qRecord);
	void logError();
};

