-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbLib.h
75 lines (63 loc) · 2.14 KB
/
dbLib.h
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
/*
* =========================================================================================
* Name : dbLib.h
* Author : Duc Dung Nguyen
* Email : [email protected]
* Copyright : Faculty of Computer Science and Engineering - Bach Khoa University
* Description : library for Assignment 2 - Data structures and Algorithms - Fall 2017
* This library contains functions used for database management
* =========================================================================================
*/
#ifndef DSA171A2_DBLIB_H
#define DSA171A2_DBLIB_H
#include <string>
#include <string.h>
#include <time.h>
#include <iostream>
#include <iomanip>
#include <functional>
#include "dsaLib.h"
#include "requestLib.h"
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#define ID_MAX_LENGTH 16
#ifndef VM_RECORD
#define VM_RECORD
struct VM_Record
{
//char id[ID_MAX_LENGTH];
std::string id;
time_t timestamp;
double longitude, latitude;
// default constructor
VM_Record() {
// id[0] = 0;
id = "";
}
VM_Record(const char* busID) {
//strcpy(id, busID);
id = busID;
}
// copy constructor
VM_Record(VM_Record& bus) : timestamp(bus.timestamp), longitude(bus.longitude), latitude(bus.latitude) {
//strcpy(id, bus.id);
id = bus.id;
}
};
#endif // !VM_RECORD
void printVMRecord(VM_Record &);
void strPrintTime(char* des, time_t& t);
bool parseVMRecord(char*, VM_Record &);
void loadVMDB(char*, L1List<VM_Record> &);
double distanceEarth(double lon1d, double lat1d, double lon2d, double lat2d);
bool processRequest(VM_Request &, L1List<VM_Record> &, void *);// from processData.cpp
/// NOTE: student may create this function to allocate some global data
bool initVMGlobalData(void** pGData);
/// NOTE: student must defined this function if they use dynamically allocated global data.
/// If student do not use any dynamic global data, please define this function as empty function
/// in your code (file processData.cpp) as follows
/// void releaseBusGlobalData() {}
void releaseVMGlobalData(void* pGData);
void process(L1List<VM_Request>& requestList, L1List<VM_Record>& recordList);
#endif //DSA171A2_DBLIB_H