p3dInstanceManager.I 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. // Filename: p3dInstanceManager.I
  2. // Created by: drose (29May09)
  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. // Function: P3DInstanceManager::is_initialized
  16. // Access: Public
  17. // Description: Returns true if the instance manager is successfully
  18. // initialized, false otherwise.
  19. ////////////////////////////////////////////////////////////////////
  20. inline bool P3DInstanceManager::
  21. is_initialized() const {
  22. return _is_initialized;
  23. }
  24. ////////////////////////////////////////////////////////////////////
  25. // Function: P3DInstanceManager::reconsider_runtime_environment
  26. // Access: Public
  27. // Description: Recreates the runtime environment if a previous call
  28. // to uninstall_all() removed it. Does nothing if the
  29. // runtime environment is already correctly set up.
  30. ////////////////////////////////////////////////////////////////////
  31. inline void P3DInstanceManager::
  32. reconsider_runtime_environment() {
  33. assert(_is_initialized);
  34. if (!_created_runtime_environment) {
  35. create_runtime_environment();
  36. }
  37. }
  38. ////////////////////////////////////////////////////////////////////
  39. // Function: P3DInstanceManager::verify_contents
  40. // Access: Public
  41. // Description: Returns the verify_contents setting. When this is
  42. // set to P3D_VC_none, it indicates that we don't need
  43. // to contact the server to verify that a contents.xml
  44. // file is fresh before using it; we should just use it
  45. // as it is.
  46. ////////////////////////////////////////////////////////////////////
  47. inline P3D_verify_contents P3DInstanceManager::
  48. get_verify_contents() const {
  49. return _verify_contents;
  50. }
  51. ////////////////////////////////////////////////////////////////////
  52. // Function: P3DInstanceManager::reset_verify_contents
  53. // Access: Public
  54. // Description: Resets the verify_contents flag to P3D_VC_normal, if
  55. // it is P3D_VC_none. This should be done whenever we
  56. // discover anything needs to be downloaded. At this
  57. // point, we might as well verify everything.
  58. ////////////////////////////////////////////////////////////////////
  59. inline void P3DInstanceManager::
  60. reset_verify_contents() {
  61. if (_verify_contents == P3D_VC_none) {
  62. _verify_contents = P3D_VC_normal;
  63. }
  64. }
  65. ////////////////////////////////////////////////////////////////////
  66. // Function: P3DInstanceManager::get_api_version
  67. // Access: Public
  68. // Description: Returns the api_version number which was passed to
  69. // P3D_initialize(). Client code may use this to
  70. // determine how to interpret parameters to various
  71. // functions whose interface may have changed over
  72. // different versions.
  73. ////////////////////////////////////////////////////////////////////
  74. inline int P3DInstanceManager::
  75. get_api_version() const {
  76. return _api_version;
  77. }
  78. ////////////////////////////////////////////////////////////////////
  79. // Function: P3DInstanceManager::get_host_url
  80. // Access: Public
  81. // Description: Returns the standard host_url which the instances
  82. // should attempt to contact to download auxiliary
  83. // packages associated with the core API, such as the
  84. // p3dcert and images packages. This is normally the
  85. // compiled-in PANDA_PACKAGE_HOST_URL, but it might be
  86. // set to something different by the -u parameter on the
  87. // panda3d executable.
  88. ////////////////////////////////////////////////////////////////////
  89. inline const string &P3DInstanceManager::
  90. get_host_url() const {
  91. return _host_url;
  92. }
  93. ////////////////////////////////////////////////////////////////////
  94. // Function: P3DInstanceManager::get_root_dir
  95. // Access: Public
  96. // Description: Returns the root directory into which all the P3D
  97. // runtime files are downloaded and installed. This
  98. // must be a writable directory or nothing will work.
  99. ////////////////////////////////////////////////////////////////////
  100. inline const string &P3DInstanceManager::
  101. get_root_dir() const {
  102. return _root_dir;
  103. }
  104. ////////////////////////////////////////////////////////////////////
  105. // Function: P3DInstanceManager::get_platform
  106. // Access: Public
  107. // Description: Returns the string that corresponds to the platform
  108. // on which we are running. This string will be used to
  109. // determine the appropriate packages to download.
  110. ////////////////////////////////////////////////////////////////////
  111. inline const string &P3DInstanceManager::
  112. get_platform() const {
  113. return _platform;
  114. }
  115. ////////////////////////////////////////////////////////////////////
  116. // Function: P3DInstanceManager::get_temp_directory
  117. // Access: Public
  118. // Description: Returns the pathname of the directory into which
  119. // temporary files should be written. This filename
  120. // will end with a slash, so that full pathnames may be
  121. // made by concatenting directly with this string.
  122. ////////////////////////////////////////////////////////////////////
  123. inline const string &P3DInstanceManager::
  124. get_temp_directory() const {
  125. return _temp_directory;
  126. }
  127. ////////////////////////////////////////////////////////////////////
  128. // Function: P3DInstanceManager::get_log_directory
  129. // Access: Public
  130. // Description: Returns the pathname of the directory into which all
  131. // log files should be written. This filename will end
  132. // with a slash, so that full pathnames may be made by
  133. // concatenting directly with this string.
  134. ////////////////////////////////////////////////////////////////////
  135. inline const string &P3DInstanceManager::
  136. get_log_directory() const {
  137. return _log_directory;
  138. }
  139. ////////////////////////////////////////////////////////////////////
  140. // Function: P3DInstanceManager::get_log_pathname
  141. // Access: Public
  142. // Description: Returns the filename of the system log file; this
  143. // file is responsible for downloading and installing
  144. // updates, and launching applications. This is
  145. // different from the session log file(s), which
  146. // represent the output from a particular Python
  147. // session.
  148. ////////////////////////////////////////////////////////////////////
  149. inline const string &P3DInstanceManager::
  150. get_log_pathname() const {
  151. return _log_pathname;
  152. }
  153. ////////////////////////////////////////////////////////////////////
  154. // Function: P3DInstanceManager::get_trusted_environment
  155. // Access: Public
  156. // Description: Returns the value of the trusted_environment flag
  157. // passed to the constructor. If this is true, it means
  158. // the environment we are running in is trusted and the
  159. // p3d file is already vetted. This means the current
  160. // working directory will remain unchanged, and the p3d
  161. // file will be run without checking its signature.
  162. //
  163. // This should generally be true only when run by
  164. // panda3d.exe or panda3dw.exe, and not when run by the
  165. // web plugin.
  166. ////////////////////////////////////////////////////////////////////
  167. inline bool P3DInstanceManager::
  168. get_trusted_environment() const {
  169. return _trusted_environment;
  170. }
  171. ////////////////////////////////////////////////////////////////////
  172. // Function: P3DInstanceManager::get_console_environment
  173. // Access: Public
  174. // Description: Returns the value of the console_environment flag
  175. // passed to the constructor. If this is true, it means
  176. // we are running from a text-based console window, and
  177. // not from a desktop environment.
  178. //
  179. // This should generally be true only when run by
  180. // panda3d.exe, and not when run by the web plugin or by
  181. // panda3dw.exe.
  182. ////////////////////////////////////////////////////////////////////
  183. inline bool P3DInstanceManager::
  184. get_console_environment() const {
  185. return _console_environment;
  186. }
  187. ////////////////////////////////////////////////////////////////////
  188. // Function: P3DInstanceManager::get_plugin_major_version
  189. // Access: Public
  190. // Description: Returns the plugin's reported major version number.
  191. ////////////////////////////////////////////////////////////////////
  192. inline int P3DInstanceManager::
  193. get_plugin_major_version() const {
  194. return _plugin_major_version;
  195. }
  196. ////////////////////////////////////////////////////////////////////
  197. // Function: P3DInstanceManager::get_plugin_minor_version
  198. // Access: Public
  199. // Description: Returns the plugin's reported minor version number.
  200. ////////////////////////////////////////////////////////////////////
  201. inline int P3DInstanceManager::
  202. get_plugin_minor_version() const {
  203. return _plugin_minor_version;
  204. }
  205. ////////////////////////////////////////////////////////////////////
  206. // Function: P3DInstanceManager::get_plugin_sequence_version
  207. // Access: Public
  208. // Description: Returns the plugin's reported sequence version number.
  209. ////////////////////////////////////////////////////////////////////
  210. inline int P3DInstanceManager::
  211. get_plugin_sequence_version() const {
  212. return _plugin_sequence_version;
  213. }
  214. ////////////////////////////////////////////////////////////////////
  215. // Function: P3DInstanceManager::get_plugin_official_version
  216. // Access: Public
  217. // Description: Returns true if the plugin claims to be from an
  218. // "official" build, and the its version number is
  219. // authoritative; or false if it makes no such claim
  220. // (for instance, it was built by someone checking out
  221. // from cvs).
  222. ////////////////////////////////////////////////////////////////////
  223. inline bool P3DInstanceManager::
  224. get_plugin_official_version() const {
  225. return _plugin_official_version;
  226. }
  227. ////////////////////////////////////////////////////////////////////
  228. // Function: P3DInstanceManager::get_plugin_distributor
  229. // Access: Public
  230. // Description: Returns the "distributor" reported by the plugin.
  231. // This should represent the entity that built and
  232. // hosted the plugin.
  233. ////////////////////////////////////////////////////////////////////
  234. inline const string &P3DInstanceManager::
  235. get_plugin_distributor() const {
  236. return _plugin_distributor;
  237. }
  238. ////////////////////////////////////////////////////////////////////
  239. // Function: P3DInstanceManager::get_coreapi_host_url
  240. // Access: Public
  241. // Description: Returns the host URL from which this Core API was
  242. // downloaded (according to the plugin). This is for
  243. // reporting purposes only; see get_host_url() for the
  244. // URL to contact to actually download content.
  245. ////////////////////////////////////////////////////////////////////
  246. inline const string &P3DInstanceManager::
  247. get_coreapi_host_url() const {
  248. return _coreapi_host_url;
  249. }
  250. ////////////////////////////////////////////////////////////////////
  251. // Function: P3DInstanceManager::get_coreapi_timestamp
  252. // Access: Public
  253. // Description: Returns the timestamp associated with this Core API
  254. // DLL (according to the plugin). This is the timestamp
  255. // shown in the contents.xml for this host, and is
  256. // usually the time at which the plugin was built.
  257. ////////////////////////////////////////////////////////////////////
  258. inline time_t P3DInstanceManager::
  259. get_coreapi_timestamp() const {
  260. return _coreapi_timestamp;
  261. }
  262. ////////////////////////////////////////////////////////////////////
  263. // Function: P3DInstanceManager::get_coreapi_set_ver
  264. // Access: Public
  265. // Description: Returns the version number associated with the Core
  266. // API, if provided. Some early versions of the Core
  267. // API, and some early versions of the plugin, did not
  268. // provide a number here. If provided, this will be a
  269. // string of dot-separated integers.
  270. ////////////////////////////////////////////////////////////////////
  271. inline const string &P3DInstanceManager::
  272. get_coreapi_set_ver() const {
  273. return _coreapi_set_ver;
  274. }
  275. ////////////////////////////////////////////////////////////////////
  276. // Function: P3DInstanceManager::get_super_mirror
  277. // Access: Public
  278. // Description: Returns the "super mirror" URL. See p3d_plugin.h.
  279. ////////////////////////////////////////////////////////////////////
  280. inline const string &P3DInstanceManager::
  281. get_super_mirror() const {
  282. return _super_mirror_url;
  283. }
  284. ////////////////////////////////////////////////////////////////////
  285. // Function: P3DInstanceManager::get_num_instances
  286. // Access: Public
  287. // Description: Returns the number of instances currently running
  288. // within the world.
  289. ////////////////////////////////////////////////////////////////////
  290. inline int P3DInstanceManager::
  291. get_num_instances() const {
  292. return _instances.size();
  293. }
  294. ////////////////////////////////////////////////////////////////////
  295. // Function: P3DInstanceManager::new_undefined_object
  296. // Access: Public
  297. // Description: Returns the singleton "undefined" object, as a new
  298. // reference.
  299. ////////////////////////////////////////////////////////////////////
  300. inline P3D_object *P3DInstanceManager::
  301. new_undefined_object() {
  302. P3D_OBJECT_INCREF(_undefined_object);
  303. return _undefined_object;
  304. }
  305. ////////////////////////////////////////////////////////////////////
  306. // Function: P3DInstanceManager::new_none_object
  307. // Access: Public
  308. // Description: Returns the singleton "none" object, as a new
  309. // reference.
  310. ////////////////////////////////////////////////////////////////////
  311. inline P3D_object *P3DInstanceManager::
  312. new_none_object() {
  313. P3D_OBJECT_INCREF(_none_object);
  314. return _none_object;
  315. }
  316. ////////////////////////////////////////////////////////////////////
  317. // Function: P3DInstanceManager::new_bool_object
  318. // Access: Public
  319. // Description: Returns the singleton "true" or "false" object, as a
  320. // new reference.
  321. ////////////////////////////////////////////////////////////////////
  322. inline P3D_object *P3DInstanceManager::
  323. new_bool_object(bool value) {
  324. P3D_object *obj = (value) ? _true_object : _false_object;
  325. P3D_OBJECT_INCREF(obj);
  326. return obj;
  327. }
  328. ////////////////////////////////////////////////////////////////////
  329. // Function: P3DInstanceManager::encode_hexdigit
  330. // Access: Public
  331. // Description: Returns the hex digit corresponding to the
  332. // indicated integer value.
  333. ////////////////////////////////////////////////////////////////////
  334. inline char P3DInstanceManager::
  335. encode_hexdigit(int c) {
  336. if (c >= 10) {
  337. return c - 10 + 'a';
  338. }
  339. return c + '0';
  340. }