/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package API;

import common.Instruction;
import common.IvannosysTargetArch;
import common.Log;
import java.util.HashMap;

/**
 *
 * @author Eugenio
 */
public class Target {

    // Todos os processors serão armazenados aqui, e cada evendo possui uma lista de processors separada por virgula
    protected static HashMap<String, IvannosysTargetArch> targets = new HashMap<>();

    public static void _init() {

    }

    public static void Add(String id, IvannosysTargetArch target) throws Exception {
        if (targets.containsKey(id)) {
            Log.PrintWarning(
                    "Target API",
                    new Instruction().Set("msg", String.format("Tentativa de sobrescrita do gerador alvo %s.", id))
            );
        }
        targets.put(id, target);
    }

    public static IvannosysTargetArch Get(String id) throws Exception {
        if (!targets.containsKey(id)) {
            throw new Exception(String.format("Gerador alvo '%s' não definido.", id));
        }
        return targets.get(id);
    }

    public static boolean Has(String id) {
        return targets.containsKey(id);
    }
}
