-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorkTypeTable.h
68 lines (59 loc) · 1.6 KB
/
WorkTypeTable.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
57
58
59
60
61
62
63
64
65
66
67
68
//
// WorkTypeTable.h
// 腾飞科创Model
//
// Created by leavesyoung on 2018/5/2.
// Copyright © 2018年 leavesyoung. All rights reserved.
//
#ifndef WorkTypeTable_h
#define WorkTypeTable_h
#include <string>
#include <vector>
#include <map>
#include <iterator>
using namespace std;
struct WorkTypeTableAttributes {
WorkTypeTableAttributes(){}
~WorkTypeTableAttributes(){}
string tag;
vector<int> WorkerList;
void operator = (WorkTypeTableAttributes u){
this->tag=u.tag;
(this->WorkerList).clear();
for(vector<int>::iterator it=u.WorkerList.begin();it!=u.WorkerList.end();it++) (this->WorkerList).push_back(*it);
}
};
class WorkTypeTable{
public:
WorkTypeTable(){
table.clear();
}
~WorkTypeTable(){}
map<int,WorkTypeTableAttributes>* getTable(){
return &table;
}
//put work types into the table
int setTable(int WorkTypeID,string tag){
if(table.find(WorkTypeID)!=table.end()) return -1;
//warning:work type already exists.Replace it?
else{
WorkTypeTableAttributes temp;
temp.tag=tag;
table[WorkTypeID]=temp;
}
return 0;
}
//default:table has all work types.
int setTable(int WorkTypeID,int WorkerID){
if(table.find(WorkTypeID)==table.end()) return -1;
//error:no such work type
else table[WorkTypeID].WorkerList.push_back(WorkerID);
return 0;
}
void clear(){
table.clear();
}
private:
map<int,WorkTypeTableAttributes> table;
};
#endif /* WorkTypeTable_h */