Panda3D
Loading...
Searching...
No Matches
pnmFileTypeRegistry.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file pnmFileTypeRegistry.h
10 * @author drose
11 * @date 2000-06-15
12 */
13
14#ifndef PNMFILETYPEREGISTRY_H
15#define PNMFILETYPEREGISTRY_H
16
17#include "pandabase.h"
18
19#include "typedObject.h"
20#include "pmap.h"
21#include "pvector.h"
22
23class PNMFileType;
24
25/**
26 * This class maintains the set of all known PNMFileTypes in the universe.
27 */
28class EXPCL_PANDA_PNMIMAGE PNMFileTypeRegistry {
29protected:
30 PNMFileTypeRegistry();
31
32public:
33 ~PNMFileTypeRegistry();
34
35 void register_type(PNMFileType *type);
36 void unregister_type(PNMFileType *type);
37
38PUBLISHED:
39 int get_num_types() const;
40 PNMFileType *get_type(int n) const;
41 MAKE_SEQ(get_types, get_num_types, get_type);
42 MAKE_SEQ_PROPERTY(types, get_num_types, get_type);
43
44 PNMFileType *get_type_from_extension(const std::string &filename) const;
45 PNMFileType *get_type_from_magic_number(const std::string &magic_number) const;
47
48 void write(std::ostream &out, int indent_level = 0) const;
49
50 static PNMFileTypeRegistry *get_global_ptr();
51
52private:
53 void sort_preferences();
54
55 typedef pvector<PNMFileType *> Types;
56 Types _types;
57
58 typedef pmap<std::string, Types> Extensions;
59 Extensions _extensions;
60
61 typedef pmap<TypeHandle, PNMFileType *> Handles;
62 Handles _handles;
63
64 bool _requires_sort;
65
66 static PNMFileTypeRegistry *_global_ptr;
67};
68
69#endif
get_num_types
Returns the total number of types registered.
PNMFileType * get_type_from_magic_number(const std::string &magic_number) const
Tries to determine what the PNMFileType is likely to be for a particular image file based on its magi...
PNMFileType * get_type_by_handle(TypeHandle handle) const
Returns the PNMFileType instance stored in the registry for the given TypeHandle, e....
static PNMFileTypeRegistry * get_global_ptr()
Returns a pointer to the global PNMFileTypeRegistry object.
void write(std::ostream &out, int indent_level=0) const
Writes a list of supported image file types to the indicated output stream, one per line.
get_type
Returns the nth type registered.
void unregister_type(PNMFileType *type)
Removes a PNMFileType previously passed to register_type.
PNMFileType * get_type_from_extension(const std::string &filename) const
Tries to determine what the PNMFileType is likely to be for a particular image file based on its exte...
This is the base class of a family of classes that represent particular image file types that PNMImag...
Definition pnmFileType.h:32
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.