blob: 2bee4b43baab34b1af8d61aa47f4ad7d9ce9597c (
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
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "route.h"
namespace mbus {
class RoutingNode;
class Reply;
/**
* Implements an iterator for the child routing contexts of this. Use {@link
* RoutingContext#getChildIterator()} to retrieve an instance of this.
*/
class RoutingNodeIterator {
private:
std::vector<RoutingNode*>::iterator _pos, _end;
public:
/**
* Constructs a new iterator based on a given list.
*
* @param children The list to iterate through.
*/
explicit RoutingNodeIterator(std::vector<RoutingNode*> &children);
/**
* Returns whether or not this iterator is valid.
*
* @return True if we are still pointing to a valid entry.
*/
[[nodiscard]] bool isValid() const { return _pos != _end; }
/**
* Steps to the next child in the map.
*
* @return This, to allow chaining.
*/
RoutingNodeIterator &next();
/**
* Skips the given number of children.
*
* @param num The number of children to skip.
* @return This, to allow chaining.
*/
RoutingNodeIterator &skip(uint32_t num);
/**
* Returns the route of the current child.
*
* @return The route.
*/
[[nodiscard]] const Route &getRoute() const;
/**
* Removes and returns the reply of the current child. This is the correct way of reusing a reply of a
* child node, the {@link #getReplyRef()} should be used when just inspecting a child reply.
*
* @return The reply.
*/
std::unique_ptr<Reply> removeReply();
/**
* Returns the reply of the current child.
*
* @return The reply.
*/
[[nodiscard]] const Reply &getReplyRef() const;
};
} // mbus
|