SOFA API  59c939c2
Open source framework for multi-physics simuation
sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT > Class Template Reference

#include <TopologyData.h>

A class for storing topology related data. Automatically manages topology changes. More...

Inheritance diagram for sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >:

Detailed Description

template<class TopologyElementType, class VecT>
class sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >

A class for storing topology related data. Automatically manages topology changes.

This class is a wrapper of class helper::vector that is made to take care transparently of all topology changes that might happen (non exhaustive list: element added, removed, fused, renumbered).

Protected Attributes

sofa::component::topology::TopologyEngineImpl< VecT >::SPtr m_topologicalEngine
 
sofa::core::topology::BaseMeshTopologym_topology
 
sofa::component::topology::TopologyDataHandler< TopologyElementType, VecT > * m_topologyHandler
 
- Protected Attributes inherited from sofa::core::objectmodel::Data< VecT >
ValueType m_value
 Value. More...
 
- Protected Attributes inherited from sofa::core::objectmodel::TData< VecT >
SingleLink< TData< VecT >, TData< VecT >, BaseLink::FLAG_DATALINK|BaseLink::FLAG_DUPLICATE > parentData
 
- Protected Attributes inherited from sofa::core::objectmodel::BaseData
std::string help {""}
 Help message. More...
 
std::string ownerClass {""}
 Owner class. More...
 
std::string group {""}
 group More...
 
std::string widget {""}
 widget More...
 
int m_counter
 Number of changes since creation. More...
 
bool m_isSet
 True if this Data is set, i.e. its value is different from the default value. More...
 
DataFlags m_dataFlags
 Flags indicating the purpose and behaviour of this Data. More...
 
Basem_owner {nullptr}
 Return the Base component owning this Data. More...
 
std::string m_name
 Data name within the Base component. More...
 
SingleLink< BaseData, BaseData, BaseLink::FLAG_STOREPATH|BaseLink::FLAG_DATALINK|BaseLink::FLAG_DUPLICATEparentBaseData
 Parent Data. More...
 
VecLink m_vecLink
 List of links. More...
 
- Protected Attributes inherited from sofa::core::objectmodel::DDGNode
DDGLinkContainer inputs
 
DDGLinkContainer outputs
 

Public Member Functions

 TopologyDataImpl (const typename sofa::core::topology::BaseTopologyData< VecT >::InitData &data)
 Constructor. More...
 
virtual ~TopologyDataImpl ()
 
virtual void createTopologicalEngine (sofa::core::topology::BaseMeshTopology *_topology, sofa::component::topology::TopologyDataHandler< TopologyElementType, VecT > *_topologyHandler, bool deleteHandler=false)
 To create topological engine link to this Data. Pointer to current topology is needed. More...
 
virtual void createTopologicalEngine (sofa::core::topology::BaseMeshTopology *_topology)
 To create topological engine link to this Data. Pointer to current topology is needed. More...
 
void addInputData (sofa::core::objectmodel::BaseData *_data)
 Allow to add additionnal dependencies to others Data. More...
 
void registerTopologicalData ()
 
const value_typeoperator[] (int i) const
 
value_typeoperator[] (int i)
 
void linkToPointDataArray ()
 Link Data to topology arrays. More...
 
void linkToEdgeDataArray ()
 Method used to link Data to edge Data array, using the engine's method. More...
 
void linkToTriangleDataArray ()
 Method used to link Data to triangle Data array, using the engine's method. More...
 
void linkToQuadDataArray ()
 Method used to link Data to quad Data array, using the engine's method. More...
 
void linkToTetrahedronDataArray ()
 Method used to link Data to tetrahedron Data array, using the engine's method. More...
 
void linkToHexahedronDataArray ()
 Method used to link Data to hexahedron Data array, using the engine's method. More...
 
sofa::component::topology::TopologyEngineImpl< VecT > * getTopologicalEngine ()
 
sofa::core::topology::BaseMeshTopologygetTopology ()
 
sofa::component::topology::TopologyDataHandler< TopologyElementType, VecT > * getTopologyHandler ()
 
- Public Member Functions inherited from sofa::core::topology::BaseTopologyData< VecT >
 BaseTopologyData (const sofa::core::objectmodel::BaseData::BaseInitData &init)
 
 BaseTopologyData (const InitData &init)
 
 BaseTopologyData (const char *helpMsg=nullptr, bool isDisplayed=true, bool isReadOnly=false)
 
 BaseTopologyData (const VecT &, const char *helpMsg=nullptr, bool isDisplayed=true, bool isReadOnly=false)
 
virtual void applyCreatePointFunction (const sofa::helper::vector< unsigned int > &)
 Apply adding points elements. More...
 
virtual void applyDestroyPointFunction (const sofa::helper::vector< unsigned int > &)
 Apply removing points elements. More...
 
virtual void applyCreateEdgeFunction (const sofa::helper::vector< unsigned int > &)
 Apply adding edges elements. More...
 
virtual void applyDestroyEdgeFunction (const sofa::helper::vector< unsigned int > &)
 Apply removing edges elements. More...
 
virtual void applyCreateTriangleFunction (const sofa::helper::vector< unsigned int > &)
 Apply adding triangles elements. More...
 
virtual void applyDestroyTriangleFunction (const sofa::helper::vector< unsigned int > &)
 Apply removing triangles elements. More...
 
virtual void applyCreateQuadFunction (const sofa::helper::vector< unsigned int > &)
 Apply adding quads elements. More...
 
virtual void applyDestroyQuadFunction (const sofa::helper::vector< unsigned int > &)
 Apply removing quads elements. More...
 
virtual void applyCreateTetrahedronFunction (const sofa::helper::vector< unsigned int > &)
 Apply adding tetrahedra elements. More...
 
virtual void applyDestroyTetrahedronFunction (const sofa::helper::vector< unsigned int > &)
 Apply removing tetrahedra elements. More...
 
virtual void applyCreateHexahedronFunction (const sofa::helper::vector< unsigned int > &)
 Apply adding hexahedra elements. More...
 
virtual void applyDestroyHexahedronFunction (const sofa::helper::vector< unsigned int > &)
 Apply removing hexahedra elements. More...
 
virtual void add (unsigned int, const sofa::helper::vector< sofa::helper::vector< unsigned int > > &, const sofa::helper::vector< sofa::helper::vector< SReal > > &)
 Add some values. Values are added at the end of the vector. More...
 
virtual void add (unsigned int, const sofa::helper::vector< sofa::helper::fixed_array< unsigned int, 2 > > &, const sofa::helper::vector< sofa::helper::vector< unsigned int > > &, const sofa::helper::vector< sofa::helper::vector< SReal > > &)
 
virtual void add (unsigned int, const sofa::helper::vector< sofa::helper::fixed_array< unsigned int, 3 > > &, const sofa::helper::vector< sofa::helper::vector< unsigned int > > &, const sofa::helper::vector< sofa::helper::vector< SReal > > &)
 add Triangle More...
 
virtual void add (unsigned int, const sofa::helper::vector< sofa::helper::fixed_array< unsigned int, 4 > > &, const sofa::helper::vector< sofa::helper::vector< unsigned int > > &, const sofa::helper::vector< sofa::helper::vector< SReal > > &)
 add Quad & Tetrahedron More...
 
virtual void add (unsigned int, const sofa::helper::vector< sofa::helper::fixed_array< unsigned int, 8 > > &, const sofa::helper::vector< sofa::helper::vector< unsigned int > > &, const sofa::helper::vector< sofa::helper::vector< SReal > > &)
 add Hexahedron More...
 
virtual void remove (const sofa::helper::vector< unsigned int > &)
 Remove the values corresponding to the points removed. More...
 
virtual void swap (unsigned int, unsigned int)
 Swaps values at indices i1 and i2. More...
 
virtual void renumber (const sofa::helper::vector< unsigned int > &)
 Reorder the values. More...
 
virtual void move (const sofa::helper::vector< unsigned int > &, const sofa::helper::vector< sofa::helper::vector< unsigned int > > &, const sofa::helper::vector< sofa::helper::vector< SReal > > &)
 Move a list of points. More...
 
- Public Member Functions inherited from sofa::core::objectmodel::Data< VecT >
bool operator== (const VecT &value) const
 
bool operator!= (const VecT &value) const
 
void operator= (const VecT &value)
 
virtual BaseDatagetNewInstance ()
 
 Data (const BaseData::BaseInitData &init)
 
 Data (const InitData &init)
 
 Data (const char *helpMsg=nullptr, bool isDisplayed=true, bool isReadOnly=false)
 
 Data (const std::string &helpMsg, bool isDisplayed=true, bool isReadOnly=false)
 
 Data (const VecT &value, const char *helpMsg=nullptr, bool isDisplayed=true, bool isReadOnly=false)
 
 Data (const VecT &value, const std::string &helpMsg, bool isDisplayed=true, bool isReadOnly=false)
 
virtual ~Data ()
 Destructor. More...
 
VecT * beginEdit ()
 BeginEdit method if it is only to write the value. More...
 
VecT * beginEdit (const core::ExecParams *)
 
VecT * beginWriteOnly ()
 
VecT * beginWriteOnly (const core::ExecParams *)
 
void endEdit ()
 
void endEdit (const core::ExecParams *)
 
void setValue (const VecT &value)
 
void setValue (const core::ExecParams *, const VecT &value)
 
const VecT & getValue () const
 
const VecT & getValue (const core::ExecParams *) const
 
virtual const VecT & virtualGetValue () const
 
virtual void virtualSetValue (const VecT &v)
 
virtual void virtualSetLink (const BaseData &bd)
 
virtual VecT * virtualBeginEdit ()
 
virtual void virtualEndEdit ()
 
virtual const BaseClassgetClass () const
 
- Public Member Functions inherited from sofa::core::objectmodel::TData< VecT >
 TData (const BaseInitData &init)
 
 TData (const char *helpMsg=nullptr, bool isDisplayed=true, bool isReadOnly=false)
 
 TData (const std::string &helpMsg, bool isDisplayed=true, bool isReadOnly=false)
 
 ~TData () override
 
void printValue (std::ostream &out) const override
 General case for printing default value. More...
 
std::string getValueString () const override
 General case for printing default value. More...
 
std::string getValueTypeString () const override
 Get the name of the type of the value held in this Data. More...
 
const sofa::defaulttype::AbstractTypeInfogetValueTypeInfo () const override
 Get info about the value type of the associated variable. More...
 
const void * getValueVoidPtr () const override
 Get current value as a void pointer (use getValueTypeInfo to find how to access it) More...
 
void * beginEditVoidPtr () override
 Begin edit current value as a void pointer (use getValueTypeInfo to find how to access it) More...
 
void endEditVoidPtr () override
 End edit current value as a void pointer (use getValueTypeInfo to find how to access it) More...
 
virtual bool read (const std::string &s) override
 
bool isCounterValid () const override
 True if the counter of modification gives valid information. More...
 
bool copyValue (const TData< VecT > *parent)
 
bool copyValue (const BaseData *parent) override
 
bool validParent (BaseData *parent) override
 Check if a given Data can be linked as a parent of this data. More...
 
const BaseClassgetClass () const
 
- Public Member Functions inherited from sofa::core::objectmodel::BaseData
 BaseData (const BaseInitData &init)
 
 BaseData (const std::string &helpMsg, DataFlags flags=FLAG_DEFAULT)
 
 BaseData (const char *helpMsg, DataFlags flags=FLAG_DEFAULT)
 
 BaseData (const std::string &helpMsg, bool isDisplayed=true, bool isReadOnly=false)
 
 BaseData (const char *helpMsg, bool isDisplayed=true, bool isReadOnly=false)
 
 ~BaseData () override
 Destructor. More...
 
const std::string & getHelp () const
 Get a help message that describes this Data. More...
 
void setHelp (const std::string &val)
 Set the help message. More...
 
const std::string & getOwnerClass () const
 Get owner class. More...
 
void setOwnerClass (const char *val)
 Set owner class. More...
 
const std::string & getGroup () const
 Get group. More...
 
void setGroup (const std::string &val)
 Set group. More...
 
const std::string & getWidget () const
 Get widget. More...
 
void setWidget (const char *val)
 Set widget. More...
 
std::string getLinkPath () const
 If we use the Data as a link and not as value directly. More...
 
virtual bool canBeLinked () const
 
BasegetOwner () const
 Return the Base component owning this Data. More...
 
void setOwner (Base *o)
 Set the owner of this Data. More...
 
BaseDatagetData () const
 This method is needed by DDGNode. More...
 
const std::string & getName () const
 Return the name of this Data within the Base component. More...
 
void setName (const std::string &name)
 
bool setParent (BaseData *parent, const std::string &path=std::string())
 Link to a parent data. The value of this data will automatically duplicate the value of the parent data. More...
 
bool setParent (const std::string &path)
 
BaseDatagetParent () const
 
void update () override
 Update the value of this Data. More...
 
void setFlag (DataFlagsEnum flag, bool b)
 Set one of the flags. More...
 
bool getFlag (DataFlagsEnum flag) const
 Get one of the flags. More...
 
bool isDisplayed () const
 Return whether this Data has to be displayed in GUIs. More...
 
bool isReadOnly () const
 Return whether this Data will be read-only in GUIs. More...
 
bool isPersistent () const
 Return whether this Data contains persistent information. More...
 
bool isAutoLink () const
 Return whether this Data should be autolinked when using the src="" syntax. More...
 
bool isRequired () const
 Return whether the Data has to be set by the user for the owner component to be valid. More...
 
void setDisplayed (bool b)
 Set whether this Data should be displayed in GUIs. More...
 
void setReadOnly (bool b)
 Set whether this Data is read-only. More...
 
void setPersistent (bool b)
 Set whether this Data contains persistent information. More...
 
void setAutoLink (bool b)
 Set whether this data should be autolinked when using the src="" syntax. More...
 
void setRequired (bool b)
 Set whether the Data has to be set by the user for the owner component to be valid. More...
 
bool isSet (const core::ExecParams *) const
 
bool isSet () const
 
void unset (const core::ExecParams *)
 Reset the isSet flag to false, to indicate that the current value is the default for this Data. More...
 
void unset ()
 
void forceSet (const core::ExecParams *)
 Reset the isSet flag to true, to indicate that the current value has been modified. More...
 
void forceSet ()
 
int getCounter (const core::ExecParams *) const
 
int getCounter () const
 
const BaseClassgetClass () const
 
const VecLinkgetLinks () const
 Accessor to the vector containing all the fields of this object. More...
 
virtual bool findDataLinkDest (BaseData *&ptr, const std::string &path, const BaseLink *link)
 
template<class DataT >
bool findDataLinkDest (DataT *&ptr, const std::string &path, const BaseLink *link)
 
void addLink (BaseLink *l)
 Add a link. More...
 
- Public Member Functions inherited from sofa::core::objectmodel::DDGNode
 DDGNode ()
 Constructor. More...
 
virtual ~DDGNode ()
 Destructor. Automatically remove remaining links. More...
 
void addInput (DDGNode *n)
 Add a new input to this node. More...
 
void delInput (DDGNode *n)
 Remove an input from this node. More...
 
void addOutput (DDGNode *n)
 Add a new output to this node. More...
 
void delOutput (DDGNode *n)
 Remove an output from this node. More...
 
const DDGLinkContainergetInputs ()
 Get the list of inputs for this DDGNode. More...
 
const DDGLinkContainergetOutputs ()
 Get the list of outputs for this DDGNode. More...
 
bool isDirty (const core::ExecParams *) const
 Returns true if the DDGNode needs to be updated. More...
 
bool isDirty () const
 
virtual void setDirtyValue (const core::ExecParams *) final
 Indicate the value needs to be updated. More...
 
virtual void setDirtyValue ()
 
virtual void setDirtyOutputs (const core::ExecParams *) final
 Indicate the outputs needs to be updated. This method must be called after changing the value of this node. More...
 
virtual void setDirtyOutputs ()
 
void cleanDirty (const core::ExecParams *)
 Set dirty flag to false. More...
 
void cleanDirty ()
 
virtual void notifyEndEdit (const core::ExecParams *) final
 Notify links that the DGNode has been modified. More...
 
virtual void notifyEndEdit ()
 
void updateIfDirty (const core::ExecParams *) const
 Utility method to call update if necessary. This method should be called before reading of writing the value of this node. More...
 
void updateIfDirty () const
 

Protected Member Functions

void linkToElementDataArray (sofa::core::topology::BaseMeshTopology::Point *)
 
void linkToElementDataArray (sofa::core::topology::BaseMeshTopology::Edge *)
 
void linkToElementDataArray (sofa::core::topology::BaseMeshTopology::Triangle *)
 
void linkToElementDataArray (sofa::core::topology::BaseMeshTopology::Quad *)
 
void linkToElementDataArray (sofa::core::topology::BaseMeshTopology::Tetrahedron *)
 
void linkToElementDataArray (sofa::core::topology::BaseMeshTopology::Hexahedron *)
 
- Protected Member Functions inherited from sofa::core::objectmodel::TData< VecT >
BaseLink::InitLink< TData< VecT > > initLink (const char *name, const char *help)
 
void doSetParent (BaseData *parent) override
 
bool updateFromParentValue (const BaseData *parent) override
 Update this Data from the value of its parent. More...
 
- Protected Member Functions inherited from sofa::core::objectmodel::BaseData
void doDelInput (DDGNode *n) override
 
BaseLink::InitLink< BaseDatainitLink (const std::string &name, const std::string &help)
 
- Protected Member Functions inherited from sofa::core::objectmodel::DDGNode
virtual void doAddInput (DDGNode *n)
 
virtual void doAddOutput (DDGNode *n)
 
virtual void doDelOutput (DDGNode *n)
 
void cleanDirtyOutputsOfInputs (const core::ExecParams *)
 the dirtyOutputs flags of all the inputs will be set to false More...
 
void cleanDirtyOutputsOfInputs ()
 

Additional Inherited Members

- Static Public Member Functions inherited from sofa::core::objectmodel::Data< VecT >
static const sofa::core::objectmodel::BaseClassGetClass ()
 
static std::string templateName (const Data< VecT > *=nullptr)
 
- Static Public Member Functions inherited from sofa::core::objectmodel::TData< VecT >
static const sofa::core::objectmodel::BaseClassGetClass ()
 
static std::string templateName (const TData< VecT > *=nullptr)
 
- Static Public Member Functions inherited from sofa::core::objectmodel::BaseData
template<class T >
static std::string typeName (const T *=nullptr)
 Helper method to get the type name of type T. More...
 
static const sofa::core::objectmodel::BaseClassGetClass ()
 
template<class T >
static void dynamicCast (T *&ptr, Base *)
 
- Static Protected Member Functions inherited from sofa::core::objectmodel::BaseData
static std::string decodeTypeName (const std::type_info &t)
 Helper method to decode the type name to a more readable form if possible. More...
 

Attribute details

template<class TopologyElementType, class VecT>
sofa::component::topology::TopologyEngineImpl<VecT>::SPtr sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::m_topologicalEngine
protected
template<class TopologyElementType, class VecT>
sofa::core::topology::BaseMeshTopology* sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::m_topology
protected
template<class TopologyElementType, class VecT>
sofa::component::topology::TopologyDataHandler<TopologyElementType,VecT>* sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::m_topologyHandler
protected

Constructor details

template<class TopologyElementType, class VecT>
sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::TopologyDataImpl ( const typename sofa::core::topology::BaseTopologyData< VecT >::InitData &  data)
inline

Constructor.

template<typename TopologyElementType , typename VecT >
sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::~TopologyDataImpl ( )
virtual

Function details

template<typename TopologyElementType , typename VecT >
void sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::addInputData ( sofa::core::objectmodel::BaseData _data)

Allow to add additionnal dependencies to others Data.

template<typename TopologyElementType, typename VecT>
void sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::createTopologicalEngine ( sofa::core::topology::BaseMeshTopology _topology,
sofa::component::topology::TopologyDataHandler< TopologyElementType, VecT > *  _topologyHandler,
bool  deleteHandler = false 
)
virtual

To create topological engine link to this Data. Pointer to current topology is needed.

Public functions to handle topological engine creation

template<typename TopologyElementType, typename VecT>
void sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::createTopologicalEngine ( sofa::core::topology::BaseMeshTopology _topology)
virtual

To create topological engine link to this Data. Pointer to current topology is needed.

Public functions to handle topological engine creation

template<class TopologyElementType, class VecT>
sofa::component::topology::TopologyEngineImpl<VecT>* sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::getTopologicalEngine ( )
inline
template<class TopologyElementType, class VecT>
sofa::core::topology::BaseMeshTopology* sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::getTopology ( )
inline
template<class TopologyElementType, class VecT>
sofa::component::topology::TopologyDataHandler<TopologyElementType,VecT>* sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::getTopologyHandler ( )
inline
template<typename TopologyElementType , typename VecT >
void sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::linkToEdgeDataArray ( )

Method used to link Data to edge Data array, using the engine's method.

template<class TopologyElementType, class VecT>
void sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::linkToElementDataArray ( sofa::core::topology::BaseMeshTopology::Point )
inlineprotected
template<class TopologyElementType, class VecT>
void sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::linkToElementDataArray ( sofa::core::topology::BaseMeshTopology::Edge )
inlineprotected
template<class TopologyElementType, class VecT>
void sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::linkToElementDataArray ( sofa::core::topology::BaseMeshTopology::Triangle )
inlineprotected
template<class TopologyElementType, class VecT>
void sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::linkToElementDataArray ( sofa::core::topology::BaseMeshTopology::Quad )
inlineprotected
template<class TopologyElementType, class VecT>
void sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::linkToElementDataArray ( sofa::core::topology::BaseMeshTopology::Tetrahedron )
inlineprotected
template<class TopologyElementType, class VecT>
void sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::linkToElementDataArray ( sofa::core::topology::BaseMeshTopology::Hexahedron )
inlineprotected
template<typename TopologyElementType , typename VecT >
void sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::linkToHexahedronDataArray ( )

Method used to link Data to hexahedron Data array, using the engine's method.

template<typename TopologyElementType , typename VecT >
void sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::linkToPointDataArray ( )

Link Data to topology arrays.

Method used to link Data to point Data array, using the engine's method.

template<typename TopologyElementType , typename VecT >
void sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::linkToQuadDataArray ( )

Method used to link Data to quad Data array, using the engine's method.

template<typename TopologyElementType , typename VecT >
void sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::linkToTetrahedronDataArray ( )

Method used to link Data to tetrahedron Data array, using the engine's method.

template<typename TopologyElementType , typename VecT >
void sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::linkToTriangleDataArray ( )

Method used to link Data to triangle Data array, using the engine's method.

template<class TopologyElementType, class VecT>
const value_type& sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::operator[] ( int  i) const
inline
template<class TopologyElementType, class VecT>
value_type& sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::operator[] ( int  i)
inline
template<typename TopologyElementType , typename VecT >
void sofa::component::topology::TopologyDataImpl< TopologyElementType, VecT >::registerTopologicalData ( )

Function to link the topological Data with the engine and the current topology. And init everything. This function should be used at the end of the all declaration link to this Data while using it in a component.