Branch data Line data Source code
1 : : // Copyright 2026 HPActor Contributors
2 : : //
3 : : // Licensed under the Apache License, Version 2.0 (the "License");
4 : : // you may not use this file except in compliance with the License.
5 : : // You may obtain a copy of the License at
6 : : //
7 : : // http://www.apache.org/licenses/LICENSE-2.0
8 : : //
9 : : // Unless required by applicable law or agreed to in writing, software
10 : : // distributed under the License is distributed on an "AS IS" BASIS,
11 : : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : : // See the License for the specific language governing permissions and
13 : : // limitations under the License.
14 : :
15 : : #include <hpactor/config/actor_factory_registry.hpp>
16 : :
17 : : namespace hpactor::config {
18 : :
19 : 14 : ActorFactoryRegistry& ActorFactoryRegistry::instance() {
20 : 14 : static ActorFactoryRegistry registry;
21 : 14 : return registry;
22 : : }
23 : :
24 : 13 : ActorFactory ActorFactoryRegistry::get_factory(const std::string& name) const {
25 : 13 : auto it = factories_.find(name);
26 : 13 : if (it != factories_.end()) {
27 : 12 : return it->second;
28 : : }
29 : 1 : return nullptr;
30 : : }
31 : :
32 : 13 : bool ActorFactoryRegistry::has(const std::string& name) const {
33 : 13 : return factories_.find(name) != factories_.end();
34 : : }
35 : :
36 : 1 : std::vector<std::string> ActorFactoryRegistry::known_names() const {
37 : 1 : std::vector<std::string> names;
38 : 1 : names.reserve(factories_.size());
39 : 3 : for (const auto& [name, _] : factories_) {
40 : 2 : names.push_back(name);
41 : : }
42 : 1 : return names;
43 : : }
44 : :
45 : : } // namespace hpactor::config
|