-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstruction.h
56 lines (45 loc) · 1.7 KB
/
instruction.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
/*
Author: Justin Muskopf
Instructor: Hoffman
Course: CSCE 4550, Fall 2018
Assignment: Project 1
*/
#ifndef INSTRUCTION_H
#define INSTRUCTION_H
#include <string>
#include <vector>
// Data types for Instruction and SecurityLevel Enums
typedef enum {ADD_SUB, ADD_OBJ, READ, WRITE, CMD_ERROR} CmdType;
typedef enum {LOW, MEDIUM, HIGH, LVL_ERROR} SecurityLevel;
// Represents Instructions to ReferenceMonitor
class Instruction
{
public:
Instruction(std::string command);
// The number of command types and security levels
static const int NUM_CMD_TYPES = 4;
static const int NUM_SEC_LVLS = 3;
bool isValid();
bool isInvalid();
std::string getSubjectName();
std::string getObjectName();
std::string getInstruction();
SecurityLevel getSecurityLevel();
int getValue();
CmdType getType();
~Instruction();
private:
// The strings representing SecurityLevels and Instruction types in instruction strings
const std::vector<std::string> LevelStrings = {"low", "medium", "high"};
const std::vector<std::string> TypeStrings = {"addsub", "addobj", "read", "write"};
std::string subName; // The subject name
std::string objName; // The object name
std::string instruction; // The instruction string
CmdType type; // The type of command
SecurityLevel lvl; // The Security Level
bool valid; // Valid instruction?
int value; // The value (if provided)
void parseInstruction(std::string);
SecurityLevel getLevelFromString(std::string str);
};
#endif