Interface WiredNetwork


public interface WiredNetwork
A wired network is composed of one of more WiredNodes, a set of connections between them, and a series of peripherals.

Networks from a connected graph. This means there is some path between all nodes on the network. Further more, if there is some path between two nodes then they must be on the same network. WiredNetwork will automatically handle the merging and splitting of networks (and thus changing of available nodes and peripherals) as connections change.

This does mean one can not rely on the network remaining consistent between subsequent operations. Consequently, it is generally preferred to use the methods provided by WiredNode.

See Also:
  • Method Details

    • connect

      boolean connect(WiredNode left, WiredNode right)
      Create a connection between two nodes.

      This should only be used on the server thread.

      Parameters:
      left - The first node to connect
      right - The second node to connect
      Returns:
      true if a connection was created or false if the connection already exists.
      Throws:
      IllegalStateException - If neither node is on the network.
      IllegalArgumentException - If left and right are equal.
      See Also:
    • disconnect

      boolean disconnect(WiredNode left, WiredNode right)
      Destroy a connection between this node and another.

      This should only be used on the server thread.

      Parameters:
      left - The first node in the connection.
      right - The second node in the connection.
      Returns:
      true if a connection was destroyed or false if no connection exists.
      Throws:
      IllegalArgumentException - If either node is not on the network.
      IllegalArgumentException - If left and right are equal.
      See Also:
    • remove

      boolean remove(WiredNode node)
      Sever all connections this node has, removing it from this network.

      This should only be used on the server thread. You should only call this on nodes that your network element owns.

      Parameters:
      node - The node to remove
      Returns:
      Whether this node was removed from the network. One cannot remove a node from a network where it is the only element.
      Throws:
      IllegalArgumentException - If the node is not in the network.
      See Also:
    • updatePeripherals

      void updatePeripherals(WiredNode node, Map<String,IPeripheral> peripherals)
      Update the peripherals a node provides.

      This should only be used on the server thread. You should only call this on nodes that your network element owns.

      Parameters:
      node - The node to attach peripherals for.
      peripherals - The new peripherals for this node.
      Throws:
      IllegalArgumentException - If the node is not in the network.
      See Also: