Panda3D
|
This is the base class of a family of classes that represent particular image file types that PNMImage supports. More...
#include "pnmFileType.h"
Public Member Functions | |
virtual TypeHandle | force_init_type () |
virtual string | get_extension (int n) const |
Returns the nth possible filename extension associated with this particular file type, without a leading dot. | |
virtual string | get_name () const =0 |
virtual int | get_num_extensions () const |
Returns the number of different possible filename extensions associated with this particular file type. | |
virtual string | get_suggested_extension () const |
Returns a suitable filename extension (without a leading dot) to suggest for files of this type, or empty string if no suggestions are available. | |
virtual TypeHandle | get_type () const |
virtual bool | has_magic_number () const |
Returns true if this particular file type uses a magic number to identify it, false otherwise. | |
virtual PNMReader * | make_reader (istream *file, bool owns_file=true, const string &magic_number=string()) |
Allocates and returns a new PNMReader suitable for reading from this file type, if possible. | |
MAKE_SEQ (get_extensions, get_num_extensions, get_extension) | |
virtual PNMWriter * | make_writer (ostream *file, bool owns_file=true) |
Allocates and returns a new PNMWriter suitable for reading from this file type, if possible. | |
virtual bool | matches_magic_number (const string &magic_number) const |
Returns true if the indicated "magic number" byte stream (the initial few bytes read from the file) matches this particular file type, false otherwise. | |
virtual void | write_datagram (BamWriter *writer, Datagram &datagram) |
Fills the indicated datagram up with a binary representation of the current object, in preparation for writing to a Bam file. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. | |
static void | register_with_read_factory () |
Static Protected Member Functions | |
static void | init_pnm () |
Initializes the underlying PNM library, if it has not already been initialized. | |
static TypedWritable * | make_PNMFileType (const FactoryParams ¶ms) |
This is the base class of a family of classes that represent particular image file types that PNMImage supports.
Definition at line 35 of file pnmFileType.h.
string PNMFileType::get_extension | ( | int | n | ) | const [virtual] |
Returns the nth possible filename extension associated with this particular file type, without a leading dot.
Definition at line 62 of file pnmFileType.cxx.
Referenced by get_suggested_extension(), PNMFileTypeRegistry::register_type(), and PNMFileTypeRegistry::write().
int PNMFileType::get_num_extensions | ( | ) | const [virtual] |
Returns the number of different possible filename extensions associated with this particular file type.
Definition at line 50 of file pnmFileType.cxx.
Referenced by get_suggested_extension(), PNMFileTypeRegistry::register_type(), and PNMFileTypeRegistry::write().
string PNMFileType::get_suggested_extension | ( | ) | const [virtual] |
Returns a suitable filename extension (without a leading dot) to suggest for files of this type, or empty string if no suggestions are available.
Definition at line 75 of file pnmFileType.cxx.
References get_extension(), and get_num_extensions().
Referenced by Palettizer::report_pi(), and ImageFile::set_filename().
bool PNMFileType::has_magic_number | ( | ) | const [virtual] |
Returns true if this particular file type uses a magic number to identify it, false otherwise.
Definition at line 89 of file pnmFileType.cxx.
Referenced by PNMFileTypeRegistry::get_type_from_magic_number().
void PNMFileType::init_pnm | ( | ) | [static, protected] |
Initializes the underlying PNM library, if it has not already been initialized.
This should be called by every implementation of make_reader() and make_writer(), to ensure that the library is properly initialized before any I/O is attempted.
Definition at line 139 of file pnmFileType.cxx.
static void PNMFileType::init_type | ( | ) | [inline, static] |
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Making it inline seems to cause problems in the optimizer.
Reimplemented from TypedWritable.
Definition at line 77 of file pnmFileType.h.
References TypedWritable::init_type().
PNMReader * PNMFileType::make_reader | ( | istream * | file, |
bool | owns_file = true , |
||
const string & | magic_number = string() |
||
) | [virtual] |
Allocates and returns a new PNMReader suitable for reading from this file type, if possible.
If reading from this file type is not supported, returns NULL.
Definition at line 113 of file pnmFileType.cxx.
Referenced by PNMImageHeader::make_reader().
PNMWriter * PNMFileType::make_writer | ( | ostream * | file, |
bool | owns_file = true |
||
) | [virtual] |
Allocates and returns a new PNMWriter suitable for reading from this file type, if possible.
If writing files of this type is not supported, returns NULL.
Definition at line 125 of file pnmFileType.cxx.
Referenced by PNMImageHeader::make_writer().
bool PNMFileType::matches_magic_number | ( | const string & | magic_number | ) | const [virtual] |
Returns true if the indicated "magic number" byte stream (the initial few bytes read from the file) matches this particular file type, false otherwise.
Definition at line 101 of file pnmFileType.cxx.
Referenced by PNMFileTypeRegistry::get_type_from_magic_number().
void PNMFileType::write_datagram | ( | BamWriter * | writer, |
Datagram & | datagram | ||
) | [virtual] |
Fills the indicated datagram up with a binary representation of the current object, in preparation for writing to a Bam file.
None of the particular PNMFileType objects store any extra data--at least, not yet--so we just define this up here to do nothing.
Reimplemented from TypedWritable.
Definition at line 159 of file pnmFileType.cxx.