summaryrefslogtreecommitdiff
path: root/libforecastio/forecastio.h
blob: bc45e2c2bbf3b7d1ef4c518f1e9ebf37cc164952 (plain)
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
#ifndef __FORECASTIO_H
#define __FORECASTIO_H

#include <string>
#include "forecasts.h"
#include "forecast.h"
#include "../services.h"

using namespace std;

class cForecastIO : public cThread {
private:
    string forecastFile;
    int cacheDurationDefault;
    string apiKey;
    string language;
    string unit;
    string baseURL;
    double latitude;
    double longitude;
    cForecast *current;
    cForecasts *hourly;
    cForecasts *daily;
    bool loopActive;
    cCondVar waitCondition;
    cMutex waitMutex;
    bool CheckUserApiKey(void);
    int CalculateCachDuration(void);
    bool CacheFileValid(void);
    string FetchOnlineForecast(void);
    bool ParseForecast(string &jsonForecast);
    void Action(void);
    void Clear(void);
    void ReadForecastInitial(void);
    void ReadForecast(void);
public:
    cForecastIO(string cacheDir);
    virtual ~cForecastIO(void);
    void Stop(void); 
    void LockForecasts(void) { Lock(); };
    void UnlockForecasts(void) { Unlock(); };
    cForecast *GetCurrentForecast(void);
    cForecasts *GetHourlyForecast(void) { return hourly; };
    cForecasts *GetDailyForecast(void) { return daily; };
    bool SetCurrentWeather(cServiceCurrentWeather *call);
};


#endif //__FORECASTIO_H