-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenServerCommand.cpp
More file actions
42 lines (34 loc) · 1.11 KB
/
Copy pathOpenServerCommand.cpp
File metadata and controls
42 lines (34 loc) · 1.11 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
//
// Created by roy on 12/13/18.
//
#include "OpenServerCommand.h"
#include "iostream"
using namespace std;
/**
* Constructor of the command.
* @param newPort given port for the server.
* @param newHerz given times in second for the sampling.
* @param newReader data reader server pointer for the initialization.
* @param symbolTable symbol table pointer for the initialization.
*/
OpenServerCommand::OpenServerCommand(string newPort, string newHerz,
DataReaderServer *newReader, SymbolTable *symbolTable) {
port = newPort;
herz = newHerz;
dataReaderServer = newReader;
this->symbolTable = symbolTable;
}
/**
* This method checks if the port is valid and opens the
* reader server with the fitting values.
* @return jump index for the parser.
*/
int OpenServerCommand::execute() {
// check if valid port.
if (stod(port) < MIN_PORT || stod(port) > MAX_PORT) {
throw "non-valid port";
}
dataReaderServer->set(port, herz, this->symbolTable);
dataReaderServer->open();
return INDEX_OPEN_SERVER_JUMP; // number of needed to move the lexer
}