Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PNMFileTypeRegistry Class Reference

This class maintains the set of all known PNMFileTypes in the universe. More...

#include <pnmFileTypeRegistry.h>

List of all members.

Public Member Functions

 ~PNMFileTypeRegistry ()
int get_num_types () const
 Returns the total number of types registered.

PNMFileTypeget_type (int n) const
 Returns the nth type registered.

PNMFileTypeget_type_from_extension (const string &filename) const
 Tries to determine what the PNMFileType is likely to be for a particular image file based on its extension.

PNMFileTypeget_type_from_magic_number (const string &magic_number) const
 Tries to determine what the PNMFileType is likely to be for a particular image file based on its magic number, the first two bytes read from the file.

PNMFileTypeget_type_by_handle (TypeHandle handle) const
 Returns the PNMFileType instance stored in the registry for the given TypeHandle, e.g.

void write_types (ostream &out, int indent_level=0) const
 Writes a list of supported image file types to the indicated output stream, one per line.

void register_type (PNMFileType *type)
 Defines a new PNMFileType in the universe.


Static Public Member Functions

PNMFileTypeRegistry * get_ptr ()
 Returns a pointer to the global PNMFileTypeRegistry object.


Protected Member Functions

 PNMFileTypeRegistry ()

Private Types

typedef pvector< PNMFileType * > Types
typedef pmap< string, TypesExtensions
typedef pmap< TypeHandle,
PNMFileType * > 
Handles

Private Member Functions

void sort_preferences ()
 Sorts the PNMFileType pointers in order according to user-specified preferences in the config file.


Private Attributes

Types _types
Extensions _extensions
Handles _handles
bool _requires_sort

Static Private Attributes

PNMFileTypeRegistry * _global_ptr


Detailed Description

This class maintains the set of all known PNMFileTypes in the universe.

Definition at line 40 of file pnmFileTypeRegistry.h.


Member Typedef Documentation

typedef pmap<string, Types> PNMFileTypeRegistry::Extensions [private]
 

Definition at line 66 of file pnmFileTypeRegistry.h.

typedef pmap<TypeHandle, PNMFileType *> PNMFileTypeRegistry::Handles [private]
 

Definition at line 69 of file pnmFileTypeRegistry.h.

typedef pvector<PNMFileType *> PNMFileTypeRegistry::Types [private]
 

Definition at line 63 of file pnmFileTypeRegistry.h.


Constructor & Destructor Documentation

PNMFileTypeRegistry::PNMFileTypeRegistry  )  [protected]
 

Definition at line 42 of file pnmFileTypeRegistry.cxx.

PNMFileTypeRegistry::~PNMFileTypeRegistry  ) 
 

Definition at line 54 of file pnmFileTypeRegistry.cxx.

References _global_ptr, and NULL.


Member Function Documentation

int PNMFileTypeRegistry::get_num_types  )  const
 

Returns the total number of types registered.

Definition at line 84 of file pnmFileTypeRegistry.cxx.

References _types, and NULL.

PNMFileTypeRegistry * PNMFileTypeRegistry::get_ptr  )  [static]
 

Returns a pointer to the global PNMFileTypeRegistry object.

Definition at line 68 of file pnmFileTypeRegistry.cxx.

References _types.

Referenced by PNMFileTypeSGI::make_reader(), PNMFileTypeJPG2000::make_reader(), PNMFileTypeJPG::make_reader(), PNMFileTypeBMP::make_reader(), PNMImageHeader::make_writer(), PNMFileTypeSoftImage::Writer::write_header(), and PNMFileTypeAlias::Writer::write_header().

PNMFileType * PNMFileTypeRegistry::get_type int  n  )  const
 

Returns the nth type registered.

Definition at line 100 of file pnmFileTypeRegistry.cxx.

PNMFileType * PNMFileTypeRegistry::get_type_by_handle TypeHandle  handle  )  const
 

Returns the PNMFileType instance stored in the registry for the given TypeHandle, e.g.

as retrieved by a previous call to get_type() on the type instance.

Definition at line 205 of file pnmFileTypeRegistry.cxx.

Referenced by PNMFileTypeSGI::make_reader(), PNMFileTypeJPG2000::make_reader(), PNMFileTypeJPG::make_reader(), PNMFileTypeBMP::make_reader(), PNMFileTypeSoftImage::Writer::write_header(), and PNMFileTypeAlias::Writer::write_header().

PNMFileType * PNMFileTypeRegistry::get_type_from_extension const string &  filename  )  const
 

Tries to determine what the PNMFileType is likely to be for a particular image file based on its extension.

Returns a suitable PNMFileType pointer, or NULL if no type can be determined.

Definition at line 120 of file pnmFileTypeRegistry.cxx.

Referenced by PNMImageHeader::make_writer().

PNMFileType * PNMFileTypeRegistry::get_type_from_magic_number const string &  magic_number  )  const
 

Tries to determine what the PNMFileType is likely to be for a particular image file based on its magic number, the first two bytes read from the file.

Returns a suitable PNMFileType pointer, or NULL if no type can be determined.

Definition at line 173 of file pnmFileTypeRegistry.cxx.

void PNMFileTypeRegistry::register_type PNMFileType type  ) 
 

Defines a new PNMFileType in the universe.

Definition at line 260 of file pnmFileTypeRegistry.cxx.

References _requires_sort.

void PNMFileTypeRegistry::sort_preferences  )  [private]
 

Sorts the PNMFileType pointers in order according to user-specified preferences in the config file.

This allows us to choose a particular PNMFileType over another for particular extensions when multiple file types map to the same extension, or for file types that have no magic number.

Definition at line 314 of file pnmFileTypeRegistry.cxx.

void PNMFileTypeRegistry::write_types ostream &  out,
int  indent_level = 0
const
 

Writes a list of supported image file types to the indicated output stream, one per line.

Definition at line 226 of file pnmFileTypeRegistry.cxx.

References _handles, and _types.


Member Data Documentation

Extensions PNMFileTypeRegistry::_extensions [private]
 

Definition at line 67 of file pnmFileTypeRegistry.h.

PNMFileTypeRegistry * PNMFileTypeRegistry::_global_ptr [static, private]
 

Definition at line 32 of file pnmFileTypeRegistry.cxx.

Referenced by ~PNMFileTypeRegistry().

Handles PNMFileTypeRegistry::_handles [private]
 

Definition at line 70 of file pnmFileTypeRegistry.h.

Referenced by write_types().

bool PNMFileTypeRegistry::_requires_sort [private]
 

Definition at line 72 of file pnmFileTypeRegistry.h.

Referenced by register_type().

Types PNMFileTypeRegistry::_types [private]
 

Definition at line 64 of file pnmFileTypeRegistry.h.

Referenced by get_num_types(), get_ptr(), and write_types().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:53:56 2003 for Panda by doxygen1.3