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

panda/src/testbed/downloader_test.cxx

Go to the documentation of this file.
00001 // Filename: downloader_test.cxx
00002 // Created by:  
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 #include <eventHandler.h>
00020 #include <chancfg.h>
00021 #include <downloader.h>
00022 #include <framework.h>
00023 #include <decompressor.h>
00024 #include <extractor.h>
00025 
00026 Downloader downloader;
00027 Decompressor decompressor;
00028 Extractor extractor;
00029 Filename src_file;
00030 Filename dest_file;
00031 
00032 void event_y(CPT_Event) {
00033   downloader.request_download(src_file, dest_file, "");
00034 }
00035 
00036 void event_u(CPT_Event) {
00037   downloader.request_download("/oldfoobar.mfz", "/fit/people/mike/download/oldfoobar.mfz", "");
00038 }
00039 
00040 void event_i(CPT_Event) {
00041   downloader.request_download("/foobar.mfz", "/fit/people/mike/download/partfoobar.mfz", "", 0, 99, 151);
00042 }
00043 
00044 void event_o(CPT_Event) {
00045   downloader.request_download("/foobar.mfz", "/fit/people/mike/download/partfoobar.mfz", "", 100, 151, 151);
00046 }
00047 
00048 void event_p(CPT_Event) {
00049   decompressor.request_decompress("/fit/people/mike/download/dload.mf.pz", "");
00050 }
00051 
00052 void event_la(CPT_Event) {
00053   extractor.request_extract("/fit/people/mike/download/dload.mf", "");
00054 }
00055 
00056 void loader_keys(EventHandler& eh) {
00057   eh.add_hook("y", event_y);
00058   eh.add_hook("u", event_u);
00059   eh.add_hook("i", event_i);
00060   eh.add_hook("o", event_o);
00061   eh.add_hook("p", event_p);
00062   eh.add_hook("[", event_la);
00063 }
00064 
00065 int main(int argc, char *argv[]) {
00066 
00067   if (argc < 4) {
00068     cerr << "Usage: download <server> <source file> <dest file>" << endl;
00069     return 0;
00070   }
00071 
00072   string server_name = argv[1];
00073   src_file = argv[2];
00074   dest_file = argv[3];
00075   argc -= 3;
00076   argv += 3;
00077 
00078   define_keys = &loader_keys;
00079   downloader.create_thread();
00080   downloader.connect_to_server(server_name);
00081   decompressor.create_thread();
00082   extractor.create_thread();
00083   return framework_main(argc, argv);
00084 }

Generated on Fri May 2 00:44:07 2003 for Panda by doxygen1.3