// __author__ = Juan Carlos De Abreu (jcabreur@gmail.com)
//
// Can Store any kind of data types ...

#ifndef DATA_VECTOR_H__
#define DATA_VECTOR_H__
 
#include "Data.h"

BEGIN_TEG_NAMESPACE();

// To store a vector of DATA ...
class DataVector : public IData {
public:
	std::vector<SmartPointer<IData>> value;

	DataVector() : IData(DATA_VECTOR) { }
	~DataVector() { }

	void print() {
		printf("(");
		const int nValues = static_cast<int> (value.size());
		for (int i = 0; i < nValues; ++i) {
			if (i != 0) printf(", ");
		}
		printf(")");
	}

	SmartPointer<IData> resolve(std::map<std::string, SmartPointer<IData>>& variables);
	SmartPointer<IData> getAttribute(std::string attrName);
	SmartPointer<IData> getElement(SmartPointer<IData> elem);

  SmartPointer<IData> getMethod(
      SmartPointer<IData> elem,
      std::map<std::string, SmartPointer<IData>>& variables);


  // Method to free the container
  void freePtrs();
  AUTO_SIZE();
};

inline SmartPointer<DataVector> castToDataVector(SmartPointer<IData> d) {
	return SmartPointer<DataVector>(dynamic_cast<DataVector*>((IData*) d));
}

END_TEG_NAMESPACE();

#endif  // DATA_VECTOR_H__
