00001 #ifndef READER_H 00002 #define READER_H 00003 /* 00004 * class Reader 00005 * 00006 * This class stores a decoded BCD track, and the different fields 00007 * its divided into 00008 */ 00009 00010 #include "card.h" 00011 00012 typedef std::vector<int> intVec; 00013 00014 //abstarct! 00015 class Reader { 00016 00017 public: 00018 Reader(); 00019 char * getName() const; 00020 void setName(char *); 00021 00022 void setVerbose(bool); 00023 00024 bool canReadTrack(const int &) const; 00025 void setCanReadTrack(const int&); 00026 00027 //-----------funcs 00028 virtual void readRaw() const =0; //read in raw mode from the interface 00029 virtual bool initReader() = 0;//init hardware 00030 virtual Card read() const =0; //read from the hardware interface! 00031 virtual bool writeXML(char *) const =0; //write this object as XML from disk; 00032 protected: 00033 char * name; 00034 int interface; 00035 intVec readableTracks; 00036 00037 //internal variables 00038 bool init; //used to track if hardware is inited 00039 bool verbose; //am I being verbose? 00040 00041 }; 00042 00043 00044 // used by parallel port and gameport based readers 00045 class DirectReader : public Reader{ 00046 00047 public: 00048 00049 DirectReader(); 00050 DirectReader(int, int, int, int, int, int, int, int); 00051 virtual void readRaw() const; //read in raw mode from the interface 00052 virtual bool initReader(); 00053 virtual Card read() const; //read from the hardware interface! 00054 virtual bool writeXML(char *) const; 00055 00056 protected: 00057 00058 int port; 00059 bool usesCP; 00060 00061 int CP; 00062 int CLK1; 00063 int DATA1; 00064 int CLK2; 00065 int DATA2; 00066 int CLK3; 00067 int DATA3; 00068 00069 }; 00070 00071 //-----------------------------------------------------------------Serial Reader 00072 00073 class SerialReader : public Reader{ 00074 00075 public: 00076 00077 SerialReader(); 00078 SerialReader(char *); 00079 void setDevice(char *); 00080 void setCRFlag(bool); 00081 virtual void readRaw() const; //read in raw mode from the interface 00082 virtual bool initReader(); 00083 virtual Card read() const; //read from the hardware interface! 00084 virtual bool writeXML(char *) const; 00085 00086 protected: 00087 00088 char * device; 00089 FILE * fin; 00090 bool SerialReader::validInput(const char *) const; 00091 char * parseTrack(const char *, const char, const char) const; 00092 bool flagCR; 00093 }; 00094 00095 00096 #endif