LCOV - code coverage report
Current view: top level - modules/intra - intra_getter_impl.cc (source / functions) Hit Total Coverage
Test: vlink Lines: 36 36 100.0 %
Date: 2026-06-27 19:56:04 Functions: 15 15 100.0 %
Branches: 20 34 58.8 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (C) 2026 by Thun Lu. All rights reserved.
       3                 :            :  * Author: Thun Lu <thun.lu@zohomail.cn>
       4                 :            :  * Repo:   https://github.com/thun-res/vlink
       5                 :            :  *  _    __   __      _           __
       6                 :            :  * | |  / /  / /     (_) ____    / /__
       7                 :            :  * | | / /  / /     / / / __ \  / //_/
       8                 :            :  * | |/ /  / /___  / / / / / / / ,<
       9                 :            :  * |___/  /_____/ /_/ /_/ /_/ /_/|_|
      10                 :            :  *
      11                 :            :  * Licensed under the Apache License, Version 2.0 (the "License");
      12                 :            :  * you may not use this file except in compliance with the License.
      13                 :            :  * You may obtain a copy of the License at
      14                 :            :  *
      15                 :            :  *     http://www.apache.org/licenses/LICENSE-2.0
      16                 :            :  *
      17                 :            :  * Unless required by applicable law or agreed to in writing, software
      18                 :            :  * distributed under the License is distributed on an "AS IS" BASIS,
      19                 :            :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      20                 :            :  * See the License for the specific language governing permissions and
      21                 :            :  * limitations under the License.
      22                 :            :  */
      23                 :            : 
      24                 :            : #include "./intra_getter_impl.h"
      25                 :            : 
      26                 :            : #include <utility>
      27                 :            : 
      28                 :            : #include "./base/helpers.h"
      29                 :            : 
      30                 :            : namespace vlink {
      31                 :            : 
      32                 :            : // IntraGetterImpl
      33         [ +  - ]:         13 : IntraGetterImpl::IntraGetterImpl(const IntraConf& conf) : conf_(conf) {
      34         [ +  + ]:         13 :   if (conf.type == "direct") {
      35                 :          2 :     type_ = IntraType::kDirect;
      36                 :            :   }
      37                 :         13 : }
      38                 :            : 
      39                 :         13 : void IntraGetterImpl::init() {
      40   [ +  +  +  -  :         13 :   static auto& factory = IntraFactory::get();
             +  -  -  - ]
      41                 :            : 
      42                 :         13 :   conf_.hash_code = Helpers::get_hash_code(conf_.event);
      43                 :            : 
      44         [ +  - ]:         13 :   object_ = factory.get_object<Object>({kImplType, conf_.address, conf_.pipeline, type_});
      45                 :            : 
      46         [ +  + ]:         13 :   if (object_->msg_map_is_empty()) {
      47                 :         12 :     object_->add_impl(this);
      48                 :            : 
      49   [ +  -  +  - ]:         19 :     object_->traverse_sub_connect_callback([](NodeImpl*, const auto& callback) { callback(true); });
      50                 :            :   } else {
      51                 :          1 :     object_->add_impl(this);
      52                 :            :   }
      53                 :         13 : }
      54                 :            : 
      55                 :         13 : void IntraGetterImpl::deinit() {
      56                 :         13 :   object_->remove_impl(this);
      57                 :            : 
      58         [ +  + ]:         13 :   if (object_->msg_map_is_empty()) {
      59   [ +  -  +  - ]:         19 :     object_->traverse_sub_connect_callback([](NodeImpl*, const auto& callback) { callback(false); });
      60                 :            :   }
      61                 :         13 : }
      62                 :            : 
      63                 :          1 : bool IntraGetterImpl::suspend() {
      64                 :          1 :   has_suspend = true;
      65                 :            : 
      66                 :          1 :   return true;
      67                 :            : }
      68                 :            : 
      69                 :          1 : bool IntraGetterImpl::resume() {
      70                 :          1 :   has_suspend = false;
      71                 :            : 
      72                 :          1 :   return true;
      73                 :            : }
      74                 :            : 
      75                 :          2 : bool IntraGetterImpl::is_suspend() const { return has_suspend; }
      76                 :            : 
      77                 :         19 : const Conf* IntraGetterImpl::get_conf() const { return &conf_; }
      78                 :            : 
      79                 :          2 : const AbstractNode* IntraGetterImpl::get_abstract_node() const { return object_.get(); }
      80                 :            : 
      81                 :          1 : bool IntraGetterImpl::attach(class MessageLoop*) {
      82   [ +  -  +  - ]:          2 :   VLOG_W("Function [attach] is not supported.");
      83                 :          1 :   return false;
      84                 :            : }
      85                 :            : 
      86                 :          1 : bool IntraGetterImpl::detach() {
      87   [ +  -  +  - ]:          2 :   VLOG_W("Function [detach] is not supported.");
      88                 :          1 :   return false;
      89                 :            : }
      90                 :            : 
      91                 :         13 : bool IntraGetterImpl::listen(MsgCallback&& callback) {
      92                 :         13 :   object_->register_msg_callback(this, std::move(callback));
      93                 :            : 
      94                 :         13 :   return true;
      95                 :            : }
      96                 :            : 
      97                 :            : }  // namespace vlink

Generated by: LCOV version 1.14