2
0

bitMaskTransition.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Filename: bitMaskTransition.h
  2. // Created by: drose (08Jun00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. #ifndef BITMASKTRANSITION_H
  6. #define BITMASKTRANSITION_H
  7. #include <pandabase.h>
  8. #include "nodeTransition.h"
  9. class NodeAttribute;
  10. class NodeRelation;
  11. ////////////////////////////////////////////////////////////////////
  12. // Class : BitMaskTransition
  13. // Description : This is an abstract template class that encapsulates
  14. // transitions on a bitmask. Each transition may add
  15. // and/or remove bits from the accumulated bitmask.
  16. //
  17. // It's the base class for a number of scene graph
  18. // transitions like DrawMaskTransition and
  19. // CollideMaskTransition.
  20. ////////////////////////////////////////////////////////////////////
  21. template<class MaskType>
  22. class BitMaskTransition : public NodeTransition {
  23. protected:
  24. INLINE BitMaskTransition();
  25. INLINE BitMaskTransition(const MaskType &and, const MaskType &or);
  26. INLINE BitMaskTransition(const BitMaskTransition &copy);
  27. INLINE void operator = (const BitMaskTransition &copy);
  28. public:
  29. INLINE void set_and(const MaskType &and);
  30. INLINE const MaskType &get_and() const;
  31. INLINE void set_or(const MaskType &or);
  32. INLINE const MaskType &get_or() const;
  33. virtual NodeTransition *compose(const NodeTransition *other) const;
  34. virtual NodeTransition *invert() const;
  35. virtual NodeAttribute *apply(const NodeAttribute *attrib) const;
  36. virtual void output(ostream &out) const;
  37. protected:
  38. virtual int internal_compare_to(const NodeTransition *other) const;
  39. protected:
  40. virtual BitMaskTransition<MaskType> *
  41. make_with_masks(const MaskType &and, const MaskType &or) const=0;
  42. private:
  43. MaskType _and, _or;
  44. public:
  45. virtual TypeHandle get_type() const {
  46. return get_class_type();
  47. }
  48. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  49. static TypeHandle get_class_type() {
  50. return _type_handle;
  51. }
  52. static void init_type() {
  53. NodeTransition::init_type();
  54. MaskType::init_type();
  55. register_type(_type_handle,
  56. string("BitMaskTransition<") +
  57. MaskType::get_class_type().get_name() + ">",
  58. NodeTransition::get_class_type());
  59. }
  60. private:
  61. static TypeHandle _type_handle;
  62. };
  63. #include "bitMaskTransition.I"
  64. #endif