loaderFileTypeRegistry.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Filename: loaderFileTypeRegistry.h
  2. // Created by: drose (20Jun00)
  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. #ifndef LOADERFILETYPEREGISTRY_H
  15. #define LOADERFILETYPEREGISTRY_H
  16. #include "pandabase.h"
  17. #include "pvector.h"
  18. #include "pmap.h"
  19. class LoaderFileType;
  20. class Filename;
  21. ////////////////////////////////////////////////////////////////////
  22. // Class : LoaderFileTypeRegistry
  23. // Description : This class maintains the set of all known
  24. // LoaderFileTypes in the universe.
  25. ////////////////////////////////////////////////////////////////////
  26. class EXPCL_PANDA_PGRAPH LoaderFileTypeRegistry {
  27. protected:
  28. LoaderFileTypeRegistry();
  29. public:
  30. ~LoaderFileTypeRegistry();
  31. void register_type(LoaderFileType *type);
  32. void register_deferred_type(const string &extension, const string &library);
  33. PUBLISHED:
  34. int get_num_types() const;
  35. LoaderFileType *get_type(int n) const;
  36. MAKE_SEQ(get_types, get_num_types, get_type);
  37. LoaderFileType *get_type_from_extension(const string &extension);
  38. void write(ostream &out, int indent_level = 0) const;
  39. static LoaderFileTypeRegistry *get_global_ptr();
  40. private:
  41. void record_extension(const string &extension, LoaderFileType *type);
  42. private:
  43. typedef pvector<LoaderFileType *> Types;
  44. Types _types;
  45. typedef pmap<string, LoaderFileType *> Extensions;
  46. Extensions _extensions;
  47. typedef pmap<string, string> DeferredTypes;
  48. DeferredTypes _deferred_types;
  49. static LoaderFileTypeRegistry *_global_ptr;
  50. };
  51. #endif