805cc8b104d0cbc907cfc75bdac5bb14f68a706d
[iotcloud.git] / version2 / src / C / Update.C
1 #include "Table.h"
2 #include "IoTString.h"
3 #include "TimingSingleton.h"
4 #include "TransactionStatus.h"
5
6 #define NUMBER_OF_SENSORS 1
7 #define MACHINE_ID 260
8
9 int main(int numargs, char ** args) {
10         TimingSingleton * timer = TimingSingleton_getInstance();
11
12         bool foundError = false;
13         Vector<TransactionStatus *> * transStatusList = new Vector<TransactionStatus *>();
14
15         // Setup the 2 clients
16         IoTString * baseurl = new IoTString("http://dc-6.calit2.uci.edu/test.iotcloud/");
17         IoTString * password = new IoTString("reallysecret");
18         Table * t1 = new Table(baseurl, password, MACHINE_ID, -1);
19         t1->rebuild();
20         printf("T1 Ready\n");
21
22         baseurl->releaseRef();
23         password->releaseRef();
24
25         /*char keyBuffer[80];
26         char dataBuffer[80];
27
28         sprintf(keyBuffer, "sensor0");
29         IoTString * iKeyA = new IoTString(keyBuffer);
30         sprintf(dataBuffer, "data1");
31         IoTString * iValueA = new IoTString(dataBuffer);
32         t1->startTransaction();
33         t1->put(iKeyA, iValueA);
34         transStatusList->add(t1->commitTransaction());*/
35         t1->update();
36         
37         //iKeyA->releaseRef();
38         //iValueA->releaseRef();
39
40         for (uint i = 0; i < transStatusList->size(); i++) {
41                 TransactionStatus * status = transStatusList->get(i);
42                 if (status->getStatus() != TransactionStatus_StatusCommitted) {
43                         foundError = true;
44                         printf("Status error\n");
45                 }
46                 delete status;
47         }
48         
49         if (foundError) {
50                 printf("Found Errors...\n");
51         } else {
52                 printf("No Errors Found...\n");
53         }
54
55         delete transStatusList;
56         delete t1;
57 }
58