blob: d016b052dae14419c90b849f3709127cb7cd38aa (
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "simple_component_config_producer.h"
namespace vespalib {
SimpleComponentConfigProducer::SimpleComponentConfigProducer()
: _lock(),
_state()
{
}
void
SimpleComponentConfigProducer::addConfig(const Config &config)
{
LockGuard guard(_lock);
_state.insert(std::make_pair(config.name, config)).first->second = config;
}
void
SimpleComponentConfigProducer::removeConfig(const vespalib::string &name)
{
LockGuard guard(_lock);
_state.erase(name);
}
void
SimpleComponentConfigProducer::getComponentConfig(Consumer &consumer)
{
typedef std::map<vespalib::string, Config>::const_iterator ITR;
LockGuard guard(_lock);
for (ITR itr = _state.begin(); itr != _state.end(); ++itr) {
consumer.add(itr->second);
}
}
} // namespace vespalib
|