-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRouteStatus.cpp
46 lines (39 loc) · 1.43 KB
/
RouteStatus.cpp
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
////////////////////////////////////////////////////////////////////////////////
// Gets a status update on the pending optimization problems
////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include "../include/route4me.h"
#define KEY "11111111111111111111111111111111"
using namespace std;
int main()
{
// global init
CRoute4Me::init();
CRoute4Me route(KEY);
int ret = 0;
if(route.get_route_q() == 0)
{
//cout << "Status update for the key " << KEY << " is:" << endl << route.get_raw_resp() << endl;
//cout << "Status update for the key " << KEY << " is:" << endl << Json::FastWriter().write(route.get_json_resp()) << endl;
Json::Value opt_lst = route.get_json_resp()["optimizations"];
if(opt_lst.isArray())
{
std::cout << "Key = " << KEY << "; Optimization problems are:" << endl;
unsigned optListSize = opt_lst.size();
for(unsigned i = 0; i < optListSize ; ++i)
{
string id = opt_lst[i]["optimization_problem_id"].asString();
int state = opt_lst[i]["state"].asInt();
cout << " " << id << " in state " << state << endl;
}
}
}
else
{
cout << "Err: " << route.get_err_code() << ": " << route.get_err_msg() << endl;
ret = -1;
}
// global cleanup
CRoute4Me::cleanup();
return ret;
}