00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00030
00031
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