Panda3D
|
00001 // Filename: pnmFileTypeRegistry.h 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 #ifndef PNMFILETYPEREGISTRY_H 00016 #define PNMFILETYPEREGISTRY_H 00017 00018 #include "pandabase.h" 00019 00020 #include "typedObject.h" 00021 #include "pmap.h" 00022 #include "pvector.h" 00023 00024 class PNMFileType; 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : PNMFileTypeRegistry 00028 // Description : This class maintains the set of all known 00029 // PNMFileTypes in the universe. 00030 //////////////////////////////////////////////////////////////////// 00031 class EXPCL_PANDA_PNMIMAGE PNMFileTypeRegistry { 00032 protected: 00033 PNMFileTypeRegistry(); 00034 00035 public: 00036 ~PNMFileTypeRegistry(); 00037 00038 void register_type(PNMFileType *type); 00039 00040 PUBLISHED: 00041 int get_num_types() const; 00042 PNMFileType *get_type(int n) const; 00043 MAKE_SEQ(get_types, get_num_types, get_type); 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(ostream &out, int indent_level = 0) const; 00050 00051 static PNMFileTypeRegistry *get_global_ptr(); 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