-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStocks.h
56 lines (40 loc) · 1.12 KB
/
Stocks.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
//
// Created by charles.cxh on 2021/9/4.
//
#ifndef MINIPROJECT_STOCKS_H
#define MINIPROJECT_STOCKS_H
#include <fstream>
#include <string>
#include <stdexcept>
#include <memory>
#include <sstream>
#include <unistd.h>
#include <map>
#include<sys/stat.h>
#include "Snapshot.h"
#include "UpdateLevel.h"
#include "DeleteLevel.h"
static const size_t msgTypeOffset = sizeof(uint8_t);
static const size_t symbolOffset = 6 * sizeof(char);
static const size_t bidPriceOffset = 5 * sizeof(FLOAT64);
static const size_t bidSizeOffset = 5 * sizeof(uint32_t);
static const size_t askPriceOffset = 5 * sizeof(FLOAT64);
static const size_t sideOffset = sizeof(uint8_t);
static const size_t levelOffset = sizeof(uint8_t);
static const size_t priceOffset = sizeof(FLOAT64);
class Stocks {
private:
std::map<std::string, Snapshot> snapshotMap;
public:
/**
* 根据bufer反序列化成对象
* @param arg
* @param size
*/
void deserialize(std::unique_ptr<char[]> &arg, std::streamsize size);
Snapshot *query(std::string symbol);
~Stocks() {
snapshotMap.clear();
}
};
#endif //MINIPROJECT_STOCKS_H