COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
Public Slots | Public Member Functions | Private Member Functions | Private Attributes | List of all members
TreeNode Class Reference

Handles a CNode component in the tree. More...

#include <TreeNode.hpp>

Inherits QObject.

Public Slots

void update_child_list ()
 Updates the child internal list. The method must be called whenever children are added or removed from the corresponding node. More...
 

Public Member Functions

 TreeNode (Handle< CNode > node, TreeNode *parent, int row_number)
 Constructor. More...
 
 ~TreeNode ()
 
bool has_parent () const
 Checks whether the node has a parent or not. More...
 
TreeNodechild (int row_number)
 Returns the ith child of this node. More...
 
Handle< CNodenode ()
 Gives the node handled by this object. More...
 
Handle< CNodenode () const
 Gives the node handled by this object. More...
 
TreeNodeparent_node () const
 Gives the parent. More...
 
int row_number () const
 Gives the row number. More...
 
int child_count () const
 Gives the child count. More...
 
QString node_name () const
 Gives the node name. More...
 
TreeNodechild_by_name (const QString &name)
 Retrieves a child from its name. More...
 

Private Member Functions

void remove_child (TreeNode *child)
 

Private Attributes

Handle< CNodem_node
 Handled node. More...
 
TreeNodem_parent
 The parent. May be nullptr. More...
 
int m_row_number
 The row number. More...
 
QList< TreeNode * > m_child_nodes
 List of children. More...
 

Detailed Description

Handles a CNode component in the tree.

Author
Quentin Gasper.

Definition at line 30 of file TreeNode.hpp.

Constructor & Destructor Documentation

TreeNode ( Handle< CNode node,
TreeNode parent,
int  row_number 
)

Constructor.

Parameters
nodeThe node to handle. The pointer can not be nullptr.
parentPointer to the parent TreeNode. May be nullptr.
rowNumberRow number of the node under the parent. Must be greater or equal to 0.

Definition at line 19 of file TreeNode.cpp.

~TreeNode ( )

Definition at line 34 of file TreeNode.cpp.

Member Function Documentation

TreeNode * child ( int  row_number)

Returns the ith child of this node.

If the TreeNode object corresponding to the asked child does not exist yet, it is created.

Parameters
rowNumber
Returns
Returns the wanted child, or a nullptr pointer if the row number is not valid (less than 0, or bigger than the number of child this this node has).

Definition at line 52 of file TreeNode.cpp.

TreeNode * child_by_name ( const QString &  name)

Retrieves a child from its name.

Returns
Returns the child, or a nullptr pointer if no child as such name.
Todo:
find a better algorithm !!!

Definition at line 121 of file TreeNode.cpp.

int child_count ( ) const

Gives the child count.

Returns
Returns the child count.

Definition at line 111 of file TreeNode.cpp.

bool has_parent ( ) const

Checks whether the node has a parent or not.

A node has a parent if was constructed with a non-null pointer as parent.

Returns
Returns true if the node has parent. Otherwise, returns false.

Definition at line 45 of file TreeNode.cpp.

Handle< CNode > node ( )

Gives the node handled by this object.

Returns
Returns the node handled by this object.

Definition at line 81 of file TreeNode.cpp.

Handle< CNode > node ( ) const

Gives the node handled by this object.

Returns
Returns the node handled by this object.

Definition at line 89 of file TreeNode.cpp.

QString node_name ( ) const
inline

Gives the node name.

Calling the method is equivalent to

node->getNode()->name().str();
Returns
Return the node name.

Definition at line 91 of file TreeNode.hpp.

TreeNode * parent_node ( ) const

Gives the parent.

Returns
Returns the parent. May return a nullptr pointer if the node has no porent.

Definition at line 97 of file TreeNode.cpp.

void remove_child ( TreeNode child)
private

Definition at line 156 of file TreeNode.cpp.

int row_number ( ) const

Gives the row number.

Returns
Returns the row number.

Definition at line 104 of file TreeNode.cpp.

void update_child_list ( )
slot

Updates the child internal list. The method must be called whenever children are added or removed from the corresponding node.

Warning
To avoid consistency issues, the existing list is cleared and its items are destroyed. This is because the position of existing elements may have changed. This means that all items created by getChild will have to be recreated again. Thus, calling this method too often may lead to performance problems.

Definition at line 143 of file TreeNode.cpp.

Member Data Documentation

QList<TreeNode *> m_child_nodes
private

List of children.

This list is initialized at the right size in the constructor with nullptr pointers (one pointer for each child). Each pointer is replaced when the corresponding child is built by getChild method.

Definition at line 133 of file TreeNode.hpp.

Handle<CNode> m_node
private

Handled node.

Definition at line 120 of file TreeNode.hpp.

TreeNode* m_parent
private

The parent. May be nullptr.

Definition at line 123 of file TreeNode.hpp.

int m_row_number
private

The row number.

Definition at line 126 of file TreeNode.hpp.


The documentation for this class was generated from the following files:
Send comments to:
COOLFluiD Web Admin