loader.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // Filename: loader.h
  2. // Created by: mike (09Jan97)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef LOADER_H
  19. #define LOADER_H
  20. #include "pandabase.h"
  21. #include "loaderOptions.h"
  22. #include "pnotify.h"
  23. #include "pandaNode.h"
  24. #include "filename.h"
  25. #include "tokenBoard.h"
  26. #include "asyncUtility.h"
  27. #include "dSearchPath.h"
  28. class LoaderToken;
  29. class LoaderFileType;
  30. ////////////////////////////////////////////////////////////////////
  31. // Class : Loader
  32. // Description : Handles database loading through asynchronous
  33. // threading
  34. ////////////////////////////////////////////////////////////////////
  35. class EXPCL_PANDA Loader : public AsyncUtility {
  36. private:
  37. class ConsiderFile {
  38. public:
  39. Filename _path;
  40. LoaderFileType *_type;
  41. };
  42. PUBLISHED:
  43. class EXPCL_PANDA Results {
  44. PUBLISHED:
  45. INLINE Results();
  46. INLINE Results(const Results &copy);
  47. INLINE void operator = (const Results &copy);
  48. INLINE ~Results();
  49. INLINE void clear();
  50. INLINE int get_num_files() const;
  51. INLINE const Filename &get_file(int n) const;
  52. INLINE LoaderFileType *get_file_type(int n) const;
  53. public:
  54. INLINE void add_file(const Filename &file, LoaderFileType *type);
  55. private:
  56. typedef pvector<ConsiderFile> Files;
  57. Files _files;
  58. };
  59. Loader();
  60. ~Loader();
  61. int find_all_files(const Filename &filename, const DSearchPath &search_path,
  62. Results &results) const;
  63. INLINE PT(PandaNode) load_sync(const Filename &filename,
  64. const LoaderOptions &options = LoaderOptions()) const;
  65. uint request_load(const string &event_name, const Filename &filename, bool search = true);
  66. bool check_load(uint id);
  67. PT(PandaNode) fetch_load(uint id);
  68. private:
  69. static void load_file_types();
  70. static bool _file_types_loaded;
  71. virtual bool process_request();
  72. PT(PandaNode) load_file(const Filename &filename, const LoaderOptions &options) const;
  73. typedef TokenBoard<LoaderToken> LoaderTokenBoard;
  74. LoaderTokenBoard *_token_board;
  75. };
  76. #include "loader.I"
  77. #endif