Panda3D
callbackObject.h
1 // Filename: callbackObject.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 CALLBACKOBJECT_H
16 #define CALLBACKOBJECT_H
17 
18 #include "pandabase.h"
19 #include "typedReferenceCount.h"
20 
21 class CallbackData;
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : CallbackObject
25 // Description : This is a generic object that can be assigned to a
26 // callback at various points in the rendering process.
27 // This is actually a base class for a handful of
28 // specialized callback object types. You can also
29 // subclass it yourself to make your own callback
30 // handler.
31 ////////////////////////////////////////////////////////////////////
32 class EXPCL_PANDA_PUTIL CallbackObject : public TypedReferenceCount {
33 protected:
34  INLINE CallbackObject();
35 public:
36  ALLOC_DELETED_CHAIN(CallbackObject);
37 
38 PUBLISHED:
39  virtual void output(ostream &out) const;
40 
41  EXTENSION(static PT(CallbackObject) make(PyObject *function));
42 
43 public:
44  virtual void do_callback(CallbackData *cbdata);
45 
46 public:
47  static TypeHandle get_class_type() {
48  return _type_handle;
49  }
50  static void init_type() {
51  TypedReferenceCount::init_type();
52  register_type(_type_handle, "CallbackObject",
53  TypedReferenceCount::get_class_type());
54  }
55  virtual TypeHandle get_type() const {
56  return get_class_type();
57  }
58  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
59 
60 private:
61  static TypeHandle _type_handle;
62 };
63 
64 inline ostream &operator << (ostream &out, const CallbackObject &cbo) {
65  cbo.output(out);
66  return out;
67 }
68 
69 #include "callbackObject.I"
70 
71 #endif
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
This is a generic data block that is passed along to a CallbackObject when a callback is made...
Definition: callbackData.h:32
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