Panda3D
 All Classes Functions Variables Enumerations
virtualFileHTTP.h
00001 // Filename: virtualFileHTTP.h
00002 // Created by:  drose (31Oct08)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef VIRTUALFILEHTTP_H
00016 #define VIRTUALFILEHTTP_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "virtualFile.h"
00021 #include "httpChannel.h"
00022 #include "urlSpec.h"
00023 
00024 #ifdef HAVE_OPENSSL
00025 
00026 class VirtualFileMountHTTP;
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //       Class : VirtualFileHTTP
00030 // Description : This maps a document retrieved from an HTTPClient
00031 //               into the VirtualFileSystem, allowing models etc. to
00032 //               be loaded directly from a web page.
00033 ////////////////////////////////////////////////////////////////////
00034 class EXPCL_PANDAEXPRESS VirtualFileHTTP : public VirtualFile {
00035 public:
00036   VirtualFileHTTP(VirtualFileMountHTTP *mount,
00037                   const Filename &local_filename,
00038                   bool implicit_pz_file,
00039                   int open_flags);
00040   virtual ~VirtualFileHTTP();
00041 
00042   virtual VirtualFileSystem *get_file_system() const;
00043   virtual Filename get_filename() const;
00044 
00045   virtual bool has_file() const;
00046   virtual bool is_directory() const;
00047   virtual bool is_regular_file() const;
00048   INLINE bool is_implicit_pz_file() const;
00049 
00050   virtual istream *open_read_file(bool auto_unwrap) const;
00051   virtual bool was_read_successful() const;
00052   virtual off_t get_file_size(istream *stream) const;
00053   virtual off_t get_file_size() const;
00054   virtual time_t get_timestamp() const;
00055 
00056 private:
00057   bool fetch_file(ostream *buffer_stream) const;
00058   istream *return_file(istream *buffer_stream, bool auto_unwrap) const;
00059 
00060   VirtualFileMountHTTP *_mount;
00061   Filename _local_filename;
00062   bool _implicit_pz_file;
00063   bool _status_only;
00064   URLSpec _url;
00065   PT(HTTPChannel) _channel;
00066 
00067 public:
00068   virtual TypeHandle get_type() const {
00069     return get_class_type();
00070   }
00071   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00072 
00073 PUBLISHED:
00074   static TypeHandle get_class_type() {
00075     return _type_handle;
00076   }
00077 
00078 public:
00079   static void init_type() {
00080     VirtualFile::init_type();
00081     register_type(_type_handle, "VirtualFileHTTP",
00082                   VirtualFile::get_class_type());
00083   }
00084 
00085 private:
00086   static TypeHandle _type_handle;
00087 };
00088 
00089 #include "virtualFileHTTP.I"
00090 
00091 #endif // HAVE_OPENSSL
00092 
00093 #endif
00094 
 All Classes Functions Variables Enumerations