fileWeather.h
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/*
*  Weather.h
*
*  Created by Daisuke Nogami on Nov, 05.
*  opyright 2005 Daisuke Nogami [null-null.net]. Some rights reserved.
*/
 
#pragma once
 
// thread
#include "tjmtsupp.h"
#include "tjiostream.h"
#include "TJSyncObject.h"
#include "TJThread.h"
 
// http
#include <windows.h>
#include <wininet.h>
 
// regex
#include <boost/regex.hpp>
 
// selfmade class
#include "AirstreamFilter.h"
#include "RainFilter.h"
 
using namespace std;
using namespace boost;
 
 
class Weather : public TJThread, virtual public TJSyncObject{
protected:
  void run();
  bool signaled;
 
private:
  char* url;
  void load( char* url );
  void refresh();
 
  // filters
  AirstreamFilter* asfilter;
  RainFilter* rfilter;
 
  int crt_hour;
  int hours;
  bool isLoading;
  bool synchronize;
 
  float convertToDegreeFrom( string dir );
 
public:
  Weather( AirstreamFilter* asfilter, RainFilter* rfilter );
  void signal(); // stop thead
  void sync(); // sync current weather
  void drawStatus(); // view weather status
 
  string getLocation();
  string getCurrentDate();
  string getAddHours();
  string getCurrentWeather();
  string getCurrentTemp();
  string getCurrentPrecRate();
  string getCurrentHum();
  string getCurrentWinDir();
  string getCurrentWinSpd();
};
 
// value of weather
static next = 0;
static int current = -1;
static string today_weather[8];
static string today_temp[8];
static string today_prec_rate[8];
static string today_hum[8];
static string today_win_dir[8];
static string today_win_spd[8];
 
static string tomorrow_weather[8];
static string tomorrow_temp[8];
static string tomorrow_prec_rate[8];
static string tomorrow_hum[8];
static string tomorrow_win_dir[8];
static string tomorrow_win_spd[8];
 
static string week_weather[6];
static string week_max_temp[6];
static string week_min_temp[6];
static string week_prec_perc[6];
 
// method for regex
 
struct cb_today_current_hour{
  bool operator()( const match_results<string::iterator>& m ){
    string str = m.str(2);
    if( str == "3:00" )  current = 1;
    else if( str == "6:00" )  current = 2;
    else if( str == "9:00" )  current = 3;
    else if( str == "12:00" )  current = 4;
    else if( str == "15:00" )  current = 5;
    else if( str == "18:00" )  current = 6;
    else if( str == "21:00" )  current = 7;
    else{
      current = 0;
    }
    return true;
  }
};
 
struct cb_today_weather{
  bool operator()( const match_results<string::iterator>& m ){
    today_weather[next++] = m.str(2);
    return true;
  }
};
 
struct cb_today_temp{
  bool operator()( const match_results<string::iterator>& m ){
    today_temp[next++] = m.str(2);
    return true;
  }
};
 
struct cb_today_prec_rate{
  bool operator()( const match_results<string::iterator>& m ){
    today_prec_rate[next++] = m.str(2);
    return true;
  }
};
 
struct cb_today_hum{
  bool operator()( const match_results<string::iterator>& m ){
    today_hum[next++] = m.str(2);
    return true;
  }
};
 
struct cb_today_win_dir{
  bool operator()( const match_results<string::iterator>& m ){
    today_win_dir[next++] = m.str(2);
    return true;
  }
};
 
struct cb_today_win_spd{
  bool operator()( const match_results<string::iterator>& m ){
    today_win_spd[next++] = m.str(2);
    return true;
  }
};
 
//
 
struct cb_tomorrow_weather{
  bool operator()( const match_results<string::iterator>& m ){
    tomorrow_weather[next++] = m.str(2);
    return true;
  }
};
 
struct cb_tomorrow_temp{
  bool operator()( const match_results<string::iterator>& m ){
    tomorrow_temp[next++] = m.str(2);
    return true;
  }
};
 
struct cb_tomorrow_prec_rate{
  bool operator()( const match_results<string::iterator>& m ){
    tomorrow_prec_rate[next++] = m.str(2);
    return true;
  }
};
 
struct cb_tomorrow_hum{
  bool operator()( const match_results<string::iterator>& m ){
    tomorrow_hum[next++] = m.str(2);
    return true;
  }
};
 
struct cb_tomorrow_win_dir{
  bool operator()( const match_results<string::iterator>& m ){
    tomorrow_win_dir[next++] = m.str(2);
    return true;
  }
};
 
struct cb_tomorrow_win_spd{
  bool operator()( const match_results<string::iterator>& m ){
    tomorrow_win_spd[next++] = m.str(2);
    return true;
  }
};
 
//
 
struct cb_week_weather{
  bool operator()( const match_results<string::iterator>& m ){
    week_weather[next++] = m.str(2);
    return true;
  }
};
 
struct cb_week_max_temp{
  bool operator()( const match_results<string::iterator>& m ){
    week_max_temp[next++] = m.str(2);
    return true;
  }
};
 
struct cb_week_min_temp{
  bool operator()( const match_results<string::iterator>& m ){
    week_min_temp[next++] = m.str(2);
    return true;
  }
};
 
struct cb_week_prec_perc{
  bool operator()( const match_results<string::iterator>& m ){
    week_prec_perc[next++] = m.str(2);
    return true;
  }
};
[トップ] [一覧] [最終更新] [検索] [バックアップ]