forked from LLNL/Caliper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.h
63 lines (44 loc) · 1.42 KB
/
Node.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
// Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC.
// See top-level LICENSE file for details.
/**
* \file Node.h
* \brief Metadata tree node class.
*/
#ifndef CALI_NODE_H
#define CALI_NODE_H
#include "cali_types.h"
#include "Variant.h"
#include "util/lockfree-tree.hpp"
#include <atomic>
namespace cali
{
/// \brief A metadata tree node.
/// Represents a metadata tree node and its (attribute key, value) pair.
class Node : public util::LockfreeIntrusiveTree<Node>
{
cali_id_t m_id;
util::LockfreeIntrusiveTree<Node>::Node m_treenode;
cali_id_t m_attribute;
Variant m_data;
public:
Node(cali_id_t id, cali_id_t attr, const Variant& data)
: util::LockfreeIntrusiveTree<Node>(this, &Node::m_treenode),
m_id { id },
m_attribute { attr },
m_data { data }
{ }
Node(const Node&) = delete;
Node& operator = (const Node&) = delete;
/// \brief Check if the node's attribute and value are equal to
/// \a attr and \a v
bool equals(cali_id_t attr, const Variant& v) const {
return m_data == v && m_attribute == attr;
}
/// \brief Return the node's attribute ID
cali_id_t attribute() const { return m_attribute; }
/// \brief Return the node's data element
Variant data() const { return m_data; }
cali_id_t id() const { return m_id; }
};
} // namespace cali
#endif