blob: 2e33e54c638b90d4fda838174bc80c2e3b24e6b7 (
plain) (
blame)
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
* @class vdslib::Node
*
* Refers to a single node in a VDS cluster.
*/
#pragma once
#include "nodetype.h"
namespace storage::lib {
class Node {
const NodeType* _type;
uint16_t _index;
public:
Node() noexcept : _type(&NodeType::STORAGE), _index(0) { }
Node(const NodeType& type, uint16_t index) noexcept
: _type(&type), _index(index) { }
const NodeType& getType() const { return *_type; }
uint16_t getIndex() const { return _index; }
bool operator==(const Node& other) const {
return (other._index == _index && *other._type == *_type);
}
bool operator!=(const Node& other) const {
return (other._index != _index || *other._type != *_type);
}
bool operator<(const Node& n) const {
if (*_type != *n._type) return (*_type < *n._type);
return (_index < n._index);
}
};
std::ostream & operator << (std::ostream & os, const Node & n);
vespalib::asciistream & operator << (vespalib::asciistream & os, const Node & n);
}
|