Panda3D
|
00001 // Filename: datagramOutputFile.h 00002 // Created by: drose (30Oct00) 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 DATAGRAMOUTPUTFILE_H 00016 #define DATAGRAMOUTPUTFILE_H 00017 00018 #include "pandabase.h" 00019 00020 #include "datagramSink.h" 00021 #include "filename.h" 00022 #include "fileReference.h" 00023 #include "virtualFile.h" 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : DatagramOutputFile 00027 // Description : This class can be used to write a binary file that 00028 // consists of an arbitrary header followed by a number 00029 // of datagrams. 00030 //////////////////////////////////////////////////////////////////// 00031 class EXPCL_PANDA_PUTIL DatagramOutputFile : public DatagramSink { 00032 public: 00033 INLINE DatagramOutputFile(); 00034 INLINE ~DatagramOutputFile(); 00035 00036 bool open(const FileReference *file); 00037 INLINE bool open(const Filename &filename); 00038 bool open(ostream &out, const Filename &filename = Filename()); 00039 INLINE ostream &get_stream(); 00040 00041 void close(); 00042 00043 bool write_header(const string &header); 00044 virtual bool put_datagram(const Datagram &data); 00045 virtual bool copy_datagram(SubfileInfo &result, const Filename &filename); 00046 virtual bool copy_datagram(SubfileInfo &result, const SubfileInfo &source); 00047 virtual bool is_error(); 00048 virtual void flush(); 00049 00050 virtual const Filename &get_filename(); 00051 virtual const FileReference *get_file(); 00052 virtual streampos get_file_pos(); 00053 00054 private: 00055 bool _wrote_first_datagram; 00056 bool _error; 00057 CPT(FileReference) _file; 00058 PT(VirtualFile) _vfile; 00059 ostream *_out; 00060 bool _owns_out; 00061 Filename _filename; 00062 }; 00063 00064 #include "datagramOutputFile.I" 00065 00066 #endif