Panda3D
physxObject.h
1 // Filename: physxObject.h
2 // Created by: enn0x (11Sep09)
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 PHYSXOBJECT_H
16 #define PHYSXOBJECT_H
17 
18 #include "pandabase.h"
19 #include "typedReferenceCount.h"
20 
21 #ifdef HAVE_PYTHON
22 #undef _POSIX_C_SOURCE
23 #include <Python.h>
24 #endif // HAVE_PYTHON
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : PhysxObject
28 // Description :
29 ////////////////////////////////////////////////////////////////////
30 class EXPCL_PANDAPHYSX PhysxObject : public TypedReferenceCount {
31 
32 #ifdef HAVE_PYTHON
33 PUBLISHED:
34  INLINE void set_python_tag(const string &key, PyObject *value);
35  INLINE PyObject *get_python_tag(const string &key) const;
36  INLINE bool has_python_tag(const string &key) const;
37  INLINE void clear_python_tag(const string &key);
38  INLINE bool has_python_tags() const;
39 #endif // HAVE_PYTHON
40 
41 PUBLISHED:
42  virtual void ls() const = 0;
43  virtual void ls(ostream &out, int indent_level=0) const = 0;
44 
45 protected:
46  INLINE PhysxObject();
47  INLINE ~PhysxObject();
48 
49  enum ErrorType {
50  ET_empty,
51  ET_ok,
52  ET_released,
53  ET_fail,
54  };
55 
56  ErrorType _error_type;
57 
58 #ifdef HAVE_PYTHON
59 private:
60  typedef phash_map<string, PyObject *, string_hash> PythonTagData;
61  PythonTagData _python_tag_data;
62 #endif // HAVE_PYTHON
63 
64 ////////////////////////////////////////////////////////////////////
65 public:
66  static TypeHandle get_class_type() {
67  return _type_handle;
68  }
69  static void init_type() {
70  TypedReferenceCount::init_type();
71  register_type(_type_handle, "PhysxObject",
72  TypedReferenceCount::get_class_type());
73  }
74  virtual TypeHandle get_type() const {
75  return get_class_type();
76  }
77  virtual TypeHandle force_init_type() {
78  init_type();
79  return get_class_type();
80  }
81 
82 private:
83  static TypeHandle _type_handle;
84 };
85 
86 #include "physxObject.I"
87 
88 #endif // PHYSXOBJECT_H
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85