SOFA API  cd4ffb93
Open source framework for multi-physics simuation
sofa::core::objectmodel::AbstractDataLink Class Reference

#include <AbstractDataLink.h>

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. More...

Inheritance diagram for sofa::core::objectmodel::AbstractDataLink:

Detailed Description

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.

Protected Attributes

std::string m_path {""}
 

Public Member Functions

const BaseDatagetOwner () const
 
void setTarget (BaseData *target)
 Change the targeted DataField and set the path to the empty string. More...
 
BaseDatagetTarget () const
 Get the targeted DataField. More...
 
bool hasTarget () const
 Returns true if there is a target. More...
 
const std::string getPath () const
 Get the path (is any) More...
 
void setPath (const std::string &path)
 Set the path, try to resolve it, on success set the DataField. More...
 
bool hasPath () const
 Returns true if the path is set (and thus getTarget() == nullptr) More...
 
bool resolvePathAndSetTarget ()
 
BaseDataresolvePathAndGetTarget ()
 

Attribute details

◆ m_path

std::string sofa::core::objectmodel::AbstractDataLink::m_path {""}
protected

Function details

◆ getOwner()

const BaseData & sofa::core::objectmodel::AbstractDataLink::getOwner ( ) const

Returns the BaseData object that this DataLink belong to. There is a one to one owner relationship. A BaseData have one and only one DataLink object. A DataLink object has one and only one BaseData as owner.

Get the DataField having thins link as an attribute there is a one to one owner relationship.

◆ getPath()

const std::string sofa::core::objectmodel::AbstractDataLink::getPath ( ) const

Get the path (is any)

◆ getTarget()

BaseData * sofa::core::objectmodel::AbstractDataLink::getTarget ( ) const

Get the targeted DataField.

◆ hasPath()

bool sofa::core::objectmodel::AbstractDataLink::hasPath ( ) const

Returns true if the path is set (and thus getTarget() == nullptr)

◆ hasTarget()

bool sofa::core::objectmodel::AbstractDataLink::hasTarget ( ) const

Returns true if there is a target.

◆ resolvePathAndGetTarget()

BaseData * sofa::core::objectmodel::AbstractDataLink::resolvePathAndGetTarget ( )

Get the targeted DataField If there is no path set, returns nullptr If there is no owner set, returns nullptr If there is no compatible Data at pointed path, returns nullptr Otherwise, returns pointed target.

◆ resolvePathAndSetTarget()

bool sofa::core::objectmodel::AbstractDataLink::resolvePathAndSetTarget ( )

Search for the Data pointed by the path (if any). If there is no path set, returns false If there is no owner set, returns false If there is no compatible Data at pointed path, returns false Otherwise, returns true. After a successful call, the path is set to empty string.

◆ setPath()

void sofa::core::objectmodel::AbstractDataLink::setPath ( const std::string &  path)

Set the path, try to resolve it, on success set the DataField.

◆ setTarget()

void sofa::core::objectmodel::AbstractDataLink::setTarget ( BaseData target)

Change the targeted DataField and set the path to the empty string.

Change the targeted DataField.