TrainInfoLib

Dependents:   TrainInfoSample

Committer:
rinosh2
Date:
Fri Nov 19 20:39:15 2010 +0000
Revision:
0:475be92c8304

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rinosh2 0:475be92c8304 1 ///////////////////////////////////////////////////////////////////////////////
rinosh2 0:475be92c8304 2 // TrainInfo: Next train and delayed information library by rinos 2010
rinosh2 0:475be92c8304 3 ///////////////////////////////////////////////////////////////////////////////
rinosh2 0:475be92c8304 4
rinosh2 0:475be92c8304 5 #ifndef __TRAININFO_H__
rinosh2 0:475be92c8304 6 #define __TRAININFO_H__
rinosh2 0:475be92c8304 7
rinosh2 0:475be92c8304 8 #include "NextTrainFile.h"
rinosh2 0:475be92c8304 9 #include "IniFile.h"
rinosh2 0:475be92c8304 10
rinosh2 0:475be92c8304 11 class TrainInfo {
rinosh2 0:475be92c8304 12 // defines /////////////////////////////////////////////////////////////////
rinosh2 0:475be92c8304 13 public:
rinosh2 0:475be92c8304 14 typedef enum {
rinosh2 0:475be92c8304 15 DTYPE_NONE,
rinosh2 0:475be92c8304 16 DTYPE_TOKYU,
rinosh2 0:475be92c8304 17 DTYPE_MAX,
rinosh2 0:475be92c8304 18 } DelayType;
rinosh2 0:475be92c8304 19
rinosh2 0:475be92c8304 20 static const int MAX_DELAY_MESSAGE = 256;
rinosh2 0:475be92c8304 21
rinosh2 0:475be92c8304 22 // error code
rinosh2 0:475be92c8304 23 typedef enum {
rinosh2 0:475be92c8304 24 S_SUCCESS = 0,
rinosh2 0:475be92c8304 25 S_INI_OPEN_ERROR,
rinosh2 0:475be92c8304 26 S_ALREADY_OPEN,
rinosh2 0:475be92c8304 27 S_INI_FORMAT_ERROR,
rinosh2 0:475be92c8304 28
rinosh2 0:475be92c8304 29 S_NEXTTRAIN_OPEN_ERROR = 100,
rinosh2 0:475be92c8304 30 S_NEXTTRAIN_OPTION_OVERFLOW,
rinosh2 0:475be92c8304 31 S_NEXTTRAIN_NO_TRAIN,
rinosh2 0:475be92c8304 32 S_NEXTTRAIN_INVALID_OPTION_ID,
rinosh2 0:475be92c8304 33
rinosh2 0:475be92c8304 34 S_DELAY_DETECTED = 200,
rinosh2 0:475be92c8304 35 S_DELAY_NONE,
rinosh2 0:475be92c8304 36 S_DELAY_TYPE_ERROR,
rinosh2 0:475be92c8304 37 S_DELAY_WRITE_ERROR,
rinosh2 0:475be92c8304 38 S_DELAY_DOWNLOAD_ERROR,
rinosh2 0:475be92c8304 39 S_DELAY_NOINFO,
rinosh2 0:475be92c8304 40 } Status;
rinosh2 0:475be92c8304 41
rinosh2 0:475be92c8304 42 // internal member/method //////////////////////////////////////////////////
rinosh2 0:475be92c8304 43 private:
rinosh2 0:475be92c8304 44 IniFile m_ini;
rinosh2 0:475be92c8304 45 NextTrainFile m_ntf;
rinosh2 0:475be92c8304 46 char m_delay[MAX_DELAY_MESSAGE];
rinosh2 0:475be92c8304 47
rinosh2 0:475be92c8304 48 // Invalid method
rinosh2 0:475be92c8304 49 protected:
rinosh2 0:475be92c8304 50 TrainInfo(const TrainInfo& v);
rinosh2 0:475be92c8304 51 const TrainInfo& operator =(const TrainInfo& v);
rinosh2 0:475be92c8304 52
rinosh2 0:475be92c8304 53 public:
rinosh2 0:475be92c8304 54 TrainInfo(const char* inifile = 0);
rinosh2 0:475be92c8304 55 ~TrainInfo();
rinosh2 0:475be92c8304 56
rinosh2 0:475be92c8304 57 Status open(const char* inifile);
rinosh2 0:475be92c8304 58 Status close();
rinosh2 0:475be92c8304 59
rinosh2 0:475be92c8304 60 // NextTrainFile I/F
rinosh2 0:475be92c8304 61 void use_shortopt(bool f) {
rinosh2 0:475be92c8304 62 m_ntf.use_shortopt(f);
rinosh2 0:475be92c8304 63 }
rinosh2 0:475be92c8304 64 NextTrainFile::Status search(time_t dt = 0, int offset = 0) {
rinosh2 0:475be92c8304 65 return m_ntf.search(dt, offset);
rinosh2 0:475be92c8304 66 }
rinosh2 0:475be92c8304 67 const NextTrainFile::NextInfo* next() const {
rinosh2 0:475be92c8304 68 return m_ntf.next();
rinosh2 0:475be92c8304 69 }
rinosh2 0:475be92c8304 70
rinosh2 0:475be92c8304 71 // Delay information I/F
rinosh2 0:475be92c8304 72 Status checkDelay();
rinosh2 0:475be92c8304 73 Status getDelayMessage(char* buf, int size);
rinosh2 0:475be92c8304 74 };
rinosh2 0:475be92c8304 75
rinosh2 0:475be92c8304 76 #endif