Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/iotcloud
[iotcloud.git] / src / server / iotquery.h
1 #ifndef IOTQUERY_H
2 #define IOTQUERY_H
3 #include <iostream>
4 #include "fcgio.h"
5 #include "fcgi_stdio.h"
6
7 #define DEFAULT_SIZE 128
8 #define OFFSET_MAX 0
9 #define OFFSET_OLD 4
10 #define OFFSET_NEW 12
11
12 class IoTQuery {
13  public:
14         IoTQuery(FCGX_Request * request);
15         ~IoTQuery();
16         void processQuery();
17         
18  private:
19         void sendResponse(char *data, int length);
20         void getQuery();
21         void getDirectory();
22         void readData();
23         bool checkDirectory();
24         bool openStatusFile();
25         void updateStatusFile();
26         void decodeQuery();
27         void getSlot();
28         void putSlot();
29         void removeOldestSlot();
30         char * getSlotFileName(long long);
31         
32         FCGX_Request * request;
33         char *data;
34         char *directory;
35         const char * uri;
36         const char * query;
37         const char * method;
38         const char * iotcloudroot;
39         long long length;
40         long long oldestentry;
41         long long newestentry;
42         long long requestsequencenumber;
43         int numqueueentries;
44         int fd;
45         bool reqGetSlot;
46         bool reqPutSlot;
47 };
48 #endif