Panda3D
paramPyObject.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 paramPyObject.h
10  * @author rdb
11  * @date 2021-03-01
12  */
13 
14 #ifndef PARAMPYOBJECT_H
15 #define PARAMPYOBJECT_H
16 
17 #include "pandabase.h"
18 #include "paramValue.h"
19 
20 #ifdef HAVE_PYTHON
21 
22 #include "py_panda.h"
23 
24 /**
25  * A class object for storing an arbitrary Python object.
26  */
27 class ParamPyObject final : public ParamValueBase {
28 public:
29  INLINE ParamPyObject(PyObject *value);
30  virtual ~ParamPyObject();
31 
32  INLINE PyObject *get_value() const;
33 
34  void output(std::ostream &out) const override;
35 
36 public:
37  PyObject *_value;
38 
39 public:
40  virtual TypeHandle get_type() const override {
41  return get_class_type();
42  }
43  virtual TypeHandle force_init_type() override {init_type(); return get_class_type();}
44  static TypeHandle get_class_type() {
45  return _type_handle;
46  }
47  static void init_type() {
48  ParamValueBase::init_type();
49  register_type(_type_handle, "ParamPyObject",
50  ParamValueBase::get_class_type());
51  }
52 
53 private:
54  static TypeHandle _type_handle;
55 };
56 
57 #include "paramPyObject.I"
58 
59 #endif // HAVE_PYTHON
60 
61 #endif
A non-template base class of ParamValue (below), which serves mainly to define the placeholder for th...
Definition: paramValue.h:31
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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