Panda3D
cPointerCallbackObject.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file cPointerCallbackObject.h
10  * @author drose
11  * @date 2009-03-13
12  */
13 
14 #ifndef CPOINTERCALLBACKOBJECT_H
15 #define CPOINTERCALLBACKOBJECT_H
16 
17 #include "pandabase.h"
18 #include "callbackObject.h"
19 
20 /**
21  * This is a specialization on CallbackObject to allow association with a
22  * C-style function pointer and a 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 
30 public:
31  virtual void do_callback(CallbackData *cbdata);
32 
33 private:
34  CallbackFunction *_func;
35  void *_data;
36 
37 public:
38  static TypeHandle get_class_type() {
39  return _type_handle;
40  }
41  static void init_type() {
42  CallbackObject::init_type();
43  register_type(_type_handle, "CPointerCallbackObject",
44  CallbackObject::get_class_type());
45  }
46  virtual TypeHandle get_type() const {
47  return get_class_type();
48  }
49  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
50 
51 private:
52  static TypeHandle _type_handle;
53 };
54 
55 #include "cPointerCallbackObject.I"
56 
57 #endif
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a generic data block that is passed along to a CallbackObject when a callback is made.
Definition: callbackData.h:29
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:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.