本文整理汇总了C++中TrexStatelessPort::get_object_list方法的典型用法代码示例。如果您正苦于以下问题:C++ TrexStatelessPort::get_object_list方法的具体用法?C++ TrexStatelessPort::get_object_list怎么用?C++ TrexStatelessPort::get_object_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrexStatelessPort
的用法示例。
在下文中一共展示了TrexStatelessPort::get_object_list方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
/***************************
* get all streams
*
**************************/
trex_rpc_cmd_rc_e
TrexRpcCmdGetAllStreams::_run(const Json::Value ¶ms, Json::Value &result) {
uint8_t port_id = parse_port(params, result);
TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);
bool get_pkt = parse_bool(params, "get_pkt", result);
std::vector <TrexStream *> streams;
port->get_object_list(streams);
Json::Value streams_json = Json::objectValue;
for (auto stream : streams) {
Json::Value j = stream->get_stream_json();
/* should we include the packet as well ? */
if (!get_pkt) {
j.removeMember("packet");
}
std::stringstream ss;
ss << stream->m_stream_id;
streams_json[ss.str()] = j;
}
result["result"]["streams"] = streams_json;
return (TREX_RPC_CMD_OK);
}
示例2: return
/***************************
* get all streams
*
**************************/
trex_rpc_cmd_rc_e
TrexRpcCmdGetAllStreams::_run(const Json::Value ¶ms, Json::Value &result) {
uint8_t port_id = parse_byte(params, "port_id", result);
bool get_pkt = parse_bool(params, "get_pkt", result);
if (port_id >= get_stateless_obj()->get_port_count()) {
std::stringstream ss;
ss << "invalid port id - should be between 0 and " << (int)get_stateless_obj()->get_port_count() - 1;
generate_execute_err(result, ss.str());
}
TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);
std::vector <TrexStream *> streams;
port->get_object_list(streams);
Json::Value streams_json = Json::objectValue;
for (auto stream : streams) {
Json::Value j = stream->get_stream_json();
/* should we include the packet as well ? */
if (!get_pkt) {
j.removeMember("packet");
}
std::stringstream ss;
ss << stream->m_stream_id;
streams_json[ss.str()] = j;
}
result["result"]["streams"] = streams_json;
return (TREX_RPC_CMD_OK);
}