MutationListener
Generic API to handle mutations of the graph
`MutationListener` handles structural changes within the SOFA scene graph by providing callbacks for various mutation events.
- module
- Sofa.framework.Simulation.Core
- namespace
- sofa::simulation
- include
- sofa/simulation/MutationListener.h
- description
The MutationListener class in the SOFA framework is primarily responsible for handling structural changes within the simulation graph, but it does not directly contribute to any governing equations or operators related to FEM simulation. Instead, its role is more about providing a mechanism to react to mutations such as adding or removing nodes and objects within the scene graph.
Mathematical and Physical Description:
-
Governing Equations / Operators: The
MutationListenerdoes not implement or contribute to any governing equations (e.g., mass matrix $M$, stiffness matrix $K$, internal force $f_{int}$, residual $R$) directly. It is an API designed for event handling. -
Constitutive / Kinematic Laws: The component does not define or involve any constitutive laws (strain measures, stress tensors, hyperelastic potentials) or kinematic relations. Its purpose is to provide callbacks that can be used by other components to react to structural changes in the graph.
-
Role in FEM Pipeline:
MutationListenerplays no direct role in assembly, time integration, nonlinear solve, linear solve, constraint handling, mapping, etc., as these are handled by other specific components within SOFA. Instead, it acts as a framework for ensuring that custom actions can be performed when the graph structure changes. -
Numerical Methods / Discretization Choices: The
MutationListenerdoes not encode any numerical methods or discretization choices related to FEM simulation. Its primary function is to provide hooks (methods) that can be overridden by derived classes to perform specific tasks during mutation events. -
Integration into Variational / Lagrangian Mechanics Framework: The component fits into the broader framework by enabling developers to implement custom behavior in response to changes in the scene graph structure, which might indirectly influence other components involved in variational or Lagrangian mechanics. However, it does not directly participate in the mathematical formulation of the simulation.
Summary:
The MutationListener is a pure API component that provides callbacks for handling structural mutations within the SOFA simulation framework. It does not contribute to any specific FEM equations or operators and is primarily used for event-driven reactions to changes in the scene graph.
Methods
void
sleepChanged
(Node * node)
virtual
void
onBeginAddChild
(Node * parent, Node * child)
virtual
void
onBeginRemoveChild
(Node * parent, Node * child)
virtual
void
onBeginAddObject
(Node * parent, core::objectmodel::BaseObject * object)
virtual
void
onBeginRemoveObject
(Node * parent, core::objectmodel::BaseObject * object)
virtual
void
onBeginAddSlave
(core::objectmodel::BaseObject * master, core::objectmodel::BaseObject * slave)
virtual
void
onBeginRemoveSlave
(core::objectmodel::BaseObject * master, core::objectmodel::BaseObject * slave)
virtual
void
onEndAddChild
(Node * parent, Node * child)
virtual
void
onEndRemoveChild
(Node * parent, Node * child)
virtual
void
onEndAddObject
(Node * parent, core::objectmodel::BaseObject * object)
virtual
void
onEndRemoveObject
(Node * parent, core::objectmodel::BaseObject * object)
virtual
void
onEndAddSlave
(core::objectmodel::BaseObject * master, core::objectmodel::BaseObject * slave)
virtual
void
onEndRemoveSlave
(core::objectmodel::BaseObject * master, core::objectmodel::BaseObject * slave)
virtual
{
"name": "MutationListener",
"namespace": "sofa::simulation",
"module": "Sofa.framework.Simulation.Core",
"include": "sofa/simulation/MutationListener.h",
"doc": "Generic API to handle mutations of the graph",
"inherits": [],
"templates": [],
"data_fields": [],
"links": [],
"methods": [
{
"name": "sleepChanged",
"return_type": "void",
"params": [
{
"name": "node",
"type": "Node *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "onBeginAddChild",
"return_type": "void",
"params": [
{
"name": "parent",
"type": "Node *"
},
{
"name": "child",
"type": "Node *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "onBeginRemoveChild",
"return_type": "void",
"params": [
{
"name": "parent",
"type": "Node *"
},
{
"name": "child",
"type": "Node *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "onBeginAddObject",
"return_type": "void",
"params": [
{
"name": "parent",
"type": "Node *"
},
{
"name": "object",
"type": "core::objectmodel::BaseObject *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "onBeginRemoveObject",
"return_type": "void",
"params": [
{
"name": "parent",
"type": "Node *"
},
{
"name": "object",
"type": "core::objectmodel::BaseObject *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "onBeginAddSlave",
"return_type": "void",
"params": [
{
"name": "master",
"type": "core::objectmodel::BaseObject *"
},
{
"name": "slave",
"type": "core::objectmodel::BaseObject *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "onBeginRemoveSlave",
"return_type": "void",
"params": [
{
"name": "master",
"type": "core::objectmodel::BaseObject *"
},
{
"name": "slave",
"type": "core::objectmodel::BaseObject *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "onEndAddChild",
"return_type": "void",
"params": [
{
"name": "parent",
"type": "Node *"
},
{
"name": "child",
"type": "Node *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "onEndRemoveChild",
"return_type": "void",
"params": [
{
"name": "parent",
"type": "Node *"
},
{
"name": "child",
"type": "Node *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "onEndAddObject",
"return_type": "void",
"params": [
{
"name": "parent",
"type": "Node *"
},
{
"name": "object",
"type": "core::objectmodel::BaseObject *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "onEndRemoveObject",
"return_type": "void",
"params": [
{
"name": "parent",
"type": "Node *"
},
{
"name": "object",
"type": "core::objectmodel::BaseObject *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "onEndAddSlave",
"return_type": "void",
"params": [
{
"name": "master",
"type": "core::objectmodel::BaseObject *"
},
{
"name": "slave",
"type": "core::objectmodel::BaseObject *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "onEndRemoveSlave",
"return_type": "void",
"params": [
{
"name": "master",
"type": "core::objectmodel::BaseObject *"
},
{
"name": "slave",
"type": "core::objectmodel::BaseObject *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
}
],
"description": "The `MutationListener` is a class in the `sofa::simulation` namespace within the `Sofa.framework.Simulation.Core` module, designed to handle mutations (changes) in the simulation graph structure. It provides callbacks for various events related to adding or removing nodes and objects within the scene graph.\n\n### Role and Purpose\nThis component serves as a generic API to manage changes such as adding or removing child nodes, objects, and slave objects. It allows developers to react to these mutations by implementing specific methods that are called at different stages of mutation events.\n\n### Interactions with Other Components\n- **Node**: The `MutationListener` interacts directly with the scene graph's nodes (`Node`) when changes occur in the hierarchy (additions/removals).\n- **BaseObject**: It also works with individual objects within the simulation, allowing callbacks for object-related mutations.\n\n### Methods and Usage Guidance\nThe methods provided by `MutationListener` are virtual and must be implemented by derived classes to handle specific mutation events:\n- `sleepChanged`: Called when the sleep state of a node changes.\n- `onBeginAddChild`, `onEndAddChild`: Called before and after adding a child node to a parent node.\n- `onBeginRemoveChild`, `onEndRemoveChild`: Called before and after removing a child node from a parent node.\n- `onBeginAddObject`, `onEndAddObject`: Called before and after adding an object to a node.\n- `onBeginRemoveObject`, `onEndRemoveObject`: Called before and after removing an object from a node.\n- `onBeginAddSlave`, `onEndAddSlave`: Called before and after adding a slave object to a master object.\n- `onBeginRemoveSlave`, `onEndRemoveSlave`: Called before and after removing a slave object from a master object.\n\nDerived classes can override these methods to perform custom actions in response to graph mutations, such as updating visual representations or managing additional simulation data.",
"maths": "The `MutationListener` class in the SOFA framework is primarily responsible for handling structural changes within the simulation graph, but it does not directly contribute to any governing equations or operators related to FEM simulation. Instead, its role is more about providing a mechanism to react to mutations such as adding or removing nodes and objects within the scene graph.\n\n### Mathematical and Physical Description:\n\n- **Governing Equations / Operators**: The `MutationListener` does not implement or contribute to any governing equations (e.g., mass matrix \\(M\\), stiffness matrix \\(K\\), internal force \\(f_{int}\\), residual \\(R\\)) directly. It is an API designed for event handling.\n\n- **Constitutive / Kinematic Laws**: The component does not define or involve any constitutive laws (strain measures, stress tensors, hyperelastic potentials) or kinematic relations. Its purpose is to provide callbacks that can be used by other components to react to structural changes in the graph.\n\n- **Role in FEM Pipeline**: `MutationListener` plays no direct role in assembly, time integration, nonlinear solve, linear solve, constraint handling, mapping, etc., as these are handled by other specific components within SOFA. Instead, it acts as a framework for ensuring that custom actions can be performed when the graph structure changes.\n\n- **Numerical Methods / Discretization Choices**: The `MutationListener` does not encode any numerical methods or discretization choices related to FEM simulation. Its primary function is to provide hooks (methods) that can be overridden by derived classes to perform specific tasks during mutation events.\n\n- **Integration into Variational / Lagrangian Mechanics Framework**: The component fits into the broader framework by enabling developers to implement custom behavior in response to changes in the scene graph structure, which might indirectly influence other components involved in variational or Lagrangian mechanics. However, it does not directly participate in the mathematical formulation of the simulation.\n\n### Summary:\nThe `MutationListener` is a pure API component that provides callbacks for handling structural mutations within the SOFA simulation framework. It does not contribute to any specific FEM equations or operators and is primarily used for event-driven reactions to changes in the scene graph.",
"abstract": "`MutationListener` handles structural changes within the SOFA scene graph by providing callbacks for various mutation events.",
"sheet": "# MutationListener\n\n**Overview**\n\nThe `MutationListener` is a class in the `sofa::simulation` namespace designed to manage mutations (changes) in the simulation graph structure. It provides virtual methods that can be overridden by derived classes to handle specific mutation events, such as adding or removing nodes and objects within the scene graph.\n\n**Dependencies and Connections**\n\nThe `MutationListener` interacts directly with the scene graph's nodes (`Node`) when changes occur in the hierarchy (additions/removals). It also works with individual objects within the simulation, allowing callbacks for object-related mutations. Derived classes can override these methods to perform custom actions in response to graph mutations."
}