cPointerCallbackObject.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Filename: cPointerCallbackObject.h
  2. // Created by: drose (13Mar09)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #ifndef CPOINTERCALLBACKOBJECT_H
  15. #define CPOINTERCALLBACKOBJECT_H
  16. #include "pandabase.h"
  17. #include "callbackObject.h"
  18. ////////////////////////////////////////////////////////////////////
  19. // Class : CPointerCallbackObject
  20. // Description : This is a specialization on CallbackObject to allow
  21. // association with a C-style function pointer and a
  22. // void * parameter.
  23. ////////////////////////////////////////////////////////////////////
  24. class EXPCL_PANDA_PUTIL CPointerCallbackObject : public CallbackObject {
  25. public:
  26. typedef void CallbackFunction(CallbackData *cbdata, void *data);
  27. INLINE CPointerCallbackObject(CallbackFunction *func, void *data);
  28. ALLOC_DELETED_CHAIN(CPointerCallbackObject);
  29. public:
  30. virtual void do_callback(CallbackData *cbdata);
  31. private:
  32. CallbackFunction *_func;
  33. void *_data;
  34. public:
  35. static TypeHandle get_class_type() {
  36. return _type_handle;
  37. }
  38. static void init_type() {
  39. CallbackObject::init_type();
  40. register_type(_type_handle, "CPointerCallbackObject",
  41. CallbackObject::get_class_type());
  42. }
  43. virtual TypeHandle get_type() const {
  44. return get_class_type();
  45. }
  46. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  47. private:
  48. static TypeHandle _type_handle;
  49. };
  50. #include "cPointerCallbackObject.I"
  51. #endif