p3dPythonObject.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Filename: p3dPythonObject.h
  2. // Created by: drose (02Jul09)
  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. #ifndef P3DPYTHONOBJECT_H
  15. #define P3DPYTHONOBJECT_H
  16. #include "p3d_plugin_common.h"
  17. #include "p3dObject.h"
  18. class P3DSession;
  19. ////////////////////////////////////////////////////////////////////
  20. // Class : P3DPythonObject
  21. // Description : An object type that references a PyObject in the
  22. // subordinate process. It allows querying and/or
  23. // modifying the state of the referenced PyObject, via
  24. // clever XML communication in
  25. // P3DSession::command_and_response().
  26. ////////////////////////////////////////////////////////////////////
  27. class P3DPythonObject : public P3DObject {
  28. public:
  29. P3DPythonObject(P3DSession *session, int object_id);
  30. virtual ~P3DPythonObject();
  31. public:
  32. virtual P3D_object_type get_type();
  33. virtual bool get_bool();
  34. virtual int get_int();
  35. virtual double get_float();
  36. virtual void make_string(string &value);
  37. virtual P3D_object *get_property(const string &property);
  38. virtual bool set_property(const string &property, bool needs_response, P3D_object *value);
  39. bool set_property_insecure(const string &property, bool needs_response,
  40. P3D_object *value);
  41. virtual bool has_method(const string &method_name);
  42. virtual P3D_object *call(const string &method_name, bool needs_response,
  43. P3D_object *params[], int num_params);
  44. P3D_object *call_insecure(const string &method_name, bool needs_response,
  45. P3D_object *params[], int num_params);
  46. virtual void output(ostream &out);
  47. virtual bool fill_xml(TiXmlElement *xvalue, P3DSession *session);
  48. virtual P3DPythonObject *as_python_object();
  49. P3DSession *get_session();
  50. int get_object_id();
  51. private:
  52. P3DSession *_session;
  53. int _object_id;
  54. typedef map<string, bool> HasMethod;
  55. HasMethod _has_method;
  56. };
  57. #endif