Panda3D
|
00001 // Filename: pnmFileType.cxx 00002 // Created by: drose (15Jun00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "pnmFileType.h" 00016 00017 #include "string_utils.h" 00018 #include "executionEnvironment.h" 00019 #include "bamReader.h" 00020 #include "bamWriter.h" 00021 00022 bool PNMFileType::_did_init_pnm = false; 00023 TypeHandle PNMFileType::_type_handle; 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Function: PNMFileType::Constructor 00027 // Access: Protected 00028 // Description: 00029 //////////////////////////////////////////////////////////////////// 00030 PNMFileType:: 00031 PNMFileType() { 00032 } 00033 00034 //////////////////////////////////////////////////////////////////// 00035 // Function: PNMFileType::Destructor 00036 // Access: Public, Virtual 00037 // Description: 00038 //////////////////////////////////////////////////////////////////// 00039 PNMFileType:: 00040 ~PNMFileType() { 00041 } 00042 00043 //////////////////////////////////////////////////////////////////// 00044 // Function: PNMFileType::get_num_extensions 00045 // Access: Published, Virtual 00046 // Description: Returns the number of different possible filename 00047 // extensions associated with this particular file type. 00048 //////////////////////////////////////////////////////////////////// 00049 int PNMFileType:: 00050 get_num_extensions() const { 00051 return 0; 00052 } 00053 00054 //////////////////////////////////////////////////////////////////// 00055 // Function: PNMFileType::get_extension 00056 // Access: Published, Virtual 00057 // Description: Returns the nth possible filename extension 00058 // associated with this particular file type, without a 00059 // leading dot. 00060 //////////////////////////////////////////////////////////////////// 00061 string PNMFileType:: 00062 get_extension(int) const { 00063 nassertr(false, string()); 00064 return string(); 00065 } 00066 00067 //////////////////////////////////////////////////////////////////// 00068 // Function: PNMFileType::get_suggested_extension 00069 // Access: Published, Virtual 00070 // Description: Returns a suitable filename extension (without a 00071 // leading dot) to suggest for files of this type, or 00072 // empty string if no suggestions are available. 00073 //////////////////////////////////////////////////////////////////// 00074 string PNMFileType:: 00075 get_suggested_extension() const { 00076 if (get_num_extensions() > 0) { 00077 return get_extension(0); 00078 } 00079 return string(); 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function: PNMFileType::has_magic_number 00084 // Access: Public, Virtual 00085 // Description: Returns true if this particular file type uses a 00086 // magic number to identify it, false otherwise. 00087 //////////////////////////////////////////////////////////////////// 00088 bool PNMFileType:: 00089 has_magic_number() const { 00090 return false; 00091 } 00092 00093 //////////////////////////////////////////////////////////////////// 00094 // Function: PNMFileType::matches_magic_number 00095 // Access: Public, Virtual 00096 // Description: Returns true if the indicated "magic number" byte 00097 // stream (the initial few bytes read from the file) 00098 // matches this particular file type, false otherwise. 00099 //////////////////////////////////////////////////////////////////// 00100 bool PNMFileType:: 00101 matches_magic_number(const string &) const { 00102 return false; 00103 } 00104 00105 //////////////////////////////////////////////////////////////////// 00106 // Function: PNMFileType::make_reader 00107 // Access: Public, Virtual 00108 // Description: Allocates and returns a new PNMReader suitable for 00109 // reading from this file type, if possible. If reading 00110 // from this file type is not supported, returns NULL. 00111 //////////////////////////////////////////////////////////////////// 00112 PNMReader *PNMFileType:: 00113 make_reader(istream *, bool, const string &) { 00114 return NULL; 00115 } 00116 00117 //////////////////////////////////////////////////////////////////// 00118 // Function: PNMFileType::make_writer 00119 // Access: Public, Virtual 00120 // Description: Allocates and returns a new PNMWriter suitable for 00121 // reading from this file type, if possible. If writing 00122 // files of this type is not supported, returns NULL. 00123 //////////////////////////////////////////////////////////////////// 00124 PNMWriter *PNMFileType:: 00125 make_writer(ostream *, bool) { 00126 return NULL; 00127 } 00128 00129 //////////////////////////////////////////////////////////////////// 00130 // Function: PNMFileType::init_pnm 00131 // Access: Protected, Static 00132 // Description: Initializes the underlying PNM library, if it has not 00133 // already been initialized. This should be called by 00134 // every implementation of make_reader() and 00135 // make_writer(), to ensure that the library is properly 00136 // initialized before any I/O is attempted. 00137 //////////////////////////////////////////////////////////////////// 00138 void PNMFileType:: 00139 init_pnm() { 00140 if (!_did_init_pnm) { 00141 _did_init_pnm = true; 00142 00143 // No reason to do anything here nowadays. 00144 } 00145 } 00146 00147 //////////////////////////////////////////////////////////////////// 00148 // Function: PNMFileType::write_datagram 00149 // Access: Public, Virtual 00150 // Description: Fills the indicated datagram up with a binary 00151 // representation of the current object, in preparation 00152 // for writing to a Bam file. 00153 // 00154 // None of the particular PNMFileType objects store any 00155 // extra data--at least, not yet--so we just define this 00156 // up here to do nothing. 00157 //////////////////////////////////////////////////////////////////// 00158 void PNMFileType:: 00159 write_datagram(BamWriter *, Datagram &) { 00160 }