Browse Source

add find_child

David Rose 22 years ago
parent
commit
c37f62fd9a
2 changed files with 21 additions and 0 deletions
  1. 19 0
      panda/src/egg/eggGroupNode.cxx
  2. 2 0
      panda/src/egg/eggGroupNode.h

+ 19 - 0
panda/src/egg/eggGroupNode.cxx

@@ -289,6 +289,25 @@ steal_children(EggGroupNode &other) {
   _children.splice(_children.end(), other._children);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: EggGroupNode::find_child
+//       Access: Public
+//  Description: Returns the child of this node whose name is the
+//               indicated string, or NULL if there is no child of
+//               this node by that name.  Does not search recursively.
+////////////////////////////////////////////////////////////////////
+EggNode *EggGroupNode::
+find_child(const string &name) const {
+  Children::const_iterator ci;
+  for (ci = _children.begin(); ci != _children.end(); ++ci) {
+    EggNode *child = (*ci);
+    if (child->get_name() == name) {
+      return child;
+    }
+  }
+
+  return NULL;
+}
 
 ////////////////////////////////////////////////////////////////////
 //     Function: EggGroupNode::resolve_filenames

+ 2 - 0
panda/src/egg/eggGroupNode.h

@@ -109,6 +109,8 @@ public:
   PT(EggNode) remove_child(PT(EggNode) node);
   void steal_children(EggGroupNode &other);
 
+  EggNode *find_child(const string &name) const;
+
   void resolve_filenames(const DSearchPath &searchpath);
   void reverse_vertex_ordering();