forked from LLNL/Caliper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntry.cpp
55 lines (42 loc) · 1.18 KB
/
Entry.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
// Copyright (c) 2019, Lawrence Livermore National Security, LLC.
// See top-level LICENSE file for details.
// Entry class definition
#include "caliper/common/Entry.h"
#include "caliper/common/Node.h"
#include <functional>
using namespace cali;
int
Entry::count(cali_id_t attr_id) const
{
int res = 0;
if (m_node) {
for (const Node* node = m_node; node; node = node->parent())
if (node->attribute() == attr_id)
++res;
} else {
if (m_attr_id != CALI_INV_ID && m_attr_id == attr_id)
++res;
}
return res;
}
Variant
Entry::value(cali_id_t attr_id) const
{
if (!m_node && attr_id == m_attr_id)
return m_value;
for (const Node* node = m_node; node; node = node->parent())
if (node->attribute() == attr_id)
return node->data();
return Variant();
}
bool cali::operator == (const Entry& lhs, const Entry& rhs)
{
if (lhs.m_node)
return rhs.m_node ? (lhs.m_node->id() == rhs.m_node->id()) : false;
else if (rhs.m_node)
return false;
else if (lhs.m_attr_id == rhs.m_attr_id)
return lhs.m_value == rhs.m_value;
return false;
}
const Entry Entry::empty;