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

panda/src/pnmimage/pnmFileTypeRegistry.h

Go to the documentation of this file.
00001 // Filename: pnmFileTypeRegistry.h
00002 // Created by:  drose (15Jun00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef PNMFILETYPEREGISTRY_H
00020 #define PNMFILETYPEREGISTRY_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include <typedObject.h>
00025 
00026 class PNMFileType;
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //       Class : PNMFileTypeRegistry
00030 // Description : This class maintains the set of all known
00031 //               PNMFileTypes in the universe.
00032 ////////////////////////////////////////////////////////////////////
00033 class EXPCL_PANDA PNMFileTypeRegistry {
00034 protected:
00035   PNMFileTypeRegistry();
00036 
00037 public:
00038   ~PNMFileTypeRegistry();
00039 
00040   static PNMFileTypeRegistry *get_ptr();
00041 
00042   int get_num_types() const;
00043   PNMFileType *get_type(int n) const;
00044 
00045   PNMFileType *get_type_from_extension(const string &filename) const;
00046   PNMFileType *get_type_from_magic_number(const string &magic_number) const;
00047   PNMFileType *get_type_by_handle(TypeHandle handle) const;
00048 
00049   void write_types(ostream &out, int indent_level = 0) const;
00050 
00051   void register_type(PNMFileType *type);
00052 
00053 private:
00054   void sort_preferences();
00055 
00056   typedef pvector<PNMFileType *> Types;
00057   Types _types;
00058 
00059   typedef pmap<string, Types> Extensions;
00060   Extensions _extensions;
00061 
00062   typedef pmap<TypeHandle, PNMFileType *> Handles;
00063   Handles _handles;
00064 
00065   bool _requires_sort;
00066 
00067   static PNMFileTypeRegistry *_global_ptr;
00068 };
00069 
00070 #endif
00071 

Generated on Fri May 2 00:43:07 2003 for Panda by doxygen1.3