-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccessDescriptor.cpp
56 lines (46 loc) · 1.05 KB
/
AccessDescriptor.cpp
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
//
//
// @ Project : FileSystem
// @ File Name : AccessDescriptor.cpp
// @ Date : 9/15/2014
// @ Author : Stefan Djordjevic
//
//
#include "../Header Files/AccessDescriptor.h"
#include "../Header Files/FilesystemObject.h"
#include <string>
#include <vector>
using namespace std;
AccessDescriptor::AccessDescriptor(FilesystemObject *fo):allowedOperations()
{
protectedObject = fo;
}
void AccessDescriptor::add(string operationName)
{
allowedOperations.push_back(operationName);
}
void AccessDescriptor::remove(string operationName)
{
for(vector<string>::iterator it = allowedOperations.begin();
it != allowedOperations.end(); ++it)
{
if(!(*it).compare(operationName))
{
allowedOperations.erase(it);
break;
}
}
}
const vector<string>& AccessDescriptor::getAllowedOperations() const
{
return allowedOperations;
}
bool AccessDescriptor::checkAccess(string operationName)
{
for(vector<string>::iterator it = allowedOperations.begin();
it != allowedOperations.end(); it++)
{
if(!(*it).compare(operationName)) return true;
}
return false;
}