Panda3D

loaderFileType.cxx
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 loaderFileType.cxx
10 * @author drose
11 * @date 2000-06-20
12 */
13
14 #include "loaderFileType.h"
15 #include "loaderOptions.h"
16 #include "config_pgraph.h"
17
18
19 TypeHandle LoaderFileType::_type_handle;
20
21 /**
22 *
23 */
24 LoaderFileType::
25 LoaderFileType() {
26 // Derived LoaderFileType classes that return a different result based on
27 // the setting of certain LoaderOptions flags (like LF_convert_anim) should
28 // set those bits in the following bitmask, so that we will not
29 // inadvertently cache a model without respecting these flags.
30 _no_cache_flags = 0;
31 }
32
33 /**
34 *
35 */
36 LoaderFileType::
37 ~LoaderFileType() {
38 }
39
40 /**
41 * Returns a space-separated list of extension, in addition to the one
42 * returned by get_extension(), that are recognized by this loader.
43 */
44 std::string LoaderFileType::
45 get_additional_extensions() const {
46 return std::string();
47 }
48
49 /**
50 * Returns true if this file type can transparently load compressed files
51 * (with a .pz or .gz extension), false otherwise.
52 */
53 bool LoaderFileType::
54 supports_compressed() const {
55 return false;
56 }
57
58 /**
59 * Returns true if the loader flags allow retrieving the model from the on-
60 * disk bam cache (if it is enabled), false otherwise.
61 */
62 bool LoaderFileType::
63 get_allow_disk_cache(const LoaderOptions &options) const {
64 return (options.get_flags() & (LoaderOptions::LF_no_disk_cache | _no_cache_flags)) == 0;
65 }
66
67 /**
68 * Returns true if the loader flags allow retrieving the model from the in-
69 * memory ModelPool cache, false otherwise.
70 */
71 bool LoaderFileType::
72 get_allow_ram_cache(const LoaderOptions &options) const {
73 return (options.get_flags() & (LoaderOptions::LF_no_ram_cache | _no_cache_flags)) == 0;
74 }
75
76 /**
77 * Returns true if the file type can be used to load files, and load_file() is
78 * supported. Returns false if load_file() is unimplemented and will always
79 * fail.
80 */
81 bool LoaderFileType::
82 supports_load() const {
83 return true;
84 }
85
86 /**
87 * Returns true if the file type can be used to save files, and save_file() is
88 * supported. Returns false if save_file() is unimplemented and will always
89 * fail.
90 */
91 bool LoaderFileType::
92 supports_save() const {
93 return false;
94 }
95
96 /**
97 *
98 */
99 PT(PandaNode) LoaderFileType::
100 load_file(const Filename &path, const LoaderOptions &options,
101 BamCacheRecord *record) const {
102 loader_cat.error()
103 << get_type() << " cannot read PandaNode objects.\n";
104 return nullptr;
105 }
106
107 /**
108 *
109 */
110 bool LoaderFileType::
111 save_file(const Filename &path, const LoaderOptions &options,
112 PandaNode *node) const {
113 loader_cat.error()
114 << get_type() << " cannot save PandaNode objects.\n";
115 return false;
116 }
BamCacheRecord
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
Definition: bamCacheRecord.h:36
Filename
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
LoaderFileType::supports_compressed
virtual bool supports_compressed() const
Returns true if this file type can transparently load compressed files (with a .pz or ....
Definition: loaderFileType.cxx:54
LoaderFileType::get_allow_ram_cache
virtual bool get_allow_ram_cache(const LoaderOptions &options) const
Returns true if the loader flags allow retrieving the model from the in- memory ModelPool cache,...
Definition: loaderFileType.cxx:72
LoaderFileType::supports_save
virtual bool supports_save() const
Returns true if the file type can be used to save files, and save_file() is supported.
Definition: loaderFileType.cxx:92
LoaderFileType::supports_load
virtual bool supports_load() const
Returns true if the file type can be used to load files, and load_file() is supported.
Definition: loaderFileType.cxx:82
LoaderFileType::get_additional_extensions
virtual std::string get_additional_extensions() const
Returns a space-separated list of extension, in addition to the one returned by get_extension(),...
Definition: loaderFileType.cxx:45
LoaderFileType::get_allow_disk_cache
virtual bool get_allow_disk_cache(const LoaderOptions &options) const
Returns true if the loader flags allow retrieving the model from the on- disk bam cache (if it is ena...
Definition: loaderFileType.cxx:63
LoaderOptions
Specifies parameters that may be passed to the loader.
Definition: loaderOptions.h:23
PandaNode
A basic node of the scene graph or data graph.
Definition: pandaNode.h:65
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
config_pgraph.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
loaderFileType.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
loaderOptions.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.