forked from ljtum/logalyzer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCapMap.cpp
91 lines (74 loc) · 1.55 KB
/
CapMap.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "CapMap.h"
#include <iostream>
CapMap::CapMap()
{
}
void CapMap::add_cap_info( int badge, size_t kcap, std::shared_ptr<Stage> stage )
{
_capabilities.emplace_back( std::make_shared<CapabilityInfo>( badge, kcap, stage ) );
}
void CapMap::remove_cap_info( int badge, size_t kcap )
{
/* for( auto it = _capabilities.begin(); it != _capabilities.end(); ++it )
{
if( it->badge == badge && it->kcap == kcap && !it->removed )
{
it->removed = true;
break;
}
}
*/
for( auto& cap_info : _capabilities )
{
if( cap_info->badge == badge && cap_info->kcap == kcap && !cap_info->removed )
{
cap_info->removed = true;
break;
}
}
}
std::shared_ptr<CapabilityInfo> CapMap::get_cap_info( int badge )
{
for( auto& cap_info : _capabilities )
{
if( cap_info->badge == badge && !cap_info->removed )
return cap_info;
}
return {};
}
const std::list<std::shared_ptr<CapabilityInfo>>& CapMap::get_cap_infos()
{
return _capabilities;
}
int CapMap::kcap_to_badge( size_t kcap )
{
for( auto& cap_info : _capabilities )
{
if( cap_info->kcap == kcap && !cap_info->removed )
return cap_info->badge;
}
return 0;
}
const std::string&CapMap::task_name()
{
return _task_name;
}
size_t CapMap::valid_caps()
{
size_t count = 0;
for( auto& cap_info : _capabilities )
{
if( !cap_info->removed )
++count;
}
return count;
}
void CapMap::print_info()
{
std::cout << "CapMap for task '" << _task_name << "'" << std::endl;
for( auto& cap_info : _capabilities )
{
std::cout << cap_info->description() << std::endl;
}
std::cout << std::endl;
}