-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
111 lines (90 loc) · 3.02 KB
/
Main.cpp
File metadata and controls
111 lines (90 loc) · 3.02 KB
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
#include <iostream>
#include "Communication.h"
#include "Matrix.h"
//using namespace std;
//int main(int args, char **argv) {
/**
* get input from user.
* width of map >> height of map >> x value of start point >>
* y value of start point >> x value of end point >> y value of end point.
* format: 4_4,3_2,1_2
*/
//
// int sizeX, sizeY, numOfObstacles;
// char c;
// cin >> sizeX >> sizeY;
//
// // create matrix.
// Matrix matrix(sizeX, sizeY);
// // save matrix address at map object.
// Map *map = &matrix;
// cin >> numOfObstacles;
// if (numOfObstacles > 0) {
// map->setObstacles(numOfObstacles);
// }
// int id, age, experience, cabId;
// Status status;
// char statusLetter;
// Driver *driver;
//
// cin >> id >> c >> age >> c >> statusLetter >> c >>
// experience >> c >> cabId;
// status = Status(statusLetter);
// driver = new Driver(map, id, age, status, experience, cabId);
// //taxiCenter->addDriverInfo(driver);
// //driver = NULL;
// int portNo = atoi(argv[2]);
// set the pointer to point on null so when
// the object will delete this pointer will no longer point on it
// Communication *communication = new Communication();
// communication->startCommunicate();
// delete (communication);
// return 0;
#include "Udp.h"
#include <unistd.h>
using namespace std;
int main(int argc, char *argv[]) {
std::cout << "Hello, from client" << std::endl;
//
// Point *gp = new Point(0,0);
//
// std::string serial_str;
// boost::iostreams::back_insert_device<std::string> inserter(serial_str);
// boost::iostreams::stream<boost::iostreams::back_insert_device<std::string> > s(inserter);
// boost::archive::binary_oarchive oa(s);
// oa << gp;
// s.flush();
//
// cout << serial_str << endl;
// Point *gp2;
// boost::iostreams::basic_array_source<char> device(serial_str.c_str(), serial_str.size());
// boost::iostreams::stream<boost::iostreams::basic_array_source<char> > s2(device);
// boost::archive::binary_iarchive ia(s2);
// ia >> gp2;
//
// cout << *gp2 << endl;
Driver *d = new Driver(0, 30, Status(0), 1, 2);
cout << *d->getCurrentLocation() << endl;
string serial_str;
boost::iostreams::back_insert_device<std::string> inserter(serial_str);
boost::iostreams::stream<boost::iostreams::back_insert_device<std::string>>s(inserter);
boost::archive::binary_oarchive oa(s);
oa << d;
s.flush();
cout << serial_str << endl;
Driver *d2;
boost::iostreams::basic_array_source<char> device(serial_str.c_str(), serial_str.size());
boost::iostreams::stream<boost::iostreams::basic_array_source<char> > s2(device);
boost::archive::binary_iarchive ia(s2);
ia >> d2;
cout << *d2->getCurrentLocation() << endl;
cout << argv[1] << endl;
Udp udp(0, atoi(argv[1]));
udp.initialize();
char buffer[1024];
//udp.sendData(serial_str);
// udp.reciveData(buffer, sizeof(buffer));
//cout << buffer << endl;
return 0;
}
//}