Example #1
0
  private Network createNetwork(Element element) {
    Network network = IrFactory.eINSTANCE.createNetwork();
    String id = element.getAttribute("id");
    network.setId(id);
    doAnnotations(network, element);

    addIrObject(id, network);

    network.setType((TypeActor) createType(getChild(element, "Type")));

    List<Element> declarations = getChildren(element, "Decl");
    for (Element e : declarations) {
      Declaration decl = (Declaration) createDeclaration(e);
      network.getDeclarations().add(decl);
      if (decl instanceof Variable && ((Variable) decl).isParameter()) {
        network.getParameters().add((Variable) decl);
      }
    }

    List<Element> ports = getChildren(element, "Port");
    for (Element e : ports) {
      Port port = createPort(e);
      if (e.getAttribute("direction").equals("in")) {
        network.getInputPorts().add(port);
      } else {
        network.getOutputPorts().add(port);
      }
    }

    List<Element> instances = getChildren(element, "Instance");
    for (Element e : instances) {
      ActorInstance instance = createActorInstance(e);
      network.getActors().add(instance);
    }

    List<Element> connections = getChildren(element, "Connection");
    for (Element e : connections) {
      Connection connection = createConnection(e, network);
      network.getConnections().add(connection);
    }

    return network;
  }