github.com/igggame/nebulas-go@v2.1.0+incompatible/nbre/core/net_ipc/nipc_pkg.cpp (about)

     1  // Copyright (C) 2018 go-nebulas authors
     2  //
     3  // This file is part of the go-nebulas library.
     4  //
     5  // the go-nebulas library is free software: you can redistribute it and/or
     6  // modify
     7  // it under the terms of the GNU General Public License as published by
     8  // the Free Software Foundation, either version 3 of the License, or
     9  // (at your option) any later version.
    10  //
    11  // the go-nebulas library is distributed in the hope that it will be useful,
    12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  // GNU General Public License for more details.
    15  //
    16  // You should have received a copy of the GNU General Public License
    17  // along with the go-nebulas library.  If not, see
    18  // <http://www.gnu.org/licenses/>.
    19  //
    20  #include "core/net_ipc/nipc_pkg.h"
    21  
    22  namespace neb {
    23  namespace core {
    24  
    25  std::string pkg_type_id_to_name(uint64_t type) {
    26    std::string ret;
    27    switch (type) {
    28    case heart_beat_pkg:
    29      ret = "heart_beat_pkg";
    30      break;
    31    case nipc_last_pkg_id:
    32      ret = "nipc_last_pkg_id";
    33      break;
    34  
    35  #define define_ipc_param(type, name)
    36  
    37  #define define_ipc_pkg(type, ...)                                              \
    38    case JOIN(type, _pkg):                                                       \
    39      ret = #type;                                                               \
    40      break;
    41  
    42  #define define_ipc_api(req, ack)
    43  
    44  #include "core/net_ipc/ipc_interface_impl.h"
    45  
    46  #undef define_ipc_api
    47  #undef define_ipc_pkg
    48  #undef define_ipc_param
    49    default:
    50      ret = "not_def_in_nipc";
    51    }
    52  
    53    return ret;
    54  }
    55  
    56  bool is_pkg_type_has_callback(uint64_t type) {
    57  
    58  #define define_ipc_param(type, name)
    59  #define define_ipc_pkg(type, ...)
    60  #define define_ipc_api(req, ack)                                               \
    61    if (type == JOIN(req, _pkg))                                                 \
    62      return true;
    63  
    64  #include "core/net_ipc/ipc_interface_impl.h"
    65  
    66  #undef define_ipc_api
    67  #undef define_ipc_pkg
    68  #undef define_ipc_param
    69    return false;
    70  }
    71  } // namespace core
    72  } // namespace neb