Panda3D
 All Classes Functions Variables Enumerations
pnmFileTypeRegistry.h
1 // Filename: pnmFileTypeRegistry.h
2 // Created by: drose (15Jun00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef PNMFILETYPEREGISTRY_H
16 #define PNMFILETYPEREGISTRY_H
17 
18 #include "pandabase.h"
19 
20 #include "typedObject.h"
21 #include "pmap.h"
22 #include "pvector.h"
23 
24 class PNMFileType;
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : PNMFileTypeRegistry
28 // Description : This class maintains the set of all known
29 // PNMFileTypes in the universe.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDA_PNMIMAGE PNMFileTypeRegistry {
32 protected:
34 
35 public:
37 
38  void register_type(PNMFileType *type);
39 
40 PUBLISHED:
41  int get_num_types() const;
42  PNMFileType *get_type(int n) const;
43  MAKE_SEQ(get_types, get_num_types, get_type);
44 
45  PNMFileType *get_type_from_extension(const string &filename) const;
46  PNMFileType *get_type_from_magic_number(const string &magic_number) const;
47  PNMFileType *get_type_by_handle(TypeHandle handle) const;
48 
49  void write(ostream &out, int indent_level = 0) const;
50 
51  static PNMFileTypeRegistry *get_global_ptr();
52 
53 private:
54  void sort_preferences();
55 
57  Types _types;
58 
60  Extensions _extensions;
61 
63  Handles _handles;
64 
65  bool _requires_sort;
66 
67  static PNMFileTypeRegistry *_global_ptr;
68 };
69 
70 #endif
71 
This is the base class of a family of classes that represent particular image file types that PNMImag...
Definition: pnmFileType.h:35
This class maintains the set of all known PNMFileTypes in the universe.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85