Target.java 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package API;
  7. import common.Instruction;
  8. import common.IvannosysTargetArch;
  9. import common.Log;
  10. import java.util.HashMap;
  11. /**
  12. *
  13. * @author Eugenio
  14. */
  15. public class Target {
  16. // Todos os processors serão armazenados aqui, e cada evendo possui uma lista de processors separada por virgula
  17. protected static HashMap<String, IvannosysTargetArch> targets = new HashMap<>();
  18. public static void _init() {
  19. }
  20. public static void Add(String id, IvannosysTargetArch target) throws Exception {
  21. if (targets.containsKey(id)) {
  22. Log.PrintWarning(
  23. "Target API",
  24. new Instruction().S("msg", String.format("Tentativa de sobrescrita do gerador alvo %s.", id))
  25. );
  26. }
  27. targets.put(id, target);
  28. }
  29. public static IvannosysTargetArch Get(String id) throws Exception {
  30. if (!targets.containsKey(id)) {
  31. throw new Exception(String.format("Gerador alvo '%s' não definido.", id));
  32. }
  33. return targets.get(id);
  34. }
  35. public static boolean Has(String id) {
  36. return targets.containsKey(id);
  37. }
  38. }