Panda3D

findApproxLevelEntry.h

00001 // Filename: findApproxLevelEntry.h
00002 // Created by:  drose (13Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef FINDAPPROXLEVELENTRY_H
00016 #define FINDAPPROXLEVELENTRY_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "findApproxPath.h"
00021 #include "workingNodePath.h"
00022 
00023 class NodePathCollection;
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : FindApproxLevelEntry
00027 // Description : This class is local to this package only; it doesn't
00028 //               get exported.  It represents a single node under
00029 //               consideration for matching at a single point in the
00030 //               breadth-first search.
00031 ////////////////////////////////////////////////////////////////////
00032 class FindApproxLevelEntry {
00033 public:
00034   INLINE FindApproxLevelEntry(const WorkingNodePath &node_path,
00035                               FindApproxPath &approx_path);
00036   INLINE FindApproxLevelEntry(const FindApproxLevelEntry &parent,
00037                               PandaNode *child_node, int i,
00038                               FindApproxLevelEntry *next);
00039   INLINE FindApproxLevelEntry(const FindApproxLevelEntry &copy);
00040   INLINE void operator = (const FindApproxLevelEntry &copy);
00041   ALLOC_DELETED_CHAIN(FindApproxLevelEntry);
00042 
00043   INLINE bool next_is_stashed(int increment) const;
00044 
00045   bool consider_node(NodePathCollection &result, 
00046                      FindApproxLevelEntry *&next_level,
00047                      int max_matches, int increment) const;
00048   void consider_next_step(PandaNode *child_node, 
00049                           FindApproxLevelEntry *&next_level,
00050                           int increment) const;
00051   INLINE bool is_solution(int increment) const;
00052 
00053   void output(ostream &out) const;
00054   void write_level(ostream &out, int indent_level) const;
00055 
00056   // _node_path represents the most recent node that we have
00057   // previously accepted as being a partial solution.
00058   WorkingNodePath _node_path;
00059 
00060   // _i represents the next component in the approx_path that must be
00061   // matched against all of the children of _node_path, above.  If _i
00062   // refers to the end of the approx_path, then _node_path is a
00063   // solution.
00064   int _i;
00065   FindApproxPath &_approx_path;
00066   FindApproxLevelEntry *_next;
00067 
00068 public:
00069   static TypeHandle get_class_type() {
00070     return _type_handle;
00071   }
00072   static void init_type() {
00073     register_type(_type_handle, "FindApproxLevelEntry");
00074   }
00075 
00076 private:
00077   static TypeHandle _type_handle;
00078 };
00079 
00080 INLINE ostream &
00081 operator << (ostream &out, const FindApproxLevelEntry &entry) {
00082   entry.output(out);
00083   return out;
00084 }
00085 
00086 #include "findApproxLevelEntry.I"
00087 
00088 #endif
 All Classes Functions Variables Enumerations