00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef PNMFILETYPE_H
00020 #define PNMFILETYPE_H
00021
00022 #include "pandabase.h"
00023
00024 #include "pnmimage_base.h"
00025
00026 #include "typedObject.h"
00027 #include "typedWritable.h"
00028
00029 class PNMReader;
00030 class PNMWriter;
00031 class FactoryParams;
00032
00033
00034
00035
00036
00037
00038
00039 class EXPCL_PANDA PNMFileType : public TypedWritable {
00040 protected:
00041 PNMFileType();
00042
00043 public:
00044 virtual ~PNMFileType();
00045
00046 virtual string get_name() const=0;
00047
00048 virtual int get_num_extensions() const;
00049 virtual string get_extension(int n) const;
00050 virtual string get_suggested_extension() const;
00051
00052 virtual bool has_magic_number() const;
00053 virtual bool matches_magic_number(const string &magic_number) const;
00054
00055 virtual PNMReader *make_reader(istream *file, bool owns_file = true,
00056 const string &magic_number = string());
00057 virtual PNMWriter *make_writer(ostream *file, bool owns_file = true);
00058
00059 protected:
00060 static void init_pnm();
00061
00062 private:
00063 static bool _did_init_pnm;
00064
00065
00066
00067 public:
00068 static void register_with_read_factory(void);
00069 virtual void write_datagram(BamWriter *writer, Datagram &datagram);
00070
00071 protected:
00072 static TypedWritable *make_PNMFileType(const FactoryParams ¶ms);
00073
00074 public:
00075 static TypeHandle get_class_type() {
00076 return _type_handle;
00077 }
00078 static void init_type() {
00079 TypedWritable::init_type();
00080 register_type(_type_handle, "PNMFileType",
00081 TypedWritable::get_class_type());
00082 }
00083 virtual TypeHandle get_type() const {
00084 return get_class_type();
00085 }
00086 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00087
00088 private:
00089 static TypeHandle _type_handle;
00090 };
00091
00092 #endif
00093