// __author__ = Juan Carlos De Abreu (jcabreur@gmail.com)
//
// This class define a Memory Management for the basic data types in the parse.

#ifndef DATA_MEMORY_MANAGEMENT_H__
#define DATA_MEMORY_MANAGEMENT_H__

#include "../Base/Singleton.h"
#include "../Base/Memory/SmartPointer.h"
#include "DataTypes.h"

BEGIN_TEG_NAMESPACE();

#define MAX_DATA_ARRAY_SIZE 2000

#define NEW_DATA_INT(t) DataMemoryManagement::GetInstance().newDataInt(t)
#define NEW_DATA_BOOL(t) DataMemoryManagement::GetInstance().newDataBool(t)
#define NEW_DATA_FLOAT(t) DataMemoryManagement::GetInstance().newDataFloat(t)

class DataMemoryManagement : public Singleton<DataMemoryManagement> {
private:
  // Attributes.
  std::vector<SmartPointer<IData>> buffer;

public:
#ifdef _DEBUG
  int numNewf, numNewi, numNewb;
#endif 

  // DataMemoryManagement constructor.
  DataMemoryManagement();

  // DataMemoryManagement destructor.
  ~DataMemoryManagement();

  // Methods.
  void init(void);
  void release(void);
  int getNextFreePosition(const int& type) const;
  SmartPointer<DataInt> newDataInt(const int& t);
  SmartPointer<DataBool> newDataBool(const bool& t);
  SmartPointer<DataFloat> newDataFloat(const float& t);
};

END_TEG_NAMESPACE();

#endif  // DATA_MEMORY_MANAGEMENT_H__
