// Author: Juan Carlos De Abreu (jcabreur@gmail.com)
//
// This file define a class to manage the materials in the app.

#ifndef MATERIAL_MANAGEMENT_H__
#define MATERIAL_MANAGEMENT_H__

#include "../global.h"
#include "Material.h"
#include "../Base/Singleton.h"
#include "../Base/Memory/SmartPointer.h"

BEGIN_TEG_NAMESPACE();

// Macros to use the functionality of the MaterialManagement.
#define LOAD_MATERIALS(path) MaterialManagement::GetInstance().load(path)
#define MATERIAL(name) MaterialManagement::GetInstance().get(name)

class MaterialManagement : public Singleton<MaterialManagement> {
protected:
  // Attributes.
  std::map<std::tstring, SmartPointer<Material>> materials; // Materials in the app.
	
 public:
  // MaterialManagement constructor and destructor.
  MaterialManagement();
  ~MaterialManagement();

  // Methods.
  void load(const std::tstring& path); // Method to load a material file.
  void init();
  void release();
  SmartPointer<Material> get(const std::tstring& materialName); // Method to get a material.

protected:
  void add(const SmartPointer<Material>& material);

 private:
  DISALLOW_COPY_AND_ASSIGN(MaterialManagement);
};

END_TEG_NAMESPACE();

#endif  // MATERIAL_MANAGEMENT_H__
