Describes the relationship between a parent and child tableau. More...
#include <vgui_parent_child_link.h>
Public Member Functions | |
vgui_parent_child_link () | |
Constructor - creates a default vgui_parent_child_link. | |
vgui_parent_child_link (vgui_parent_child_link const &) | |
Constructor - creates a vgui_parent_child_link same as the given one. | |
vgui_parent_child_link (vgui_tableau *parent) | |
Constructor - takes the parent tableau. | |
vgui_parent_child_link (vgui_tableau *parent, vgui_tableau_sptr const &child) | |
Constructor - takes the parent and child tableaux. | |
~vgui_parent_child_link () | |
Destructor - delete this parent_child_link. | |
vgui_parent_child_link & | operator= (vgui_parent_child_link const &) |
Make this parent_child_link equal to the given one. | |
bool | operator== (vgui_parent_child_link const &s) const |
Returns true if this parent_child_link is the same as the given link. | |
bool | operator== (vgui_tableau_sptr const &t) const |
Comparing a parent_child_link with a tableau compares the child. | |
vgui_tableau_sptr | parent () const |
Returns the parent tableau for this parent_child_link. | |
vgui_tableau_sptr | child () const |
Returns the child tableau for this parent_child_link. | |
operator safe_bool () const | |
Return true if both parent and child tableaux exist. | |
bool | operator! () const |
Return false if both parent and child tableaux exist. | |
operator vgui_tableau_sptr () const | |
Return a pointer to the child tableau. | |
vgui_tableau * | operator-> () const |
Return a pointer to the child tableau. | |
bool | handle (vgui_event const &e) |
Let the child tableau handle the event. | |
void | assign (vgui_tableau_sptr const &) |
Make the given tableau the child tableau in this relationship. | |
Static Public Member Functions | |
static void | get_children_of (vgui_tableau_sptr const &tab, vcl_vector< vgui_tableau_sptr > *) |
Push all children of 'tab' onto the vector. | |
static void | get_parents_of (vgui_tableau_sptr const &tab, vcl_vector< vgui_tableau_sptr > *) |
Push all parents of 'tab' onto the vector. | |
static void | replace_child_everywhere (vgui_tableau_sptr const &old_child, vgui_tableau_sptr const &new_child) |
In all parent_child_links, replace old_child with new_child. | |
Private Attributes | |
VCL_SAFE_BOOL_DEFINE | |
vgui_parent_child_link_impl * | pimpl |
Friends | |
class | vgui_tableau |
Describes the relationship between a parent and child tableau.
Q: what is a vgui_parent_child_link? A: These are essentially specialized smart pointers. A parent_child_link refers to an edge in the tableau [di]graph. A tableau acquires a child by creating a parent_child_link with itself as parent and the child as, er, child. The parent_child_links are responsible for storing this relation behind the scenes so that it can be queried and used for, say, propagating redraw requests.
Semantics: Assigning a parent_child_link to a parent_child_link
lhs = rhs;
doesn't change the graph, only the lhs which no longer refers to the edge it used to refer to. Calling set_child(t) on a parent_child_link changes the graph (the given tableau *t becomes the new child of the parent_child_link). E.g.:
vgui_parent_child_link left (this,child); vgui_parent_child_link right(this,child); bool v = (left == right); // this is false
or :
vgui_parent_child_link e(this,child); vgui_parent_child_link f=e; bool v = (e == f); // this is true
You can use a parent_child_link much like a pointer to tableaux. It will behave like the child of the parent_child_link :
left->handle(e); // same as left.child()->handle(e); right->method(); // same as right.child()->method();
In particular, you may put your parent_child_links into vectors, trees, stacks etc if that is useful for your purposes. Repeat : copying a parent_child_link does not create a new edge in the graph, only another handle to the same edge.
Attempting to create a non-empty parent_child_link whose parent and child are the same tableau causes an abort().
Definition at line 68 of file vgui_parent_child_link.h.
vgui_parent_child_link::vgui_parent_child_link | ( | ) | [inline] |
Constructor - creates a default vgui_parent_child_link.
Definition at line 74 of file vgui_parent_child_link.h.
vgui_parent_child_link::vgui_parent_child_link | ( | vgui_parent_child_link const & | that | ) |
Constructor - creates a vgui_parent_child_link same as the given one.
Definition at line 229 of file vgui_parent_child_link.cxx.
vgui_parent_child_link::vgui_parent_child_link | ( | vgui_tableau * | parent | ) |
Constructor - takes the parent tableau.
The 'parent' parameter is the self pointer ('this') of the tableau which intends to hold the parent_child_link. It may not be a null pointer. To make an uninitialized parent_child_link, use the default constructor.
Definition at line 216 of file vgui_parent_child_link.cxx.
vgui_parent_child_link::vgui_parent_child_link | ( | vgui_tableau * | parent, |
vgui_tableau_sptr const & | child | ||
) |
Constructor - takes the parent and child tableaux.
The 'parent' parameter is the self pointer ('this') of the tableau which intends to hold the parent_child_link. It may not be a null pointer. To make an uninitialized parent_child_link, use the default constructor.
Definition at line 222 of file vgui_parent_child_link.cxx.
vgui_parent_child_link::~vgui_parent_child_link | ( | ) |
Destructor - delete this parent_child_link.
Definition at line 237 of file vgui_parent_child_link.cxx.
void vgui_parent_child_link::assign | ( | vgui_tableau_sptr const & | t | ) |
Make the given tableau the child tableau in this relationship.
A parent_child_link's parent pointer cannot be changed because there is no legitimate use for that. Attempting to set the child to be the same tableau as the parent will cause an abort().
Definition at line 275 of file vgui_parent_child_link.cxx.
vgui_tableau_sptr vgui_parent_child_link::child | ( | ) | const |
Returns the child tableau for this parent_child_link.
Definition at line 265 of file vgui_parent_child_link.cxx.
void vgui_parent_child_link::get_children_of | ( | vgui_tableau_sptr const & | tab, |
vcl_vector< vgui_tableau_sptr > * | children | ||
) | [static] |
Push all children of 'tab' onto the vector.
Definition at line 330 of file vgui_parent_child_link.cxx.
void vgui_parent_child_link::get_parents_of | ( | vgui_tableau_sptr const & | tab, |
vcl_vector< vgui_tableau_sptr > * | parents | ||
) | [static] |
Push all parents of 'tab' onto the vector.
Definition at line 342 of file vgui_parent_child_link.cxx.
bool vgui_parent_child_link::handle | ( | vgui_event const & | e | ) |
Let the child tableau handle the event.
A parent_child_link behaves more like its child than its parent.
Definition at line 287 of file vgui_parent_child_link.cxx.
vgui_parent_child_link::operator vgui_parent_child_link::safe_bool | ( | ) | const |
Return true if both parent and child tableaux exist.
Definition at line 296 of file vgui_parent_child_link.cxx.
vgui_parent_child_link::operator vgui_tableau_sptr | ( | ) | const |
Return a pointer to the child tableau.
A parent_child_link behaves more like its child than its parent.
Definition at line 306 of file vgui_parent_child_link.cxx.
bool vgui_parent_child_link::operator! | ( | ) | const |
Return false if both parent and child tableaux exist.
Definition at line 301 of file vgui_parent_child_link.cxx.
vgui_tableau * vgui_parent_child_link::operator-> | ( | ) | const |
Return a pointer to the child tableau.
A parent_child_link behaves more like its child than its parent.
Definition at line 311 of file vgui_parent_child_link.cxx.
vgui_parent_child_link & vgui_parent_child_link::operator= | ( | vgui_parent_child_link const & | that | ) |
Make this parent_child_link equal to the given one.
Definition at line 245 of file vgui_parent_child_link.cxx.
bool vgui_parent_child_link::operator== | ( | vgui_parent_child_link const & | s | ) | const [inline] |
Returns true if this parent_child_link is the same as the given link.
Links are equal if they have the same implementation. Merely having the same parent and child does not imply equality.
Definition at line 102 of file vgui_parent_child_link.h.
bool vgui_parent_child_link::operator== | ( | vgui_tableau_sptr const & | t | ) | const |
Comparing a parent_child_link with a tableau compares the child.
Definition at line 270 of file vgui_parent_child_link.cxx.
vgui_tableau_sptr vgui_parent_child_link::parent | ( | ) | const |
Returns the parent tableau for this parent_child_link.
Definition at line 260 of file vgui_parent_child_link.cxx.
void vgui_parent_child_link::replace_child_everywhere | ( | vgui_tableau_sptr const & | old_child, |
vgui_tableau_sptr const & | new_child | ||
) | [static] |
In all parent_child_links, replace old_child with new_child.
Definition at line 361 of file vgui_parent_child_link.cxx.
friend class vgui_tableau [friend] |
Definition at line 153 of file vgui_parent_child_link.h.
Definition at line 155 of file vgui_parent_child_link.h.
Definition at line 71 of file vgui_parent_child_link.h.