Panda3D
 All Classes Functions Variables Enumerations
loaderFileType.cxx
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 
15 #include "loaderFileType.h"
16 #include "loaderOptions.h"
17 #include "config_pgraph.h"
18 
19 
20 TypeHandle LoaderFileType::_type_handle;
21 
22 ////////////////////////////////////////////////////////////////////
23 // Function: LoaderFileType::Constructor
24 // Access: Protected
25 // Description:
26 ////////////////////////////////////////////////////////////////////
27 LoaderFileType::
28 LoaderFileType() {
29  // Derived LoaderFileType classes that return a different result
30  // based on the setting of certain LoaderOptions flags (like
31  // LF_convert_anim) should set those bits in the following bitmask,
32  // so that we will not inadvertently cache a model without
33  // respecting these flags.
34  _no_cache_flags = 0;
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: LoaderFileType::Destructor
39 // Access: Public, Virtual
40 // Description:
41 ////////////////////////////////////////////////////////////////////
42 LoaderFileType::
43 ~LoaderFileType() {
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: LoaderFileType::get_additional_extensions
48 // Access: Published, Virtual
49 // Description: Returns a space-separated list of extension, in
50 // addition to the one returned by get_extension(), that
51 // are recognized by this loader.
52 ////////////////////////////////////////////////////////////////////
53 string LoaderFileType::
55  return string();
56 }
57 
58 ////////////////////////////////////////////////////////////////////
59 // Function: LoaderFileType::supports_compressed
60 // Access: Published, Virtual
61 // Description: Returns true if this file type can transparently load
62 // compressed files (with a .pz extension), false
63 // otherwise.
64 ////////////////////////////////////////////////////////////////////
67  return false;
68 }
69 
70 ////////////////////////////////////////////////////////////////////
71 // Function: LoaderFileType::get_allow_disk_cache
72 // Access: Published, Virtual
73 // Description: Returns true if the loader flags allow retrieving the
74 // model from the on-disk bam cache (if it is enabled),
75 // false otherwise.
76 ////////////////////////////////////////////////////////////////////
78 get_allow_disk_cache(const LoaderOptions &options) const {
79  return (options.get_flags() & (LoaderOptions::LF_no_disk_cache | _no_cache_flags)) == 0;
80 }
81 
82 ////////////////////////////////////////////////////////////////////
83 // Function: LoaderFileType::get_allow_ram_cache
84 // Access: Published, Virtual
85 // Description: Returns true if the loader flags allow retrieving the
86 // model from the in-memory ModelPool cache, false
87 // otherwise.
88 ////////////////////////////////////////////////////////////////////
90 get_allow_ram_cache(const LoaderOptions &options) const {
91  return (options.get_flags() & (LoaderOptions::LF_no_ram_cache | _no_cache_flags)) == 0;
92 }
93 
94 ////////////////////////////////////////////////////////////////////
95 // Function: LoaderFileType::supports_load
96 // Access: Published, Virtual
97 // Description: Returns true if the file type can be used to load
98 // files, and load_file() is supported. Returns false
99 // if load_file() is unimplemented and will always fail.
100 ////////////////////////////////////////////////////////////////////
101 bool LoaderFileType::
102 supports_load() const {
103  return true;
104 }
105 
106 ////////////////////////////////////////////////////////////////////
107 // Function: LoaderFileType::supports_save
108 // Access: Published, Virtual
109 // Description: Returns true if the file type can be used to save
110 // files, and save_file() is supported. Returns false
111 // if save_file() is unimplemented and will always fail.
112 ////////////////////////////////////////////////////////////////////
113 bool LoaderFileType::
114 supports_save() const {
115  return false;
116 }
117 
118 ////////////////////////////////////////////////////////////////////
119 // Function: LoaderFileType::load_file
120 // Access: Public, Virtual
121 // Description:
122 ////////////////////////////////////////////////////////////////////
124 load_file(const Filename &path, const LoaderOptions &options,
125  BamCacheRecord *record) const {
126  loader_cat.error()
127  << get_type() << " cannot read PandaNode objects.\n";
128  return NULL;
129 }
130 
131 ////////////////////////////////////////////////////////////////////
132 // Function: LoaderFileType::save_file
133 // Access: Public, Virtual
134 // Description:
135 ////////////////////////////////////////////////////////////////////
136 bool LoaderFileType::
137 save_file(const Filename &path, const LoaderOptions &options,
138  PandaNode *node) const {
139  loader_cat.error()
140  << get_type() << " cannot save PandaNode objects.\n";
141  return false;
142 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
Specifies parameters that may be passed to the loader.
Definition: loaderOptions.h:26
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...
virtual bool supports_load() const
Returns true if the file type can be used to load files, and load_file() is supported.
virtual bool supports_save() const
Returns true if the file type can be used to save files, and save_file() is supported.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
virtual string get_additional_extensions() const
Returns a space-separated list of extension, in addition to the one returned by get_extension(), that are recognized by this loader.
This is the base class for a family of scene-graph file types that the Loader supports.
virtual bool supports_compressed() const
Returns true if this file type can transparently load compressed files (with a .pz extension)...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
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 enab...