00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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
00031
00032
00033
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
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 ¶ms);
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