Back

AbstractDataLink

sofa::core::objectmodel::AbstractDataLink
Doc (from source)

AbstractDataLink is the base class for every link between two data fields The targeted BaseData is called the "target", The base object owning the current "child" object is the "owner" it is possible to store a path in a DataLink, in that case, at each DataLink access the path is resolved to search for a corresponding Data until one is found. Once a Data is set, the path is discarded.

Abstract (AI generated)

AbstractDataLink establishes connections (links) between two `BaseData` fields in SOFA's object model, supporting dynamic resolution of targets via stored paths.

Metadata
module
Sofa.framework.Core
namespace
sofa::core::objectmodel
include
sofa/core/objectmodel/AbstractDataLink.h
description

Mathematical and Physical Description of AbstractDataLink

AbstractDataLink is not directly involved in mathematical or physical operations within the SOFA framework. Instead, it serves as a foundational class for managing connections (links) between two data fields (BaseData objects). This class facilitates dynamic resolution of links based on paths defined during runtime.

Role and Functionality

  • Connection Management: AbstractDataLink establishes a one-to-one relationship between a BaseData object and its target. The owner of the link (a BaseData) can be queried using the method getOwner(), ensuring that each instance of AbstractDataLink has exactly one corresponding BaseData.

  • Target Resolution: Methods such as setTarget(BaseData* target) allow setting a direct target for the data field. The methods resolvePathAndSetTarget() and resolvePathAndGetTarget() dynamically resolve paths to find the appropriate BaseData target, facilitating flexible connections that can be updated at runtime.

  • Path Handling: Paths are used to indirectly specify targets through hierarchical or indirect references. Once a path is resolved successfully, it sets the target directly using setTarget, and the path information is discarded to streamline subsequent accesses.

Key Methods and Operations

  • getOwner() returns the owning BaseData object.

  • setTarget(BaseData* target): Changes the targeted data field and clears any stored path.

  • getTarget(): Retrieves the currently set target data field. If no direct target is set, it attempts to resolve a previously defined path.

  • hasTarget(): Returns whether there is an explicitly set target (BaseData* != nullptr).

  • Path Resolution:

  • resolvePathAndSetTarget(): Attempts to find and set the target based on a stored path, returning true if successful.
  • resolvePathAndGetTarget(): Similar to resolvePathAndSetTarget, but returns the resolved target directly.
  • setPath(const std::string& path): Sets the path and attempts immediate resolution using resolvePathAndSetTarget.

Inheritance and Virtual Methods

Subclasses must implement three virtual methods:
- _doGetOwner_()
- _doGetTarget_()
- _doSetTarget_(BaseData* target)
These ensure proper management of the underlying data links by the concrete subclasses.

Conclusion

AbstractDataLink is a critical class for managing connections and resolving paths within SOFA’s object model. Its primary role is to facilitate dynamic linking between data fields, enabling flexible and adaptable configurations of the simulation framework. While not directly involved in mathematical or physical computations, it underpins the structure required for such operations by ensuring that data can be dynamically connected as needed.

Methods
const BaseData & getOwner ()
void setTarget (BaseData * target)
BaseData * getTarget ()
bool hasTarget ()
const int getPath ()
void setPath (const int & path)
bool hasPath ()
bool resolvePathAndSetTarget ()
BaseData * resolvePathAndGetTarget ()
{
  "name": "AbstractDataLink",
  "namespace": "sofa::core::objectmodel",
  "module": "Sofa.framework.Core",
  "include": "sofa/core/objectmodel/AbstractDataLink.h",
  "doc": "AbstractDataLink is the base class for every link between two data fields\nThe targeted BaseData is called the \"target\",\nThe base object owning the current \"child\" object is the \"owner\"\nit is possible to store a path in a DataLink, in that case, at each DataLink access\nthe path is resolved to search for a corresponding Data until one is found.\nOnce a Data is set, the path is discarded.",
  "inherits": [],
  "templates": [],
  "data_fields": [],
  "links": [],
  "methods": [
    {
      "name": "getOwner",
      "return_type": "const BaseData &",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setTarget",
      "return_type": "void",
      "params": [
        {
          "name": "target",
          "type": "BaseData *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getTarget",
      "return_type": "BaseData *",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "hasTarget",
      "return_type": "bool",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getPath",
      "return_type": "const int",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setPath",
      "return_type": "void",
      "params": [
        {
          "name": "path",
          "type": "const int &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "hasPath",
      "return_type": "bool",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "resolvePathAndSetTarget",
      "return_type": "bool",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "resolvePathAndGetTarget",
      "return_type": "BaseData *",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    }
  ],
  "description": "AbstractDataLink is the base class for all links between two data fields in SOFA's object model. It establishes connections (links) from one `BaseData` field to another, referred to as the \"target.\" The owner of the link is defined by a one-to-one relationship with a `BaseData` object. Additionally, AbstractDataLink supports storing paths for resolving targets dynamically at each access.\n\nThis class provides methods to set and retrieve the target (`setTarget`, `getTarget`), check if there's a current target (`hasTarget`), manage path resolution for indirect links (`getPath`, `setPath`, `resolvePathAndSetTarget`, `resolvePathAndGetTarget`), and verify if a path is set (`hasPath`).\n\nSubclasses must implement the virtual methods `_doGetOwner_`, `_doGetTarget_`, and `_doSetTarget_`. These methods ensure proper storage and retrieval of target data fields. The functionality ensures that once a Data link is resolved, the path information is discarded.",
  "maths": "### Mathematical and Physical Description of AbstractDataLink\n\n**AbstractDataLink** is not directly involved in mathematical or physical operations within the SOFA framework. Instead, it serves as a foundational class for managing connections (links) between two data fields (`BaseData` objects). This class facilitates dynamic resolution of links based on paths defined during runtime.\n\n#### Role and Functionality\n- **Connection Management**: AbstractDataLink establishes a one-to-one relationship between a `BaseData` object and its target. The owner of the link (a `BaseData`) can be queried using the method `getOwner()`, ensuring that each instance of `AbstractDataLink` has exactly one corresponding `BaseData`.\n\n- **Target Resolution**: Methods such as `setTarget(BaseData* target)` allow setting a direct target for the data field. The methods `resolvePathAndSetTarget()` and `resolvePathAndGetTarget()` dynamically resolve paths to find the appropriate `BaseData` target, facilitating flexible connections that can be updated at runtime.\n\n- **Path Handling**: Paths are used to indirectly specify targets through hierarchical or indirect references. Once a path is resolved successfully, it sets the target directly using `setTarget`, and the path information is discarded to streamline subsequent accesses.\n\n#### Key Methods and Operations\n- **`getOwner()`** returns the owning `BaseData` object.\n\n- **`setTarget(BaseData* target)`**: Changes the targeted data field and clears any stored path.\n\n- **`getTarget()`**: Retrieves the currently set target data field. If no direct target is set, it attempts to resolve a previously defined path.\n\n- **`hasTarget()`**: Returns whether there is an explicitly set target (`BaseData* != nullptr`).\n\n- **Path Resolution**:\n  - `resolvePathAndSetTarget()`: Attempts to find and set the target based on a stored path, returning true if successful.\n  - `resolvePathAndGetTarget()`: Similar to `resolvePathAndSetTarget`, but returns the resolved target directly.\n  - `setPath(const std::string& path)`: Sets the path and attempts immediate resolution using `resolvePathAndSetTarget`.\n\n#### Inheritance and Virtual Methods\nSubclasses must implement three virtual methods:\n- `_doGetOwner_()`\n- `_doGetTarget_()`\n- `_doSetTarget_(BaseData* target)`\nThese ensure proper management of the underlying data links by the concrete subclasses.\n\n### Conclusion\nAbstractDataLink is a critical class for managing connections and resolving paths within SOFA’s object model. Its primary role is to facilitate dynamic linking between data fields, enabling flexible and adaptable configurations of the simulation framework. While not directly involved in mathematical or physical computations, it underpins the structure required for such operations by ensuring that data can be dynamically connected as needed.",
  "abstract": "AbstractDataLink establishes connections (links) between two `BaseData` fields in SOFA's object model, supporting dynamic resolution of targets via stored paths.",
  "sheet": "# AbstractDataLink\n\n**Overview:**\n\nAbstractDataLink is the base class for managing links between data fields (`BaseData`) within SOFA’s object model. It enables setting and resolving target connections dynamically using stored paths. The primary methods include `setTarget`, `getTarget`, `resolvePathAndSetTarget`, and `resolvePathAndGetTarget`. Once a path resolves to a target, the path information is discarded."
}