00001 // Filename: datagramOutputFile.I 00002 // Created by: drose (27Oct00) 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 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: DatagramOutputFile::Constructor 00018 // Access: Public 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE DatagramOutputFile:: 00022 DatagramOutputFile() { 00023 _error = false; 00024 _wrote_first_datagram = false; 00025 _out = (ostream *)NULL; 00026 _owns_out = false; 00027 } 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Function: DatagramOutputFile::Destructor 00031 // Access: Public 00032 // Description: 00033 //////////////////////////////////////////////////////////////////// 00034 INLINE DatagramOutputFile:: 00035 ~DatagramOutputFile() { 00036 close(); 00037 } 00038 00039 //////////////////////////////////////////////////////////////////// 00040 // Function: DatagramOutputFile::open 00041 // Access: Published 00042 // Description: Opens the indicated filename for writing. Returns 00043 // true on success, false on failure. 00044 //////////////////////////////////////////////////////////////////// 00045 INLINE bool DatagramOutputFile:: 00046 open(const Filename &filename) { 00047 return open(new FileReference(filename)); 00048 } 00049 00050 //////////////////////////////////////////////////////////////////// 00051 // Function: DatagramOutputFile::get_stream 00052 // Access: Published 00053 // Description: Returns the ostream represented by the output file. 00054 //////////////////////////////////////////////////////////////////// 00055 INLINE ostream &DatagramOutputFile:: 00056 get_stream() { 00057 static ofstream null_stream; 00058 nassertr(_out != NULL, null_stream); 00059 return *_out; 00060 }