libyui-ncurses
Loading...
Searching...
No Matches
tnode< n_value > Class Template Reference

#include <tnode.h>

Public Member Functions

 tnode (n_value v, self *p=0, bool behind=true)
 tnode (n_value v, self &p, bool behind=true)
 tnode (n_value v, self &p, self &s, bool behind=true)
void Disconnect ()
 Disconnect from the parent and siblings, but keep children.
bool ReparentTo (self &p, bool behind=true)
bool ReparentTo (self &p, self &s, bool behind=true)
n_value & Value () const
n_value & operator() () const
 Alias for Value.
self * Parent ()
const self * Parent () const
self * Psibling ()
 Previous sibling.
const self * Psibling () const
 Previous sibling.
self * Nsibling ()
 Next sibling.
const self * Nsibling () const
 Next sibling.
self * Fchild ()
 First child.
const self * Fchild () const
 First child.
self * Lchild ()
 Last child.
const self * Lchild () 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
self & Top ()
 Root of the tree.
self * Next (bool restart=false)
self * Prev (bool restart=false)
self * Next (self *&c, bool restart=false)
 Return Next and assign it to c.
self * Prev (self *&c, bool restart=false)
 Return Prev and assign it to c.
const self & Top () const
const self * Next (bool restart=false) const
const self * Prev (bool restart=false) const
const self * Next (const self *&c, bool restart=false) const
const self * Prev (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.

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

◆ 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

◆ 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

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.

◆ 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)

◆ 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)

The documentation for this class was generated from the following file:
  • /builddir/build/BUILD/libyui-4.6.2-build/libyui-4.6.2/libyui-ncurses/src/tnode.h