Back

DataExchange

The `DataExchange` component is part of the MultiThreading plugin in SOFA and is designed for data memory sharing within multi-threading applications. This component facilitates copying data from one object to another, ensuring synchronization between threads by leveraging events. ### Key Features: - **Data Copying:** The primary function of `DataExchange` is to copy data from a source (`mSource`) to a destination (`mDestination`). - **Event Handling:** It responds to specific events (e.g., `DataExchangeEvent`) to trigger the copying process, ensuring that changes are synchronized across threads. ### Templates and Instantiations: `DataExchange` is implemented as a template class that can handle various data types such as vectors of 3D/2D vectors (`Vec3d`, `Vec3f`), doubles, floats, integers, and booleans. The component supports instantiation for these types to provide flexibility in handling different kinds of data. ### Data Initialization: - **Initialization:** During initialization (`init()` method), it checks if both source and destination objects have valid parents. If so, it sets up the necessary attributes and calls `copyData()` to perform an initial copy. - **Dynamic Casting:** The `handleEvent()` method uses dynamic casting to check for a specific event type and triggers data copying accordingly. ### Usage: This component is typically used in scenarios where multiple threads need to access or modify shared data. By ensuring that the source and destination are properly synchronized, it helps maintain consistency across different parts of an application running on multiple threads.

abstract
The `DataExchange` component in SOFA's MultiThreading plugin ensures data memory sharing and synchronization between objects in multi-threading applications by copying data from a source to a destination object.
sheet
# DataExchange ## Overview The `DataExchange` component is part of the MultiThreading plugin in SOFA, designed for data memory sharing within multi-threading applications. It facilitates copying data from a source (`mSource`) to a destination (`mDestination`) object and handles events to trigger synchronization. ## Parameters and Data - **mSource**: The source object to copy (type: `DataTypes`, xmlname: `from`). - **mDestination**: The destination object to copy (type: `DataTypes`, xmlname: `to`).
description
The `DataExchange` component is part of the MultiThreading plugin in SOFA and is designed for data memory sharing within multi-threading applications. This component facilitates copying data from one object to another, ensuring synchronization between threads by leveraging events. ### Key Features: - **Data Copying:** The primary function of `DataExchange` is to copy data from a source (`mSource`) to a destination (`mDestination`). - **Event Handling:** It responds to specific events (e.g., `DataExchangeEvent`) to trigger the copying process, ensuring that changes are synchronized across threads. ### Templates and Instantiations: `DataExchange` is implemented as a template class that can handle various data types such as vectors of 3D/2D vectors (`Vec3d`, `Vec3f`), doubles, floats, integers, and booleans. The component supports instantiation for these types to provide flexibility in handling different kinds of data. ### Data Initialization: - **Initialization:** During initialization (`init()` method), it checks if both source and destination objects have valid parents. If so, it sets up the necessary attributes and calls `copyData()` to perform an initial copy. - **Dynamic Casting:** The `handleEvent()` method uses dynamic casting to check for a specific event type and triggers data copying accordingly. ### Usage: This component is typically used in scenarios where multiple threads need to access or modify shared data. By ensuring that the source and destination are properly synchronized, it helps maintain consistency across different parts of an application running on multiple threads.
maths
The `DataExchange` component in the MultiThreading plugin of SOFA is designed for data synchronization across multiple threads. It facilitates copying data from one object to another, ensuring that shared resources are consistently updated and synchronized. ### Key Mathematical and Physical Concepts: - **Data Synchronization:** The primary function is to synchronize data between two objects (`mSource` and `mDestination`). This ensures that any modifications made in the source object are reflected in the destination object, maintaining consistency across threads. #### Data Copying Mechanism: - **Copy Operation:** The `copyData()` method performs the actual copying of data from `mSource` to `mDestination`. Mathematically, this can be represented as follows: Let \( D_s \) represent the data in the source object and \( D_d \) represent the data in the destination object. The operation is defined by: \[ D_d = D_s \] - **Event Handling:** `DataExchange` responds to specific events, such as `DataExchangeEvent`, which triggers the copying process. This ensures that any changes made are synchronized across different threads. #### Initialization and Setup: - **Initialization (`init()`):** During initialization, the component checks if both source and destination objects have valid parents (i.e., they are part of a larger object hierarchy). If so, it sets up the necessary attributes and performs an initial data copy using `copyData()`. This step ensures that any pre-existing state is synchronized before any thread-specific modifications. - **Dynamic Casting (`handleEvent()`):** The `handleEvent()` method dynamically casts incoming events to determine if they are of type `DataExchangeEvent`. If so, it triggers the copying process by calling `copyData()`, ensuring that changes are propagated appropriately. ### Templates and Instantiations: `DataExchange` is implemented as a template class, supporting various data types such as vectors of 3D/2D vectors (`Vec3d`, `Vec3f`), doubles, floats, integers, and booleans. This flexibility allows it to handle different kinds of data while maintaining the same synchronization logic. ### Usage in Multi-Threading Scenarios: In multi-threading scenarios, ensuring that shared resources are consistently updated is crucial for preventing race conditions and maintaining the integrity of the simulation or application state. `DataExchange` facilitates this by providing a mechanism to synchronize changes made across different threads, thereby enabling efficient and consistent data sharing. #### Summary: The `DataExchange` component plays a critical role in synchronizing data between objects within multi-threaded applications. By ensuring that modifications are consistently propagated, it helps maintain the integrity of shared resources and enables effective collaboration between multiple threads.
{
  "name": "DataExchange",
  "main": {
    "name": "DataExchange",
    "namespace": "sofa::core",
    "module": "MultiThreading",
    "include": "MultiThreading/DataExchange.h",
    "doc": "Component for data memory sharing in the context of multi-threading applications",
    "inherits": [
      "BaseObject"
    ],
    "templates": [
      "bool",
      "double",
      "float",
      "sofa::type::Vec3d",
      "sofa::type::Vec3f"
    ],
    "data_fields": [
      {
        "name": "mSource",
        "type": "DataTypes",
        "xmlname": "from",
        "help": "source object to copy"
      },
      {
        "name": "mDestination",
        "type": "DataTypes",
        "xmlname": "to",
        "help": "destination object to copy"
      }
    ],
    "links": [],
    "methods": [
      {
        "name": "copyData",
        "return_type": "void",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "init",
        "return_type": "void",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "handleEvent",
        "return_type": "void",
        "params": [
          {
            "name": "event",
            "type": "core::objectmodel::Event *"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "GetCustomTemplateName",
        "return_type": "int",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": true,
        "access": "public"
      }
    ]
  },
  "desc": {
    "description": "The `DataExchange` component is part of the MultiThreading plugin in SOFA and is designed for data memory sharing within multi-threading applications. This component facilitates copying data from one object to another, ensuring synchronization between threads by leveraging events.\n\n### Key Features:\n- **Data Copying:** The primary function of `DataExchange` is to copy data from a source (`mSource`) to a destination (`mDestination`).\n- **Event Handling:** It responds to specific events (e.g., `DataExchangeEvent`) to trigger the copying process, ensuring that changes are synchronized across threads.\n\n### Templates and Instantiations:\n`DataExchange` is implemented as a template class that can handle various data types such as vectors of 3D/2D vectors (`Vec3d`, `Vec3f`), doubles, floats, integers, and booleans. The component supports instantiation for these types to provide flexibility in handling different kinds of data.\n\n### Data Initialization:\n- **Initialization:** During initialization (`init()` method), it checks if both source and destination objects have valid parents. If so, it sets up the necessary attributes and calls `copyData()` to perform an initial copy.\n- **Dynamic Casting:** The `handleEvent()` method uses dynamic casting to check for a specific event type and triggers data copying accordingly.\n\n### Usage:\nThis component is typically used in scenarios where multiple threads need to access or modify shared data. By ensuring that the source and destination are properly synchronized, it helps maintain consistency across different parts of an application running on multiple threads."
  },
  "maths": {
    "maths": "The `DataExchange` component in the MultiThreading plugin of SOFA is designed for data synchronization across multiple threads. It facilitates copying data from one object to another, ensuring that shared resources are consistently updated and synchronized.\n\n### Key Mathematical and Physical Concepts:\n- **Data Synchronization:** The primary function is to synchronize data between two objects (`mSource` and `mDestination`). This ensures that any modifications made in the source object are reflected in the destination object, maintaining consistency across threads.\n\n#### Data Copying Mechanism:\n- **Copy Operation:** The `copyData()` method performs the actual copying of data from `mSource` to `mDestination`. Mathematically, this can be represented as follows:\n  \n  Let \\( D_s \\) represent the data in the source object and \\( D_d \\) represent the data in the destination object. The operation is defined by:\n\n  \\[ D_d = D_s \\]\n\n- **Event Handling:** `DataExchange` responds to specific events, such as `DataExchangeEvent`, which triggers the copying process. This ensures that any changes made are synchronized across different threads.\n\n#### Initialization and Setup:\n- **Initialization (`init()`):** During initialization, the component checks if both source and destination objects have valid parents (i.e., they are part of a larger object hierarchy). If so, it sets up the necessary attributes and performs an initial data copy using `copyData()`. This step ensures that any pre-existing state is synchronized before any thread-specific modifications.\n\n- **Dynamic Casting (`handleEvent()`):** The `handleEvent()` method dynamically casts incoming events to determine if they are of type `DataExchangeEvent`. If so, it triggers the copying process by calling `copyData()`, ensuring that changes are propagated appropriately.\n\n### Templates and Instantiations:\n`DataExchange` is implemented as a template class, supporting various data types such as vectors of 3D/2D vectors (`Vec3d`, `Vec3f`), doubles, floats, integers, and booleans. This flexibility allows it to handle different kinds of data while maintaining the same synchronization logic.\n\n### Usage in Multi-Threading Scenarios:\nIn multi-threading scenarios, ensuring that shared resources are consistently updated is crucial for preventing race conditions and maintaining the integrity of the simulation or application state. `DataExchange` facilitates this by providing a mechanism to synchronize changes made across different threads, thereby enabling efficient and consistent data sharing.\n\n#### Summary:\nThe `DataExchange` component plays a critical role in synchronizing data between objects within multi-threaded applications. By ensuring that modifications are consistently propagated, it helps maintain the integrity of shared resources and enables effective collaboration between multiple threads."
  },
  "summary": {
    "abstract": "The `DataExchange` component in SOFA's MultiThreading plugin ensures data memory sharing and synchronization between objects in multi-threading applications by copying data from a source to a destination object.",
    "sheet": "# DataExchange\n\n## Overview\n\nThe `DataExchange` component is part of the MultiThreading plugin in SOFA, designed for data memory sharing within multi-threading applications. It facilitates copying data from a source (`mSource`) to a destination (`mDestination`) object and handles events to trigger synchronization.\n\n## Parameters and Data\n\n- **mSource**: The source object to copy (type: `DataTypes`, xmlname: `from`).\n- **mDestination**: The destination object to copy (type: `DataTypes`, xmlname: `to`)."
  }
}