-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataReaderServer.h
More file actions
57 lines (51 loc) · 1.48 KB
/
Copy pathDataReaderServer.h
File metadata and controls
57 lines (51 loc) · 1.48 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
#ifndef PROJECTPART1_DATAREADERSERVER_H
#define PROJECTPART1_DATAREADERSERVER_H
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <netdb.h>
#include <unistd.h>
#include <netinet/in.h>
#include <string.h>
#include <sys/socket.h>
#include <unordered_map>
#include <vector>
#include "SymbolTable.h"
#include <thread>
using namespace std;
/**
* Data reader server is responsible for getting strobes from the client
* and updating bind and symbol maps (unordered maps) by the strobes received from client.
*/
class DataReaderServer {
unordered_map<string,double> strobes; //first the address then the value
unordered_map<string, string> bindTable; //first the address then the variable
SymbolTable* symbolMap; //SCAT! for now untill I know how to pass by pointer
int sockfd;
int newSockFd;
int port;
int herz;
bool clientAccepted;
pthread_t myThread;
public:
DataReaderServer() = default;
~DataReaderServer(){
closeServer();
}
void attachThread(pthread_t);
void set(string, string, SymbolTable*);
bool isInBindMap(string);
void takeSamplesToTable(string);
void setBind(string, string);
void setSymbol(string, double);
string getBindAddress(string varName);
void updateBindedValues();
void * open();
static void * runServer(void * a);
void * runServerFunc(void *);
void closeServer();
void setSock(int);
int getSock();
};
#endif //PROJECTPART1_DATAREADERSERVER_H