Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/pgraph/loader.h

Go to the documentation of this file.
00001 // Filename: loader.h
00002 // Created by:  mike (09Jan97)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef LOADER_H
00020 #define LOADER_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "notify.h"
00025 #include "pandaNode.h"
00026 #include "filename.h"
00027 #include "tokenBoard.h"
00028 #include "asyncUtility.h"
00029 #include "dSearchPath.h"
00030 
00031 class LoaderToken;
00032 class LoaderFileType;
00033 
00034 ////////////////////////////////////////////////////////////////////
00035 //       Class : Loader
00036 // Description : Handles database loading through asynchronous
00037 //               threading
00038 ////////////////////////////////////////////////////////////////////
00039 class EXPCL_PANDA Loader : public AsyncUtility {
00040 private:
00041   class ConsiderFile {
00042   public:
00043     Filename _path;
00044     LoaderFileType *_type;
00045   };
00046 
00047 PUBLISHED:
00048   class EXPCL_PANDA Results {
00049   PUBLISHED:
00050     INLINE Results();
00051     INLINE Results(const Results &copy);
00052     INLINE void operator = (const Results &copy);
00053     INLINE ~Results();
00054 
00055     INLINE void clear();
00056     INLINE int get_num_files() const;
00057     INLINE const Filename &get_file(int n) const;
00058     INLINE LoaderFileType *get_file_type(int n) const;
00059 
00060   public:
00061     INLINE void add_file(const Filename &file, LoaderFileType *type);
00062 
00063   private:
00064     typedef pvector<ConsiderFile> Files;
00065     Files _files;
00066   };
00067 
00068   Loader();
00069   ~Loader();
00070 
00071   int find_all_files(const Filename &filename, const DSearchPath &search_path,
00072                      Results &results) const;
00073 
00074   INLINE PT(PandaNode) load_sync(const Filename &filename, bool search = true) const;
00075 
00076   uint request_load(const string &event_name, const Filename &filename, bool search = true);
00077   bool check_load(uint id);
00078   PT(PandaNode) fetch_load(uint id);
00079 
00080 private:
00081   static void load_file_types();
00082   static bool _file_types_loaded;
00083 
00084   virtual bool process_request(void);
00085   PT(PandaNode) load_file(const Filename &filename, bool search) const;
00086 
00087   typedef TokenBoard<LoaderToken> LoaderTokenBoard;
00088   LoaderTokenBoard *_token_board;
00089 };
00090 
00091 #include "loader.I"
00092 
00093 #endif

Generated on Fri May 2 00:41:47 2003 for Panda by doxygen1.3