2
0

nodeTransitions.I 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Filename: nodeTransitions.I
  2. // Created by: drose (20Mar00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. ////////////////////////////////////////////////////////////////////
  6. // Function: NodeTransitions::set_transition
  7. // Access: Public
  8. // Description: This flavor of set_transition() accepts a pointer to
  9. // a NodeTransition only. It infers the type of the
  10. // NodeTransition from the pointer. However, it is not
  11. // valid to pass a NULL pointer to this flavor of
  12. // set_transition; if the pointer might be NULL, use the
  13. // above flavor instead (or just call clear_transition).
  14. ////////////////////////////////////////////////////////////////////
  15. INLINE PT(NodeTransition) NodeTransitions::
  16. set_transition(NodeTransition *trans) {
  17. nassertr(trans != (NodeTransition *)NULL, NULL);
  18. nassertr(trans->get_handle() != TypeHandle::none(), NULL);
  19. return set_transition(trans->get_handle(), trans);
  20. }
  21. ////////////////////////////////////////////////////////////////////
  22. // Function: NodeTransitions::size
  23. // Access: Public
  24. // Description:
  25. ////////////////////////////////////////////////////////////////////
  26. INLINE NodeTransitions::size_type NodeTransitions::
  27. size() const {
  28. return _transitions.size();
  29. }
  30. ////////////////////////////////////////////////////////////////////
  31. // Function: NodeTransitions::begin
  32. // Access: Public
  33. // Description:
  34. ////////////////////////////////////////////////////////////////////
  35. INLINE NodeTransitions::const_iterator NodeTransitions::
  36. begin() const {
  37. return _transitions.begin();
  38. }
  39. ////////////////////////////////////////////////////////////////////
  40. // Function: NodeTransitions::end
  41. // Access: Public
  42. // Description:
  43. ////////////////////////////////////////////////////////////////////
  44. INLINE NodeTransitions::const_iterator NodeTransitions::
  45. end() const {
  46. return _transitions.end();
  47. }
  48. ////////////////////////////////////////////////////////////////////
  49. // Function: get_transition_into
  50. // Description: This external template function is handy for
  51. // extracting a transition of a particular type from the
  52. // set. If the transition exists, it is automatically
  53. // downcasted to the correct type and stored in the
  54. // pointer given in the first parameter, and the return
  55. // value is true. If the transition does not exist, the
  56. // pointer is filled with NULL and the return value is
  57. // false.
  58. ////////////////////////////////////////////////////////////////////
  59. template<class Transition>
  60. INLINE bool
  61. get_transition_into(Transition *&ptr, const NodeTransitions &trans,
  62. TypeHandle transition_type) {
  63. NodeTransition *nt = trans.get_transition(transition_type);
  64. if (nt == (NodeTransition *)NULL) {
  65. ptr = (Transition *)NULL;
  66. return false;
  67. }
  68. DCAST_INTO_R(ptr, nt, false);
  69. return true;
  70. }
  71. template<class Transition>
  72. INLINE bool
  73. get_transition_into(Transition *&ptr, const NodeTransitions &trans) {
  74. return get_transition_into(ptr, trans, Transition::get_class_type());
  75. }