LCOV - code coverage report
Current view: top level - src - actor_type_registry.cpp (source / functions) Coverage Total Hit
Test: HPActor Coverage Lines: 66.7 % 18 12
Test Date: 2026-05-20 02:24:49 Functions: 75.0 % 4 3
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             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/actor_type_registry.hpp>
      16                 :             : #include <hpactor/core/actor_system.hpp>
      17                 :             : 
      18                 :             : namespace hpactor {
      19                 :             : 
      20                 :             : result<ActorAddress>
      21                 :           2 : ActorTypeRegistry::spawn(ActorSystem& system, const std::string& name,
      22                 :             :                          const StreamBuffer& /*args*/, TypeTag /*args_type*/) {
      23                 :           2 :     auto it = types_by_name_.find(name);
      24                 :           2 :     if (it == types_by_name_.end()) {
      25                 :             :         return result<ActorAddress>::make(
      26                 :           1 :             error(spawn_errors::unknown_type, "unknown actor type: " + name));
      27                 :             :     }
      28                 :             : 
      29                 :           1 :     ActorAddress addr = it->second.factory(system);
      30                 :           1 :     return result<ActorAddress>::make(std::move(addr));  // NOLINT(performance-move-const-arg)
      31                 :             : }
      32                 :             : 
      33                 :           2 : bool ActorTypeRegistry::has(const std::string& name) const {
      34                 :           2 :     return types_by_name_.find(name) != types_by_name_.end();
      35                 :             : }
      36                 :             : 
      37                 :           1 : ActorType ActorTypeRegistry::type_id(const std::string& name) const {
      38                 :           1 :     auto it = types_by_name_.find(name);
      39                 :           1 :     if (it != types_by_name_.end()) {
      40                 :           1 :         return it->second.type_id;
      41                 :             :     }
      42                 :           0 :     return ActorType{0};
      43                 :             : }
      44                 :             : 
      45                 :           0 : std::string ActorTypeRegistry::type_name(ActorType type) const {
      46                 :           0 :     auto it = names_by_type_.find(type);
      47                 :           0 :     if (it != names_by_type_.end()) {
      48                 :           0 :         return it->second;
      49                 :             :     }
      50                 :           0 :     return "";
      51                 :             : }
      52                 :             : 
      53                 :             : } // namespace hpactor
        

Generated by: LCOV version 2.0-1