nodeTransitions.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Filename: nodeTransitions.h
  2. // Created by: drose (20Mar00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. #ifndef NODETRANSITIONS_H
  6. #define NODETRANSITIONS_H
  7. #include <pandabase.h>
  8. #include "nodeTransition.h"
  9. #include <pointerTo.h>
  10. #include <map>
  11. class NodeRelation;
  12. ////////////////////////////////////////////////////////////////////
  13. // Class : NodeTransitions
  14. // Description : This represents a set of zero or more NodeTransition
  15. // pointers, organized by the transitions' get_handle()
  16. // value.
  17. ////////////////////////////////////////////////////////////////////
  18. class EXPCL_PANDA NodeTransitions {
  19. public:
  20. NodeTransitions();
  21. NodeTransitions(const NodeTransitions &copy);
  22. void operator = (const NodeTransitions &copy);
  23. ~NodeTransitions();
  24. bool is_empty() const;
  25. PT(NodeTransition) set_transition(TypeHandle handle, NodeTransition *trans);
  26. INLINE_GRAPH PT(NodeTransition) set_transition(NodeTransition *trans);
  27. PT(NodeTransition) clear_transition(TypeHandle handle);
  28. bool has_transition(TypeHandle handle) const;
  29. NodeTransition *get_transition(TypeHandle handle) const;
  30. void copy_transitions_from(const NodeTransitions &other);
  31. void copy_transitions_from(const NodeTransitions &other,
  32. NodeRelation *to_arc);
  33. void compose_transitions_from(const NodeTransitions &other,
  34. NodeRelation *to_arc);
  35. void adjust_all_priorities(int adjustment, NodeRelation *arc);
  36. void clear();
  37. int compare_to(const NodeTransitions &other) const;
  38. void remove_all_from_arc(NodeRelation *arc);
  39. private:
  40. typedef map<TypeHandle, PT(NodeTransition) > Transitions;
  41. public:
  42. // STL-like definitions to allow read-only traversal of the
  43. // individual transitions. Beware! These are not safe to use
  44. // outside of PANDA.DLL.
  45. typedef Transitions::const_iterator iterator;
  46. typedef Transitions::const_iterator const_iterator;
  47. typedef Transitions::value_type value_type;
  48. typedef Transitions::size_type size_type;
  49. INLINE_GRAPH size_type size() const;
  50. INLINE_GRAPH const_iterator begin() const;
  51. INLINE_GRAPH const_iterator end() const;
  52. public:
  53. void output(ostream &out) const;
  54. void write(ostream &out, int indent_level = 0) const;
  55. private:
  56. Transitions _transitions;
  57. friend class NodeTransitionCache;
  58. };
  59. INLINE_GRAPH ostream &operator << (ostream &out, const NodeTransitions &nts);
  60. #ifdef BUILDING_PANDA
  61. #include "nodeTransitions.I"
  62. #endif
  63. #endif