FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sysadmin/src/HookTable.cpp at master · StarryInternet/sysadmin · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
StarryInternet
/
sysadmin
Public
Notifications
You must be signed in to change notification settings
Fork
8
Star
11
Code
Issues
10
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
sysadmin
/
src
/
HookTable.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
90 lines (79 loc) · 2.2 KB
Breadcrumbs
sysadmin
/
src
/
HookTable.cpp
Copy path
File metadata and controls
90 lines (79 loc) · 2.2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
include
"
HookTable.h
"
#
include
<
boost/none.hpp
>
#
include
<
boost/optional.hpp
>
#
include
<
memory
>
#
include
<
vector
>
#
include
<
log4cxx/logger.h
>
#
include
"
HookUser.h
"
#
include
"
HookManager.h
"
namespace
{
log4cxx::LoggerPtr
spLogger
(log4cxx::Logger::getLogger(
"
HookTable
"
));
}
HookTable::HookTable
()
: mTable()
{
}
void
HookTable::Insert
(HookUser&& hook)
{
auto
pHook = std::make_shared<HookUser>(
std::move
(hook));
auto
inserted =
mTable
.
insert
(pHook);
if
(!inserted.
second
)
{
LOG4CXX_WARN
(spLogger,
"
Failed to insert hook with the same name as an existing hook.
"
<<
"
Consider renaming hook:
"
<< hook.
Name
());
}
}
boost::optional<std::shared_ptr<
const
HookUser>>
HookTable::ByName
(
const
std::string& name)
{
auto
found =
mTable
.
get
<Name>().
find
(name);
if
(found !=
mTable
.
get
<Name>().
end
())
{
std::shared_ptr<
const
HookUser> convert = *found;
return
boost::make_optional
(convert);
}
else
{
return
boost::none;
}
}
std::vector<std::shared_ptr<
const
HookUser>>
HookTable::ByType
(
const
HookType type)
{
auto
found =
mTable
.
get
<Type>().
equal_range
(type);
std::vector<std::shared_ptr<
const
HookUser>>
byType
(found.
first
, found.
second
);
return
byType;
}
HookTable::RunLevelServicesMap
HookTable::GetOrderedServices
()
{
RunLevelServicesMap s;
for
(
auto
service:
RunLevelOrder
(HookType::
SERVICE
))
{
size_t
rl = service->
RunLevel
();
if
(!s.
count
(rl))
{
s.
emplace
(rl, std::vector<std::shared_ptr<
const
HookUser>>());
}
if
(
std::find
(s.
at
(rl).
begin
(),
s.
at
(rl).
end
(),
service) == s.
at
(rl).
end
())
{
s.
at
(rl).
emplace_back
(service);
}
}
return
s;
}
std::vector<std::shared_ptr<
const
HookUser>>
HookTable::RunLevelOrder
(
const
HookType type)
{
/*
* Only specifying the first component of a composite key _should_ give us
* all entries of that first component, sorted by the second component.
*/
auto
found =
mTable
.
get
<RunLevel>().
equal_range
(type);
std::vector<std::shared_ptr<
const
HookUser>>
sorted
(found.
first
, found.
second
);
return
sorted;
}
Back
|
FazBrowse Home
|
New Git URL