Panda3D
Loading...
Searching...
No Matches
loaderFileTypeRegistry.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 loaderFileTypeRegistry.h
10 * @author drose
11 * @date 2000-06-20
12 */
13
14#ifndef LOADERFILETYPEREGISTRY_H
15#define LOADERFILETYPEREGISTRY_H
16
17#include "pandabase.h"
18
19#include "pvector.h"
20#include "pmap.h"
21
22class LoaderFileType;
23class Filename;
24
25/**
26 * This class maintains the set of all known LoaderFileTypes in the universe.
27 */
28class EXPCL_PANDA_PGRAPH LoaderFileTypeRegistry {
29protected:
30 LoaderFileTypeRegistry();
31
32public:
33 ~LoaderFileTypeRegistry();
34
35 void register_type(LoaderFileType *type);
36 void register_deferred_type(const std::string &extension, const std::string &library);
37
39
40PUBLISHED:
41 EXTENSION(void register_type(PyObject *type));
42 EXTENSION(void register_deferred_type(PyObject *entry_point));
43
44 EXTENSION(void unregister_type(PyObject *type));
45
46 int get_num_types() const;
47 LoaderFileType *get_type(int n) const;
48 MAKE_SEQ(get_types, get_num_types, get_type);
49 MAKE_SEQ_PROPERTY(types, get_num_types, get_type);
50 LoaderFileType *get_type_from_extension(const std::string &extension);
51
52 void write(std::ostream &out, int indent_level = 0) const;
53
54 static LoaderFileTypeRegistry *get_global_ptr();
55
56 EXTENSION(PyObject *__reduce__() const);
57
58private:
59 void record_extension(const std::string &extension, LoaderFileType *type);
60
61private:
62 typedef pvector<LoaderFileType *> Types;
63 Types _types;
64
65 typedef pmap<std::string, LoaderFileType *> Extensions;
66 Extensions _extensions;
67
68 typedef pmap<std::string, std::string> DeferredTypes;
69 DeferredTypes _deferred_types;
70
71 static LoaderFileTypeRegistry *_global_ptr;
72};
73
74#endif
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
get_num_types
Returns the total number of types registered.
get_type
Returns the nth type registered.
void write(std::ostream &out, int indent_level=0) const
Writes a list of supported file types to the indicated output stream, one per line.
static LoaderFileTypeRegistry * get_global_ptr()
Returns a pointer to the global LoaderFileTypeRegistry object.
void unregister_type(LoaderFileType *type)
Removes a type previously registered using register_type.
LoaderFileType * get_type_from_extension(const std::string &extension)
Determines the type of the file based on the indicated extension (without a leading dot).
void register_deferred_type(const std::string &extension, const std::string &library)
Records a type associated with a particular extension to be loaded in the future.
This is the base class for a family of scene-graph file types that the Loader supports.
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(),...