| 44 | } |
| 45 | |
| 46 | int dump_module(std::string module_name) { |
| 47 | auto &M = bmf_sdk::ModuleManager::instance(); |
| 48 | bmf_sdk::ModuleInfo info(module_name); |
| 49 | std::shared_ptr<bmf_sdk::ModuleFactoryI> factory; |
| 50 | bool get_module_register_info = false; |
| 51 | try { |
| 52 | factory = M.load_module(info, &info); |
| 53 | get_module_register_info = |
| 54 | factory->module_info(info); // XXX: will throw an exception when |
| 55 | // dump a python non-module package |
| 56 | } catch (const std::exception &e) { |
| 57 | BMFLOG(BMF_ERROR) << "could not find module:" << module_name << ", " |
| 58 | << e.what() << std::endl; |
| 59 | return -1; |
| 60 | } |
| 61 | |
| 62 | int w = std::string("module_entry: ").size(); |
| 63 | if (get_module_register_info) { |
| 64 | w = std::string("module_description: ").size(); |
| 65 | } |
| 66 | std::cout << std::setw(w) << std::setfill(' ') |
| 67 | << "module_name: " << info.module_name << std::endl; |
| 68 | std::cout << std::setw(w) << std::setfill(' ') |
| 69 | << "module_entry: " << info.module_entry << std::endl; |
| 70 | std::cout << std::setw(w) << std::setfill(' ') |
| 71 | << "module_type: " << info.module_type << std::endl; |
| 72 | std::cout << std::setw(w) << std::setfill(' ') |
| 73 | << "module_path: " << info.module_path << std::endl; |
| 74 | if (get_module_register_info) { |
| 75 | std::cout << std::setw(w) << std::setfill(' ') |
| 76 | << "module_description: " << info.module_description |
| 77 | << std::endl; |
| 78 | std::cout << std::setw(w) << std::setfill(' ') |
| 79 | << "module_tag: " << info.module_tag << std::endl; |
| 80 | } |
| 81 | return 0; |
| 82 | } |
| 83 | |
| 84 | int install_module(const bmf_sdk::ModuleInfo &info, bool force) { |
| 85 | // check module_path |
no test coverage detected