loaderFileType.cxx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // Filename: loaderFileType.cxx
  2. // Created by: drose (20Jun00)
  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. #include "loaderFileType.h"
  15. #include "loaderOptions.h"
  16. #include "config_pgraph.h"
  17. TypeHandle LoaderFileType::_type_handle;
  18. ////////////////////////////////////////////////////////////////////
  19. // Function: LoaderFileType::Constructor
  20. // Access: Protected
  21. // Description:
  22. ////////////////////////////////////////////////////////////////////
  23. LoaderFileType::
  24. LoaderFileType() {
  25. // Derived LoaderFileType classes that return a different result
  26. // based on the setting of certain LoaderOptions flags (like
  27. // LF_convert_anim) should set those bits in the following bitmask,
  28. // so that we will not inadvertently cache a model without
  29. // respecting these flags.
  30. _no_cache_flags = 0;
  31. }
  32. ////////////////////////////////////////////////////////////////////
  33. // Function: LoaderFileType::Destructor
  34. // Access: Public, Virtual
  35. // Description:
  36. ////////////////////////////////////////////////////////////////////
  37. LoaderFileType::
  38. ~LoaderFileType() {
  39. }
  40. ////////////////////////////////////////////////////////////////////
  41. // Function: LoaderFileType::get_additional_extensions
  42. // Access: Published, Virtual
  43. // Description: Returns a space-separated list of extension, in
  44. // addition to the one returned by get_extension(), that
  45. // are recognized by this loader.
  46. ////////////////////////////////////////////////////////////////////
  47. string LoaderFileType::
  48. get_additional_extensions() const {
  49. return string();
  50. }
  51. ////////////////////////////////////////////////////////////////////
  52. // Function: LoaderFileType::supports_compressed
  53. // Access: Published, Virtual
  54. // Description: Returns true if this file type can transparently load
  55. // compressed files (with a .pz extension), false
  56. // otherwise.
  57. ////////////////////////////////////////////////////////////////////
  58. bool LoaderFileType::
  59. supports_compressed() const {
  60. return false;
  61. }
  62. ////////////////////////////////////////////////////////////////////
  63. // Function: LoaderFileType::get_allow_disk_cache
  64. // Access: Published, Virtual
  65. // Description: Returns true if the loader flags allow retrieving the
  66. // model from the on-disk bam cache (if it is enabled),
  67. // false otherwise.
  68. ////////////////////////////////////////////////////////////////////
  69. bool LoaderFileType::
  70. get_allow_disk_cache(const LoaderOptions &options) const {
  71. return (options.get_flags() & (LoaderOptions::LF_no_disk_cache | _no_cache_flags)) == 0;
  72. }
  73. ////////////////////////////////////////////////////////////////////
  74. // Function: LoaderFileType::get_allow_ram_cache
  75. // Access: Published
  76. // Description: Returns true if the loader flags allow retrieving the
  77. // model from the in-memory ModelPool cache, false
  78. // otherwise.
  79. ////////////////////////////////////////////////////////////////////
  80. bool LoaderFileType::
  81. get_allow_ram_cache(const LoaderOptions &options) const {
  82. return (options.get_flags() & (LoaderOptions::LF_no_ram_cache | _no_cache_flags)) == 0;
  83. }
  84. ////////////////////////////////////////////////////////////////////
  85. // Function: LoaderFileType::load_file
  86. // Access: Public, Virtual
  87. // Description:
  88. ////////////////////////////////////////////////////////////////////
  89. PT(PandaNode) LoaderFileType::
  90. load_file(const Filename &path, const LoaderOptions &options,
  91. BamCacheRecord *record) const {
  92. loader_cat.error()
  93. << get_type() << " cannot read PandaNode objects.\n";
  94. return NULL;
  95. }