SOFA API  1e111313
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 targetted 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 targetted 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 targetted DataField and set the path to the empty string. More...
 
BaseDatagetTarget () const
 Get the targetted 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

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

Function details

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.

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

Get the path (is any)

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

Get the targetted DataField.

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

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

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

Returns true if there is a target.

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

Get the targetted 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.

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 successfull call, the path is set to empty string.

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

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

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

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

Change the targetted DataField.