Panda3D
 All Classes Functions Variables Enumerations
cPointerCallbackObject.h
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 
15 #ifndef CPOINTERCALLBACKOBJECT_H
16 #define CPOINTERCALLBACKOBJECT_H
17 
18 #include "pandabase.h"
19 #include "callbackObject.h"
20 
21 ////////////////////////////////////////////////////////////////////
22 // Class : CPointerCallbackObject
23 // Description : This is a specialization on CallbackObject to allow
24 // association with a C-style function pointer and a
25 // void * parameter.
26 ////////////////////////////////////////////////////////////////////
27 class EXPCL_PANDA_PUTIL CPointerCallbackObject : public CallbackObject {
28 public:
29  typedef void CallbackFunction(CallbackData *cbdata, void *data);
30  INLINE CPointerCallbackObject(CallbackFunction *func, void *data);
31  ALLOC_DELETED_CHAIN(CPointerCallbackObject);
32 
33 public:
34  virtual void do_callback(CallbackData *cbdata);
35 
36 private:
37  CallbackFunction *_func;
38  void *_data;
39 
40 public:
41  static TypeHandle get_class_type() {
42  return _type_handle;
43  }
44  static void init_type() {
45  CallbackObject::init_type();
46  register_type(_type_handle, "CPointerCallbackObject",
47  CallbackObject::get_class_type());
48  }
49  virtual TypeHandle get_type() const {
50  return get_class_type();
51  }
52  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
53 
54 private:
55  static TypeHandle _type_handle;
56 };
57 
58 #include "cPointerCallbackObject.I"
59 
60 #endif
This is a generic data block that is passed along to a CallbackObject when a callback is made...
Definition: callbackData.h:32
virtual void do_callback(CallbackData *cbdata)
This method called when the callback is triggered; it replaces* the original function.
This is a specialization on CallbackObject to allow association with a C-style function pointer and a...
This is a generic object that can be assigned to a callback at various points in the rendering proces...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85