blob: 7df40052178f6726cd15706889c760151a6c64c4 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "iroutingpolicyfactory.h"
#include <map>
#include <mutex>
namespace documentapi {
class RoutingPolicyRepository {
private:
using FactoryMap = std::map<string, IRoutingPolicyFactory::SP>;
mutable std::mutex _lock;
FactoryMap _factories;
public:
RoutingPolicyRepository(const RoutingPolicyRepository &) = delete;
RoutingPolicyRepository & operator = (const RoutingPolicyRepository &) = delete;
/**
* Constructs a new routing policy repository.
*/
RoutingPolicyRepository();
/**
* Registers a routing policy factory for a given name.
*
* @param name The name of the factory to register.
* @param factory The factory to register.
*/
void putFactory(const string &name, IRoutingPolicyFactory::SP factory);
/**
* Returns the routing policy factory for a given name.
*
* @param name The name of the factory to return.
* @return The routing policy factory matching the criteria, or null.
*/
IRoutingPolicyFactory::SP getFactory(const string &name) const;
/**
* Creates and returns a routing policy using the named factory and the given parameter.
*
* @param name The name of the factory to use.
* @param param The parameter to pass to the factory.
* @return The craeted policy.
*/
mbus::IRoutingPolicy::UP createPolicy(const string &name, const string ¶m) const;
};
}
|