libyui-ncurses  2.57.2
tnode< n_value > Class Template Reference

Tree node. More...

#include <tnode.h>

Public Member Functions

 tnode (n_value v, self *p=0, bool behind=true)
 New node, added as the last child by default (which is natural). More...
 
 tnode (n_value v, self &p, bool behind=true)
 New node, added as the last child by default (which is natural). More...
 
 tnode (n_value v, self &p, self &s, bool behind=true)
 New node under p, just after s (or before s if behind==false) More...
 
void Disconnect ()
 Disconnect from the parent and siblings, but keep children.
 
bool ReparentTo (self &p, bool behind=true)
 Disconnect from old parent, connect to new parent p. More...
 
bool ReparentTo (self &p, self &s, bool behind=true)
 Disconnect from old parent, connect to new parent p and sibling s. More...
 
n_value & Value () const
 
n_value & operator() () const
 Alias for Value.
 
selfParent ()
 
const selfParent () const
 
selfPsibling ()
 Previous sibling.
 
const selfPsibling () const
 Previous sibling.
 
selfNsibling ()
 Next sibling.
 
const selfNsibling () const
 Next sibling.
 
selfFchild ()
 First child.
 
const selfFchild () const
 First child.
 
selfLchild ()
 Last child.
 
const selfLchild () const
 Last child.
 
bool HasParent () const
 
bool HasSiblings () const
 
bool HasChildren () const
 
bool IsParentOf (const self &c) const
 
bool IsSiblingOf (const self &s) const
 
bool IsChildOf (const self &p) const
 
unsigned Depth () const
 Depth: zero if no parent, otherwise 1 + parent's depth.
 
bool IsDescendantOf (const self &n) const
 
bool IsDescendantOf (const self *n) const
 
selfTop ()
 Root of the tree.
 
selfNext (bool restart=false)
 Next node: depth first, pre-order. More...
 
selfPrev (bool restart=false)
 
selfNext (self *&c, bool restart=false)
 Return Next and assign it to c.
 
selfPrev (self *&c, bool restart=false)
 Return Prev and assign it to c.
 
const selfTop () const
 
const selfNext (bool restart=false) const
 
const selfPrev (bool restart=false) const
 
const selfNext (const self *&c, bool restart=false) const
 
const selfPrev (const self *&c, bool restart=false) const
 

Protected Types

typedef tnode< n_value > self
 

Protected Member Functions

virtual void PreDisconnect ()
 
virtual void PostDisconnect ()
 
virtual void PreReparent ()
 
virtual void PostReparent ()
 

Protected Attributes

n_value val
 

Detailed Description

template<class n_value>
class tnode< n_value >

Tree node.

Traversing the tree with Next and Prev is done pre-order (self before children) and depth-first (children before siblings)

See also

In practice all instances of this template use NCWidget * for n_value.

Definition at line 43 of file tnode.h.

Constructor & Destructor Documentation

◆ tnode() [1/3]

template<class n_value >
tnode< n_value >::tnode ( n_value  v,
self p = 0,
bool  behind = true 
)
inline

New node, added as the last child by default (which is natural).

Parameters
pparent

Definition at line 145 of file tnode.h.

◆ tnode() [2/3]

template<class n_value >
tnode< n_value >::tnode ( n_value  v,
self p,
bool  behind = true 
)
inline

New node, added as the last child by default (which is natural).

Parameters
pparent

Definition at line 159 of file tnode.h.

◆ tnode() [3/3]

template<class n_value >
tnode< n_value >::tnode ( n_value  v,
self p,
self s,
bool  behind = true 
)
inline

New node under p, just after s (or before s if behind==false)

Parameters
pparent
sreference sibling

Definition at line 173 of file tnode.h.

Member Function Documentation

◆ Next()

template<class n_value >
self* tnode< n_value >::Next ( bool  restart = false)
inline

Next node: depth first, pre-order.

Parameters
restartif true, the last node's Next is the first (Top); otherwise nilptr.

Definition at line 337 of file tnode.h.

◆ ReparentTo() [1/2]

template<class n_value >
bool tnode< n_value >::ReparentTo ( self p,
bool  behind = true 
)
inline

Disconnect from old parent, connect to new parent p.

Become the last child (or the first, if behind==false).

Parameters
pnew parent
Returns
true on success; false on failure (p is myself or a descendant of mine)

Definition at line 222 of file tnode.h.

◆ ReparentTo() [2/2]

template<class n_value >
bool tnode< n_value >::ReparentTo ( self p,
self s,
bool  behind = true 
)
inline

Disconnect from old parent, connect to new parent p and sibling s.

Insert this as just after s (or just before, if behind==false).

In case s is not in fact a child of p then we become p's last (first) child.

Parameters
pnew parent
sreference sibling
behindtrue: insert after s; false: insert before s
Returns
true on success; false on failure (p is myself or a descendant of mine)

Definition at line 239 of file tnode.h.


The documentation for this class was generated from the following file: