Panda3D

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
PNMFileType Class Referenceabstract

This is the base class of a family of classes that represent particular image file types that PNMImage supports. More...

`#include "pnmFileType.h"`

Inheritance diagram for PNMFileType:

## Public Member Functions
virtual TypeHandle | force_init_type ()
virtual std::string | get_extension (int n) const
virtual std::string | get_name () const =0
virtual int | get_num_extensions () const
virtual std::string | get_suggested_extension () const
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 (std::istream *file, bool owns_file=true, const std::string &magic_number=std::string())
| Allocates and returns a new PNMReader suitable for reading from this file type, if possible.
virtual PNMWriter * | make_writer (std::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 std::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.
Public Member Functions inherited from TypedWritable
| TypedWritable (const TypedWritable &copy)
virtual ReferenceCount * | as_reference_count ()
| Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type.
virtual int | complete_pointers (TypedWritable **p_list, BamReader *manager)
| Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
vector_uchar | encode_to_bam_stream () const
| Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object.
bool | encode_to_bam_stream (vector_uchar &data, BamWriter *writer=nullptr) const
| Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string.
virtual void | fillin (DatagramIterator &scan, BamReader *manager)
| This internal function is intended to be called by each class's make_from_bam() method to read in all of the relevant data from the BamFile for the new object.
virtual void | finalize (BamReader *manager)
| Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed.
UpdateSeq | get_bam_modified () const
| Returns the current bam_modified counter.
void | mark_bam_modified ()
| Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams.
void | operator= (const TypedWritable &copy)
virtual bool | require_fully_complete () const
| Some objects require all of their nested pointers to have been completed before the objects themselves can be completed.
virtual void | update_bam_nested (BamWriter *manager)
| Called by the BamWriter when this object has not itself been modified recently, but it should check its nested objects for updates.
Public Member Functions inherited from TypedObject
| TypedObject (const TypedObject &copy)=default
TypedObject * | as_typed_object ()
| Returns the object, upcast (if necessary) to a TypedObject pointer.
const TypedObject * | as_typed_object () const
| Returns the object, upcast (if necessary) to a TypedObject pointer.
int | get_best_parent_from_Set (const std::set< int > &) const
int | get_type_index () const
| Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.
bool | is_exact_type (TypeHandle handle) const
| Returns true if the current object is the indicated type exactly.
bool | is_of_type (TypeHandle handle) const
| Returns true if the current object is or derives from the indicated type.
TypedObject & | operator= (const TypedObject &copy)=default
Public Member Functions inherited from MemoryBase
void | operator delete (void *, void *)
void | operator delete (void *ptr)
void | operator delete[] (void *, void *)
void | operator delete[] (void *ptr)
void * | operator new (size_t size)
void * | operator new (size_t size, void *ptr)
void * | operator new[] (size_t size)
void * | operator new[] (size_t size, void *ptr)

## Static Public Member Functions
static TypeHandle | get_class_type ()
static void | init_type ()
static void | register_with_read_factory ()
Static Public Member Functions inherited from TypedWritable
static bool | decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, BamReader *reader=nullptr)
| Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts the single object on those bytes.
static TypeHandle | get_class_type ()
static void | init_type ()
Static Public Member Functions inherited from TypedObject
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.

## Public Attributes
| get_extension
| Returns the nth possible filename extension associated with this particular file type, without a leading dot.
| get_name
| get_num_extensions
| Returns the number of different possible filename extensions associated with this particular file type.
| get_suggested_extension
| Returns a suitable filename extension (without a leading dot) to suggest for files of this type, or empty string if no suggestions are available.
Public Attributes inherited from TypedObject
| get_type

## Additional Inherited Members
Static Public Attributes inherited from TypedWritable
static TypedWritable *const | Null = nullptr

## Detailed Description

This is the base class of a family of classes that represent particular image file types that PNMImage supports.

Definition at line 32 of file pnmFileType.h.

## Constructor & Destructor Documentation

## ◆ ~PNMFileType()

PNMFileType::~PNMFileType | ( |  | ) |
| virtual

Definition at line 36 of file pnmFileType.cxx.

## Member Function Documentation

## ◆ force_init_type()

virtual TypeHandle PNMFileType::force_init_type | ( |  | ) |
| inline virtual

Reimplemented from TypedWritable.

Definition at line 86 of file pnmFileType.h.

## ◆ get_class_type()

static TypeHandle PNMFileType::get_class_type | ( |  | ) |
| inline static

Definition at line 75 of file pnmFileType.h.

## ◆ get_extension()

virtual std::string PNMFileType::get_extension | ( | int | n | ) | const
| virtual

Reimplemented in PNMFileTypePfm.

## ◆ get_name()

virtual std::string PNMFileType::get_name | ( |  | ) | const
| pure virtual

Implemented in PNMFileTypePfm.

## ◆ get_num_extensions()

virtual int PNMFileType::get_num_extensions | ( |  | ) | const
| virtual

Reimplemented in PNMFileTypePfm.

## ◆ get_suggested_extension()

virtual std::string PNMFileType::get_suggested_extension | ( |  | ) | const
| virtual

Reimplemented in PNMFileTypePfm.

## ◆ get_type()

virtual TypeHandle PNMFileType::get_type | ( |  | ) | const
| inline virtual

Reimplemented from TypedWritable.

Definition at line 83 of file pnmFileType.h.

## ◆ has_magic_number()

bool PNMFileType::has_magic_number | ( |  | ) | const
| virtual

Returns true if this particular file type uses a magic number to identify it, false otherwise.

Reimplemented in PNMFileTypePfm.

Definition at line 75 of file pnmFileType.cxx.

Referenced by PNMFileTypeRegistry::get_type_from_magic_number().

## ◆ init_type()

static void PNMFileType::init_type | ( |  | ) |
| inline static

Definition at line 78 of file pnmFileType.h.

## ◆ make_reader()

PNMReader * PNMFileType::make_reader | ( | std::istream * | file,
|  | bool | owns_file = true,
|  | const std::string & | magic_number = std::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.

Reimplemented in PNMFileTypePfm.

Definition at line 95 of file pnmFileType.cxx.

Referenced by PNMImageHeader::make_reader().

## ◆ make_writer()

PNMWriter * PNMFileType::make_writer | ( | std::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.

Reimplemented in PNMFileTypePfm.

Definition at line 105 of file pnmFileType.cxx.

Referenced by PNMImageHeader::make_writer().

## ◆ matches_magic_number()

bool PNMFileType::matches_magic_number | ( | const std::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.

Reimplemented in PNMFileTypePfm.

Definition at line 85 of file pnmFileType.cxx.

Referenced by PNMFileTypeRegistry::get_type_from_magic_number().

## ◆ write_datagram()

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 132 of file pnmFileType.cxx.

## Member Data Documentation

## ◆ get_extension

string PNMFileType::get_extension

Returns the nth possible filename extension associated with this particular file type, without a leading dot.

Definition at line 44 of file pnmFileType.h.

Referenced by PNMFileTypeRegistry::register_type(), and PNMFileTypeRegistry::write().

## ◆ get_name

PNMFileType::get_name

Definition at line 47 of file pnmFileType.h.

## ◆ get_num_extensions

int PNMFileType::get_num_extensions

Returns the number of different possible filename extensions associated with this particular file type.

Definition at line 44 of file pnmFileType.h.

Referenced by PNMFileTypeRegistry::register_type(), and PNMFileTypeRegistry::write().

## ◆ get_suggested_extension

string PNMFileType::get_suggested_extension

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 49 of file pnmFileType.h.

The documentation for this class was generated from the following files:

- panda/src/pnmimage/pnmFileType.h
- panda/src/pnmimage/pnmFileType.cxx