Go to the documentation of this file.00001 
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 
00006 
00007 
00008 
00009 
00010 #include "vgui_find.h"
00011 #include <vgui/vgui_tableau.h>
00012 
00013 
00014 
00015 vgui_tableau_sptr vgui_find_by_type_name(vgui_tableau_sptr const& start, vcl_string const &tn, bool direction_down)
00016 {
00017   if (!start)
00018     return 0;
00019 
00020   if (start->type_name() == tn)
00021     return start;
00022 
00023   vcl_vector<vgui_tableau_sptr> tt;
00024   if (direction_down)
00025     start->get_children(&tt); 
00026   else
00027     start->get_parents (&tt); 
00028 
00029   for (unsigned int i=0; i<tt.size(); ++i) {
00030     vgui_tableau_sptr t = vgui_find_by_type_name(tt[i], tn, direction_down);
00031     if (t)
00032       return t; 
00033   }
00034   return 0; 
00035 }
00036 
00037 
00038 vgui_tableau_sptr
00039 vgui_find_by_name(vgui_tableau_sptr const& start, vcl_string const &name, bool direction_down)
00040 {
00041   if (!start)
00042     return 0;
00043 
00044   if (start->name() == name)
00045     return start;
00046 
00047   vcl_vector<vgui_tableau_sptr> tt;
00048   if (direction_down)
00049     start->get_children(&tt); 
00050   else
00051     start->get_parents (&tt); 
00052 
00053   for (unsigned int i=0; i<tt.size(); ++i) {
00054     vgui_tableau_sptr t = vgui_find_by_name(tt[i], name, direction_down);
00055     if (t)
00056       return t; 
00057   }
00058   return 0; 
00059 }