nodeTransitionWrapper.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Filename: nodeTransitionWrapper.h
  2. // Created by: drose (20Mar00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef NODETRANSITIONWRAPPER_H
  19. #define NODETRANSITIONWRAPPER_H
  20. //
  21. // There are several flavors of TransitionWrappers (and their
  22. // corresponding AttributeWrappers). These are classes that represent
  23. // one or a number of transitions (or attributes) simultaneously and
  24. // are passed to template functions like df_traverse() and wrt() so
  25. // that the same functions can be used to operate on either one
  26. // transition type or a number of them.
  27. //
  28. // Since these classes are used as template parameters, they do not
  29. // need to use inheritance or virtual functions; but they all must
  30. // have a similar interface.
  31. //
  32. #include <pandabase.h>
  33. #include "nodeTransition.h"
  34. #include "nodeTransitionCacheEntry.h"
  35. class Node;
  36. class NodeRelation;
  37. class NodeAttribute;
  38. class NodeAttributeWrapper;
  39. ////////////////////////////////////////////////////////////////////
  40. // Class : NodeTransitionWrapper
  41. // Description : This is a wrapper around a single transition type,
  42. // selected at runtime by its handle. It is useful when
  43. // computing a wrt() based on one transition type only
  44. // (for instance, a MatrixTransition).
  45. ////////////////////////////////////////////////////////////////////
  46. class EXPCL_PANDA NodeTransitionWrapper {
  47. public:
  48. typedef NodeTransitionWrapper TransitionWrapper;
  49. typedef NodeAttributeWrapper AttributeWrapper;
  50. INLINE_GRAPH NodeTransitionWrapper(TypeHandle handle);
  51. INLINE_GRAPH NodeTransitionWrapper(const NodeTransitionWrapper &copy);
  52. INLINE_GRAPH void operator = (const NodeTransitionWrapper &copy);
  53. INLINE_GRAPH static NodeTransitionWrapper
  54. init_from(const NodeTransitionWrapper &other);
  55. static NodeTransitionWrapper init_from(const NodeAttributeWrapper &attrib);
  56. INLINE_GRAPH TypeHandle get_handle() const;
  57. INLINE_GRAPH bool has_trans() const;
  58. INLINE_GRAPH NodeTransition *get_trans() const;
  59. INLINE_GRAPH bool is_identity() const;
  60. INLINE_GRAPH int compare_to(const NodeTransitionWrapper &other) const;
  61. INLINE_GRAPH void make_identity();
  62. INLINE_GRAPH void extract_from(const NodeRelation *arc);
  63. INLINE_GRAPH void store_to(NodeRelation *arc) const;
  64. INLINE_GRAPH void compose_in_place(const NodeTransitionWrapper &other);
  65. INLINE_GRAPH void invert_in_place();
  66. INLINE_GRAPH void invert_compose_in_place(const NodeTransitionWrapper &other);
  67. INLINE_GRAPH Node *extract_from_cache(const NodeRelation *arc);
  68. INLINE_GRAPH void store_to_cache(NodeRelation *arc, Node *top_subtree);
  69. INLINE_GRAPH bool is_cache_verified(UpdateSeq as_of) const;
  70. INLINE_GRAPH void set_computed_verified(UpdateSeq now);
  71. INLINE_GRAPH void cached_compose(const NodeTransitionWrapper &cache,
  72. const NodeTransitionWrapper &value,
  73. UpdateSeq now);
  74. void output(ostream &out) const;
  75. void write(ostream &out, int indent_level = 0) const;
  76. private:
  77. TypeHandle _handle;
  78. NodeTransitionCacheEntry _entry;
  79. friend class NodeAttributeWrapper;
  80. };
  81. EXPCL_PANDA INLINE_GRAPH ostream &operator << (ostream &out, const NodeTransitionWrapper &ntw);
  82. #ifndef DONT_INLINE_GRAPH
  83. #include "nodeTransitionWrapper.I"
  84. #endif
  85. #include "nodeTransitionWrapper.T"
  86. #endif