package org.ntlab.radishforandroidstudio.cactusClient.models;

import org.ntlab.radishforandroidstudio.framework.model3D.Model3D;
import org.ntlab.radishforandroidstudio.framework.model3D.ModelFactory;
import org.ntlab.radishforandroidstudio.framework.model3D.ModelFileFormatException;

import java.io.IOException;
import java.util.HashMap;

class ObjectModelManager {

    private static ObjectModelManager theInstance = null;
    private HashMap<Integer, Model3D> model = new HashMap<>();
    // TODO: 2018/10/23 ObjectModelManagerの記述
    private ObjectModelManager() {
        try {
            setObject(0, ModelFactory.loadModel(null,getClass().getResource("../../pocha.stl").getPath()));
            setObject(1, ModelFactory.loadModel(null,getClass().getResource("../../pocha.stl").getPath()));
        } catch (IOException | ModelFileFormatException e) {
            e.printStackTrace();
        }
    }

    public static ObjectModelManager getInstance() {
        if (theInstance == null) {
            theInstance = new ObjectModelManager();
        }
        return theInstance;
    }

    public void setObject(int key, Model3D loadModel) {
        model.put(key, loadModel);
    }

    public Model3D getObject(int objectID) {
        return model.get(objectID);
    }

    public int getObjectModelCount() {
        return model.size();
    }
}
