Panda3D
 All Classes Functions Variables Enumerations
pnmFileType.h
00001 // Filename: pnmFileType.h
00002 // Created by:  drose (15Jun00)
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 PNMFILETYPE_H
00016 #define PNMFILETYPE_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "pnmimage_base.h"
00021 
00022 #include "typedObject.h"
00023 #include "typedWritable.h"
00024 
00025 class PNMReader;
00026 class PNMWriter;
00027 class FactoryParams;
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //       Class : PNMFileType
00031 // Description : This is the base class of a family of classes that
00032 //               represent particular image file types that PNMImage
00033 //               supports.
00034 ////////////////////////////////////////////////////////////////////
00035 class EXPCL_PANDA_PNMIMAGE PNMFileType : public TypedWritable {
00036 protected:
00037   PNMFileType();
00038 
00039 public:
00040   virtual ~PNMFileType();
00041 
00042 PUBLISHED:
00043   virtual string get_name() const=0;
00044 
00045   virtual int get_num_extensions() const;
00046   virtual string get_extension(int n) const;
00047   MAKE_SEQ(get_extensions, get_num_extensions, get_extension);
00048   virtual string get_suggested_extension() const;
00049 
00050 public:
00051   virtual bool has_magic_number() const;
00052   virtual bool matches_magic_number(const string &magic_number) const;
00053 
00054   virtual PNMReader *make_reader(istream *file, bool owns_file = true,
00055                                  const string &magic_number = string());
00056   virtual PNMWriter *make_writer(ostream *file, bool owns_file = true);
00057 
00058 protected:
00059   static void init_pnm();
00060 
00061 private:
00062   static bool _did_init_pnm;
00063 
00064 
00065   // The TypedWritable interface follows.
00066 public:
00067   static void register_with_read_factory();
00068   virtual void write_datagram(BamWriter *writer, Datagram &datagram);
00069 
00070 protected:
00071   static TypedWritable *make_PNMFileType(const FactoryParams &params);
00072 
00073 public:
00074   static TypeHandle get_class_type() {
00075     return _type_handle;
00076   }
00077   static void init_type() {
00078     TypedWritable::init_type();
00079     register_type(_type_handle, "PNMFileType",
00080                   TypedWritable::get_class_type());
00081   }
00082   virtual TypeHandle get_type() const {
00083     return get_class_type();
00084   }
00085   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00086 
00087 private:
00088   static TypeHandle _type_handle;
00089 };
00090 
00091 #endif
00092 
 All Classes Functions Variables Enumerations