Class PureBigraphMutable
java.lang.Object
org.bigraphs.framework.core.impl.pure.PureBigraph
org.bigraphs.framework.core.impl.pure.PureBigraphMutable
- All Implemented Interfaces:
Bigraph<DynamicSignature>,EcoreBigraph<DynamicSignature>,EcoreBigraphExt,HasSignature<DynamicSignature>
Mutable extension of
PureBigraph that supports live editing operations.
This class provides methods to modify the bigraph structure at runtime without requiring a complete rebuild. Changes are applied to both the EMF model and internal caches incrementally for optimal performance.
Key Features:
- O(1) mutation operations (addNode, removeNode, etc.)
- Automatic cache synchronization
- Event notification for change listeners
- Maintains consistency between EMF and entity collections
Usage Example:
PureBigraphMutable bigraph = builder.createMutable();
// Add a new node
BigraphEntity.NodeEntity newNode = bigraph.addNode(parentNode, sensorControl, "sensor_1");
// Remove a node
bigraph.removeNode(nodeToRemove);
// Connect to outer name
bigraph.connectPortToOuterName(port, outerName);
- Author:
- Manuel Krombholz, AI Assistant (Mutable Extension)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.bigraphs.framework.core.EcoreBigraph
EcoreBigraph.Stub<S extends AbstractEcoreSignature<?>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChangeListener(BigraphChangeListener listener) addEdge()Adds a new edge to the bigraph with an auto-generated name.Adds a new edge to the bigraph with the specified name.addInnerName(String name) Adds a new inner name to the bigraph.addNode(BigraphEntity<?> parent, DynamicControl control, String name) Adds a new node to the bigraph as a child of the specified parent.addOuterName(String name) Adds a new outer name to the bigraph.addPortToNode(BigraphEntity.NodeEntity<?> node) Adds a new port to a node.addRoot()Adds a new root to the bigraph.addSite(BigraphEntity<?> parent) Adds a new site to the bigraph as a child of the specified parent.voidcloseInner(BigraphEntity.InnerName innerName) Closes an inner name by disconnecting it from its link and removing it from the bigraph.voidcloseName(BigraphEntity<?> name) Closes a name endpoint by its concrete role.voidcloseOuter(BigraphEntity.OuterName outerName) Closes an outer name by disconnecting all attached points and removing the outer name.voidconnectInnerNameToLink(BigraphEntity.InnerName innerName, BigraphEntity.Link link) Connects an inner name to a link (edge or outer name).connectNodeToLink(BigraphEntity.NodeEntity<?> node, BigraphEntity.Link link) High-level convenience method: connects a node to a link by reusing an existing free (unlinked) port when available, or by creating a new one.voidconnectPortToLink(BigraphEntity.Port port, BigraphEntity.Link link) Connects a port to a link (edge or outer name).voiddisconnectInnerName(BigraphEntity.InnerName innerName) Disconnects an inner name from its link.voidDisconnects a port from its link.List<BigraphEntity<?>> getChildrenOf(BigraphEntity<?> node) Returns the set of children of a given node (including sites).getEdges()getNodes()getParent(BigraphEntity<?> node) Get the parent of a bigraph's place.getRoots()getSites()voidmoveNode(BigraphEntity.NodeEntity<DynamicControl> node, BigraphEntity<?> newParent) Moves a node to a new parent.voidremoveChangeListener(BigraphChangeListener listener) voidremoveEdge(BigraphEntity.Edge edge) Removes an edge from the bigraph.voidremoveInnerName(BigraphEntity.InnerName innerName) Removes an inner name from the bigraph.voidRemoves a node from the bigraph.voidremoveOuterName(BigraphEntity.OuterName outerName) Removes an outer name from the bigraph.voidRemoves a root from the bigraph.voidRemoves a site from the bigraph.Methods inherited from class org.bigraphs.framework.core.impl.pure.PureBigraph
areConnected, getAllLinks, getAllPlaces, getInstanceModel, getLevelOf, getLinkOfPoint, getMetaModel, getOpenNeighborhoodOfNode, getPointsFromLink, getPortCount, getPorts, getSiblingsOfInnerName, getSiblingsOfNode, getSignature, getTopLevelRoot, isParentOfMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bigraphs.framework.core.Bigraph
getIncidentLinksOf, getInnerFace, getOuterFace, getSupport, isActive, isActiveAtNode, isActiveAtSite, isDiscrete, isEpimorphic, isGround, isGuarding, isLean, isMonomorphic, isPrimeMethods inherited from interface org.bigraphs.framework.core.EcoreBigraph
getEMetaModelData, isBEdge, isBInnerName, isBLink, isBNode, isBOuterName, isBPlace, isBPoint, isBPort, isBRoot, isBSite, isIndexable, isNameable, isOfEClass
-
Constructor Details
-
PureBigraphMutable
-
-
Method Details
-
getRoots
- Specified by:
getRootsin interfaceBigraph<DynamicSignature>- Overrides:
getRootsin classPureBigraph
-
getNodes
- Specified by:
getNodesin interfaceBigraph<DynamicSignature>- Overrides:
getNodesin classPureBigraph
-
getSites
- Specified by:
getSitesin interfaceBigraph<DynamicSignature>- Overrides:
getSitesin classPureBigraph
-
getInnerNames
- Specified by:
getInnerNamesin interfaceBigraph<DynamicSignature>- Overrides:
getInnerNamesin classPureBigraph
-
getOuterNames
- Specified by:
getOuterNamesin interfaceBigraph<DynamicSignature>- Overrides:
getOuterNamesin classPureBigraph
-
getEdges
- Specified by:
getEdgesin interfaceBigraph<DynamicSignature>- Overrides:
getEdgesin classPureBigraph
-
getParent
Description copied from interface:BigraphGet the parent of a bigraph's place. Passing a root as argument will always returnnull.- Specified by:
getParentin interfaceBigraph<DynamicSignature>- Overrides:
getParentin classPureBigraph- Parameters:
node- a place of this bigraph- Returns:
- the parent of the given place, or
null
-
getChildrenOf
Description copied from interface:BigraphReturns the set of children of a given node (including sites).
If the node has no children, then an empty set is returned.- Specified by:
getChildrenOfin interfaceBigraph<DynamicSignature>- Overrides:
getChildrenOfin classPureBigraph- Parameters:
node- the node whose children should be returned- Returns:
- a set of children of the given node
-
getNodeOfPort
- Specified by:
getNodeOfPortin interfaceBigraph<DynamicSignature>- Overrides:
getNodeOfPortin classPureBigraph
-
addNode
public BigraphEntity.NodeEntity<DynamicControl> addNode(BigraphEntity<?> parent, DynamicControl control, String name) Adds a new node to the bigraph as a child of the specified parent.- Parameters:
parent- the parent entity (can be a Root or another Node)control- the control defining the node typename- optional name for the node (can be null)- Returns:
- the newly created node entity
- Throws:
IllegalArgumentException- if parent cannot have children or control is null
-
removeNode
Removes a node from the bigraph.- Parameters:
node- the node to remove- Throws:
IllegalArgumentException- if node is null or not found
-
moveNode
Moves a node to a new parent.- Parameters:
node- the node to movenewParent- the new parent- Throws:
IllegalArgumentException- if node or newParent is null
-
addSite
Adds a new site to the bigraph as a child of the specified parent.Sites are place-graph placeholders (holes) — they carry no control, arity, or link information. The site index is assigned automatically based on the current site count.
- Parameters:
parent- the parent entity (Root or Node); must not be null and must support children- Returns:
- the newly created site entity
- Throws:
IllegalArgumentException- if parent is null or cannot have children
-
removeSite
Removes a site from the bigraph.- Parameters:
site- the site to remove- Throws:
IllegalArgumentException- if site is null or not found in the bigraph
-
addRoot
Adds a new root to the bigraph.- Returns:
- the newly created root entity
-
removeRoot
Removes a root from the bigraph.- Parameters:
root- the root to remove- Throws:
IllegalArgumentException- if root is null or not found
-
addEdge
Adds a new edge to the bigraph with an auto-generated name.- Returns:
- the newly created edge entity
-
addEdge
Adds a new edge to the bigraph with the specified name.- Parameters:
name- the name for the edge- Returns:
- the newly created edge entity
-
removeEdge
Removes an edge from the bigraph.- Parameters:
edge- the edge to remove- Throws:
IllegalArgumentException- if edge is null or not found
-
connectPortToLink
Connects a port to a link (edge or outer name).- Parameters:
port- the port to connectlink- the link to connect to- Throws:
IllegalArgumentException- if port or link is null
-
connectInnerNameToLink
Connects an inner name to a link (edge or outer name).- Parameters:
innerName- the inner name to connectlink- the link to connect to- Throws:
IllegalArgumentException- if innerName or link is null
-
connectNodeToLink
public BigraphEntity.Port connectNodeToLink(BigraphEntity.NodeEntity<?> node, BigraphEntity.Link link) High-level convenience method: connects a node to a link by reusing an existing free (unlinked) port when available, or by creating a new one.This is the preferred API for callers that simply want to establish a Node → Link connection without managing ports manually. It encapsulates:
- Finding a free port (one whose
bLinkreference isnull). - Creating a new port if none is free and the arity allows it.
- Calling
connectPortToLink(BigraphEntity.Port, BigraphEntity.Link).
- Parameters:
node- the node to connectlink- the link (Edge or OuterName) to connect to- Returns:
- the port that was used or created for the connection
- Throws:
IllegalArgumentException- if node or link is nullIllegalStateException- if all ports are already linked and the arity limit has been reached
- Finding a free port (one whose
-
addPortToNode
Adds a new port to a node. The port index is automatically assigned based on existing ports.- Parameters:
node- the node to add the port to- Returns:
- the newly created port
- Throws:
IllegalArgumentException- if node is nullIllegalStateException- if node has reached its arity limit
-
disconnectPort
Disconnects a port from its link.- Parameters:
port- the port to disconnect- Throws:
IllegalArgumentException- if port is null
-
disconnectInnerName
Disconnects an inner name from its link.- Parameters:
innerName- the inner name to disconnect- Throws:
IllegalArgumentException- if innerName is null
-
closeName
Closes a name endpoint by its concrete role.Semantics:
- Inner name: disconnect from its current link (if any), then remove the inner name.
- Outer name: disconnect all currently attached points, then remove the outer name.
- Parameters:
name- the name endpoint to close (inner or outer)- Throws:
IllegalArgumentException- ifnameis null or not an inner/outer name
-
closeInner
Closes an inner name by disconnecting it from its link and removing it from the bigraph.- Parameters:
innerName- the inner name to close
-
closeOuter
Closes an outer name by disconnecting all attached points and removing the outer name.- Parameters:
outerName- the outer name to close
-
addOuterName
Adds a new outer name to the bigraph.- Parameters:
name- the name of the outer name- Returns:
- the newly created outer name entity
- Throws:
IllegalArgumentException- if name is null or empty
-
removeOuterName
Removes an outer name from the bigraph.- Parameters:
outerName- the outer name to remove- Throws:
IllegalArgumentException- if outerName is null or not found
-
addInnerName
Adds a new inner name to the bigraph.- Parameters:
name- the name of the inner name- Returns:
- the newly created inner name entity
- Throws:
IllegalArgumentException- if name is null or empty
-
removeInnerName
Removes an inner name from the bigraph.- Parameters:
innerName- the inner name to remove- Throws:
IllegalArgumentException- if innerName is null or not found
-
addChangeListener
-
removeChangeListener
-