aboutsummaryrefslogtreecommitdiffstats
path: root/messagebus/src/vespa/messagebus/routing/routingnodeiterator.cpp
blob: 83ca8d37ae4ba6df30230735944e26721f44021c (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "routingnode.h"

namespace mbus {

RoutingNodeIterator::RoutingNodeIterator(std::vector<RoutingNode*> &children) :
    _pos(children.begin()),
    _end(children.end())
{ }

RoutingNodeIterator &
RoutingNodeIterator::next()
{
    ++_pos;
    return *this;
}

RoutingNodeIterator &
RoutingNodeIterator::skip(uint32_t num)
{
    for (uint32_t i = 0; i < num && isValid(); ++i) {
        next();
    }
    return *this;
}

const Route &
RoutingNodeIterator::getRoute() const
{
    return (*_pos)->getRoute();
}

Reply::UP
RoutingNodeIterator::removeReply()
{
    RoutingNode *node = *_pos;
    Reply::UP ret = node->getReply();
    ret->getTrace().setLevel(node->getTrace().getLevel());
    ret->getTrace().swap(node->getTrace());
    return ret;
}

const Reply &
RoutingNodeIterator::getReplyRef() const
{
    return (*_pos)->getReplyRef();
}

} // mbus