Browse Source

add is_valid

David Rose 22 years ago
parent
commit
c1583ac567
2 changed files with 16 additions and 1 deletions
  1. 13 1
      panda/src/pnmimage/pnmWriter.I
  2. 3 0
      panda/src/pnmimage/pnmWriter.h

+ 13 - 1
panda/src/pnmimage/pnmWriter.I

@@ -26,7 +26,8 @@ INLINE PNMWriter::
 PNMWriter(PNMFileType *type, ostream *file, bool owns_file) :
   _type(type),
   _owns_file(owns_file),
-  _file(file)
+  _file(file),
+  _is_valid(true)
 {
 }
 
@@ -106,3 +107,14 @@ INLINE void PNMWriter::
 copy_header_from(const PNMImageHeader &header) {
   PNMImageHeader::operator = (header);
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: PNMWriter::is_valid
+//       Access: Public
+//  Description: Returns true if the PNMWriter can be used to write
+//               data, false if something is wrong.
+////////////////////////////////////////////////////////////////////
+INLINE bool PNMWriter::
+is_valid() const {
+  return _is_valid;
+}

+ 3 - 0
panda/src/pnmimage/pnmWriter.h

@@ -59,10 +59,13 @@ public:
 
   virtual bool supports_stream_write() const;
 
+  INLINE bool is_valid() const;
+
 protected:
   PNMFileType *_type;
   bool _owns_file;
   ostream *_file;
+  bool _is_valid;
 };
 
 #include "pnmWriter.I"