SOFA API  b5aefb45
Open source framework for multi-physics simuation
sofa::core::objectmodel::BaseLink Class Referenceabstract

#include <BaseLink.h>

Abstract base class for all links in the scene grapn, independently of their type. More...

Inheritance diagram for sofa::core::objectmodel::BaseLink:

Detailed Description

Abstract base class for all links in the scene grapn, independently of their type.

Classes

class  BaseInitLink
 This internal class is used by the initLink() methods to store initialization parameters of a Data. More...
 
class  InitLink
 This internal class is used by the initLink() methods to store initialization parameters of a Data. More...
 

Public Member Functions

 BaseLink (LinkFlags flags)
 
 BaseLink (const BaseInitLink &init, LinkFlags flags)
 
virtual ~BaseLink ()
 
const std::string & getName () const
 
void setName (const std::string &name)
 
const std::string & getHelp () const
 Get help message. More...
 
void setHelp (const std::string &val)
 Set help message. More...
 
virtual BasegetOwnerBase () const =0
 
void setFlag (LinkFlagsEnum flag, bool b)
 Set one of the flags. More...
 
bool getFlag (LinkFlagsEnum flag) const
 Get one flag. More...
 
bool isMultiLink () const
 
bool isStrongLink () const
 
bool isDoubleLink () const
 
bool isDuplicate () const
 
bool storePath () const
 
void setPersistent (bool b)
 Alias to match BaseData API. More...
 
bool isPersistent () const
 
bool isReadOnly () const
 Alias to match BaseData API. More...
 
virtual const BaseClassgetDestClass () const =0
 
virtual const BaseClassgetOwnerClass () const =0
 
int getCounter () const
 
void setLinkedBase (Base *link)
 
virtual size_t getSize () const =0
 
BasegetLinkedBase (std::size_t index=0) const
 
void clear ()
 
std::string getLinkedPath (const std::size_t index=0) const
 
std::string getPath (std::size_t index=0) const
 
Serialization API
bool read (const std::string &str)
 Read the command line. More...
 
bool updateLinks ()
 
virtual void printValue (std::ostream &) const
 Print the value of the associated variable. More...
 
virtual std::string getValueString () const
 Print the value of the associated variable. More...
 
virtual std::string getValueTypeString () const
 Print the value type of the associated variable. More...
 

Serialization Helper API

unsigned int m_flags
 
std::string m_name
 
std::string m_help
 
int m_counter
 Number of changes since creation. More...
 
bool parseString (const std::string &text, std::string *path, std::string *data=nullptr) const
 
BasegetOwner () const
 
void setOwner (Base *owner)
 
bool add (Base *baseptr, const std::string &path)
 Add a new target to the link. More...
 
bool set (Base *baseptr, size_t index=0)
 Change the link's target at the provided index. More...
 
static bool ParseString (const std::string &text, std::string *path, std::string *data=nullptr, Base *start=nullptr)
 
static std::string CreateString (const std::string &path, const std::string &data="")
 
static std::string CreateStringPath (Base *object, Base *from)
 
static std::string CreateStringData (BaseData *data)
 
static std::string CreateString (Base *object, Base *from)
 
static std::string CreateString (BaseData *data, Base *from)
 
static std::string CreateString (Base *object, BaseData *data, Base *from)
 
void updateCounter ()
 

Attribute details

◆ m_counter

int sofa::core::objectmodel::BaseLink::m_counter
protected

Number of changes since creation.

◆ m_flags

unsigned int sofa::core::objectmodel::BaseLink::m_flags
protected

◆ m_help

std::string sofa::core::objectmodel::BaseLink::m_help
protected

◆ m_name

std::string sofa::core::objectmodel::BaseLink::m_name
protected

Constructor details

◆ BaseLink() [1/2]

sofa::core::objectmodel::BaseLink::BaseLink ( LinkFlags  flags)

◆ BaseLink() [2/2]

sofa::core::objectmodel::BaseLink::BaseLink ( const BaseInitLink init,
LinkFlags  flags 
)

◆ ~BaseLink()

sofa::core::objectmodel::BaseLink::~BaseLink ( )
virtual

Function details

◆ add()

bool sofa::core::objectmodel::BaseLink::add ( Base baseptr,
const std::string &  path 
)
inline

Add a new target to the link.

◆ clear()

void sofa::core::objectmodel::BaseLink::clear ( )
inline

◆ CreateString() [1/4]

std::string sofa::core::objectmodel::BaseLink::CreateString ( Base object,
Base from 
)
static

◆ CreateString() [2/4]

std::string sofa::core::objectmodel::BaseLink::CreateString ( Base object,
BaseData data,
Base from 
)
static

◆ CreateString() [3/4]

std::string sofa::core::objectmodel::BaseLink::CreateString ( BaseData data,
Base from 
)
static

◆ CreateString() [4/4]

std::string sofa::core::objectmodel::BaseLink::CreateString ( const std::string &  path,
const std::string &  data = "" 
)
static

◆ CreateStringData()

std::string sofa::core::objectmodel::BaseLink::CreateStringData ( BaseData data)
static

◆ CreateStringPath()

std::string sofa::core::objectmodel::BaseLink::CreateStringPath ( Base object,
Base from 
)
static

◆ getCounter()

int sofa::core::objectmodel::BaseLink::getCounter ( ) const
inline

Return the number of changes since creation This can be used to efficiently detect changes

◆ getDestClass()

◆ getFlag()

bool sofa::core::objectmodel::BaseLink::getFlag ( LinkFlagsEnum  flag) const
inline

Get one flag.

◆ getHelp()

const std::string& sofa::core::objectmodel::BaseLink::getHelp ( ) const
inline

Get help message.

◆ getLinkedBase()

Base* sofa::core::objectmodel::BaseLink::getLinkedBase ( std::size_t  index = 0) const
inline

◆ getLinkedPath()

std::string sofa::core::objectmodel::BaseLink::getLinkedPath ( const std::size_t  index = 0) const

◆ getName()

const std::string& sofa::core::objectmodel::BaseLink::getName ( ) const
inline

◆ getOwner()

Base* sofa::core::objectmodel::BaseLink::getOwner ( ) const
inline

◆ getOwnerBase()

◆ getOwnerClass()

◆ getPath()

std::string sofa::core::objectmodel::BaseLink::getPath ( std::size_t  index = 0) const
inline

◆ getSize()

◆ getValueString()

std::string sofa::core::objectmodel::BaseLink::getValueString ( ) const
virtual

Print the value of the associated variable.

◆ getValueTypeString()

std::string sofa::core::objectmodel::BaseLink::getValueTypeString ( ) const
virtual

Print the value type of the associated variable.

◆ isDoubleLink()

bool sofa::core::objectmodel::BaseLink::isDoubleLink ( ) const
inline

◆ isDuplicate()

bool sofa::core::objectmodel::BaseLink::isDuplicate ( ) const
inline

◆ isMultiLink()

bool sofa::core::objectmodel::BaseLink::isMultiLink ( ) const
inline

◆ isPersistent()

bool sofa::core::objectmodel::BaseLink::isPersistent ( ) const
inline

◆ isReadOnly()

bool sofa::core::objectmodel::BaseLink::isReadOnly ( ) const
inline

Alias to match BaseData API.

◆ isStrongLink()

bool sofa::core::objectmodel::BaseLink::isStrongLink ( ) const
inline

◆ parseString()

bool sofa::core::objectmodel::BaseLink::parseString ( const std::string &  text,
std::string *  path,
std::string *  data = nullptr 
) const
inline

◆ ParseString()

bool sofa::core::objectmodel::BaseLink::ParseString ( const std::string &  text,
std::string *  path,
std::string *  data = nullptr,
Base start = nullptr 
)
static

◆ printValue()

void sofa::core::objectmodel::BaseLink::printValue ( std::ostream &  o) const
virtual

Print the value of the associated variable.

◆ read()

bool sofa::core::objectmodel::BaseLink::read ( const std::string &  str)

Read the command line.

Returns false if:

  • one or multiple string entries fails to be read. In this case the valid link address are initialized.
  • the owner is invalid Returns true if:
  • string is empty
  • all the linkpath are leading to a valid object or not available there.

◆ set()

bool sofa::core::objectmodel::BaseLink::set ( Base baseptr,
size_t  index = 0 
)
inline

Change the link's target at the provided index.

◆ setFlag()

void sofa::core::objectmodel::BaseLink::setFlag ( LinkFlagsEnum  flag,
bool  b 
)
inline

Set one of the flags.

◆ setHelp()

void sofa::core::objectmodel::BaseLink::setHelp ( const std::string &  val)
inline

Set help message.

◆ setLinkedBase()

void sofa::core::objectmodel::BaseLink::setLinkedBase ( Base link)

◆ setName()

void sofa::core::objectmodel::BaseLink::setName ( const std::string &  name)
inline

◆ setOwner()

void sofa::core::objectmodel::BaseLink::setOwner ( Base owner)
inline

◆ setPersistent()

void sofa::core::objectmodel::BaseLink::setPersistent ( bool  b)
inline

Alias to match BaseData API.

◆ storePath()

bool sofa::core::objectmodel::BaseLink::storePath ( ) const
inline

◆ updateCounter()

void sofa::core::objectmodel::BaseLink::updateCounter ( )
inlineprotected

◆ updateLinks()

bool sofa::core::objectmodel::BaseLink::updateLinks ( )

Update pointers in case the pointed-to objects have appeared

Returns
false if there are broken links

Enum details

◆ LinkFlagsEnum

Enumerator
FLAG_NONE 
FLAG_MULTILINK 

True if link is an array.

FLAG_STRONGLINK 

True if link has ownership of linked object(s)

FLAG_DOUBLELINK 

True if link has a reciprocal link in linked object(s)

FLAG_DUPLICATE 

True if link duplicates another one (possibly with a different/specialized DestType)

FLAG_STOREPATH 

True if link requires a path string in order to be created.