This repository has been archived by the owner on Jul 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcomputer.h
54 lines (40 loc) · 1.44 KB
/
computer.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
#ifndef CODE_COMPUTER_H
#define CODE_COMPUTER_H
#include <string>
#include <vector>
#include <condition_variable>
#include "components.h"
using std::string;
static const string COMPUTERS_FOLDER = "computers/";
static const string COMPUTER_ADDRESS_FILE = "/address.txt";
static const string COMPUTER_MEMORY_FILE = "/memory.txt";
static const string COMPUTER_COMPONENTS_FILE = "/components.txt";
static const string COMPUTER_TEMP_FS_FILE = "/tempfs.txt";
static string get_computer_address(const string &project_dir, const string &computer_name);
static long long get_computer_memory(const string &project_dir, const string &computer_name);
static long long get_current_time();
class Project;
class Component;
class Session;
class Filesystem;
class Computer {
private:
friend Session;
Session *session = nullptr;
std::vector<Component *> components;
public:
const string address;
const string name;
const long long start_time;
const long long memory;
long long used_memory = 0;
std::queue<string> signal_queue;
std::mutex queue_lock;
std::condition_variable queue_notifier;
Filesystem *tmp_fs;
explicit Computer(string &project_dir, string &name, std::map<string, Component *> &all_components);
int get_components(std::vector<Component *> *v);
Component *get_component(const string &component_address);
Component *get_component_by_name(const string &component_name);
};
#endif //CODE_COMPUTER_H