Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/pgraph/findApproxPath.h

Go to the documentation of this file.
00001 // Filename: FindApproxPath.h
00002 // Created by:  drose (13Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef FINDAPPROXPATH_H
00020 #define FINDAPPROXPATH_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "typeHandle.h"
00025 #include "pvector.h"
00026 
00027 class PandaNode;
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //       Class : FindApproxPath
00031 // Description : This class is local to this package only; it doesn't
00032 //               get exported.  It chops a string path, as supplied to
00033 //               find_up() or find_down(), and breaks it up into its
00034 //               component pieces.
00035 ////////////////////////////////////////////////////////////////////
00036 class FindApproxPath {
00037 public:
00038   INLINE FindApproxPath();
00039 
00040   bool add_string(const string &str_path);
00041   bool add_flags(const string &str_flags);
00042   bool add_component(string str_component);
00043 
00044   INLINE void add_match_name(const string &name, int flags);
00045   INLINE void add_match_name_glob(const string &glob, int flags);
00046   INLINE void add_match_exact_type(TypeHandle type, int flags);
00047   INLINE void add_match_inexact_type(TypeHandle type, int flags);
00048   INLINE void add_match_one(int flags);
00049   INLINE void add_match_many(int flags);
00050   INLINE void add_match_pointer(PandaNode *pointer, int flags);
00051 
00052   INLINE int get_num_components() const;
00053   INLINE bool is_component_match_many(int index) const;
00054   INLINE bool matches_component(int index, PandaNode *node) const;
00055   INLINE bool matches_stashed(int index) const;
00056 
00057   INLINE bool return_hidden() const;
00058   INLINE bool return_stashed() const;
00059 
00060   void output(ostream &out) const;
00061   INLINE void output_component(ostream &out, int index) const;
00062 
00063 #ifndef WIN32_VC
00064 // Visual C++ won't let us define the ostream operator functions for
00065 // these guys if they're private--even though we declare them friends.
00066 private:
00067 #endif
00068   enum ComponentType {
00069     CT_match_name,
00070     CT_match_name_glob,
00071     CT_match_exact_type,
00072     CT_match_inexact_type,
00073     CT_match_one,
00074     CT_match_many,
00075     CT_match_pointer
00076   };
00077   enum ComponentFlags {
00078     CF_stashed        = 0x001,
00079   };
00080 
00081   class Component {
00082   public:
00083     bool matches(PandaNode *node) const;
00084     void output(ostream &out) const;
00085 
00086     ComponentType _type;
00087     string _name;
00088     TypeHandle _type_handle;
00089     PandaNode *_pointer;
00090     int _flags;
00091   };
00092 
00093   typedef pvector<Component> Path;
00094   Path _path;
00095 
00096   bool _return_hidden;
00097   bool _return_stashed;
00098 
00099 friend ostream &operator << (ostream &, FindApproxPath::ComponentType);
00100 friend INLINE ostream &operator << (ostream &, const FindApproxPath::Component &);
00101 };
00102 
00103 ostream &
00104 operator << (ostream &out, FindApproxPath::ComponentType type);
00105 
00106 INLINE ostream &
00107 operator << (ostream &out, const FindApproxPath::Component &component) {
00108   component.output(out);
00109   return out;
00110 }
00111 
00112 INLINE ostream &
00113 operator << (ostream &out, const FindApproxPath &path) {
00114   path.output(out);
00115   return out;
00116 }
00117 
00118 #include "findApproxPath.I"
00119 
00120 #endif

Generated on Fri May 2 00:41:36 2003 for Panda by doxygen1.3