MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / on_add_protocol

Method on_add_protocol

DSView/pv/dock/protocoldock.cpp:293–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291}
292
293void ProtocolDock::on_add_protocol()
294{
295 if (_decoderInfoList.size() == 0){
296 MsgBox::Show(NULL, L_S(STR_PAGE_MSG, S_ID(IDS_MSG_DECODER_LIST_EMPTY), "Decoder list is empty!"));
297 return;
298 }
299 if (_selected_protocol_id == ""){
300 MsgBox::Show(NULL, L_S(STR_PAGE_MSG, S_ID(IDS_MSG_NO_SEL_DECODER), "Please select a decoder!"));
301 return;
302 }
303
304 int dex = this->get_protocol_index_by_id(_selected_protocol_id);
305 assert(dex >= 0);
306
307 //check the base protocol
308 srd_decoder *const dec = (srd_decoder *)(_decoderInfoList[dex]->_data_handle);
309 QString pro_id(dec->id);
310 std::list<data::decode::Decoder*> sub_decoders;
311
312 assert(dec->inputs);
313
314 QString input_id = parse_protocol_id((char *)dec->inputs->data);
315
316 if (input_id != "logic")
317 {
318 pro_id = ""; //reset base protocol
319
320 int base_dex = get_output_protocol_by_id(input_id);
321 sub_decoders.push_front(new data::decode::Decoder(dec));
322
323 while (base_dex != -1)
324 {
325 srd_decoder *base_dec = (srd_decoder *)(_decoderInfoList[base_dex]->_data_handle);
326 pro_id = QString(base_dec->id); //change base protocol
327
328 assert(base_dec->inputs);
329
330 input_id = parse_protocol_id((char *)base_dec->inputs->data);
331
332 if (input_id == "logic")
333 {
334 break;
335 }
336
337 sub_decoders.push_front(new data::decode::Decoder(base_dec));
338 pro_id = ""; //reset base protocol
339 base_dex = get_output_protocol_by_id(input_id);
340 }
341 }
342
343 if (pro_id == ""){
344 MsgBox::Show(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_ERROR), "error"),
345 L_S(STR_PAGE_MSG, S_ID(IDS_MSG_FIND_BASE_DECODER_ERROR), "find the base decoder error!"));
346
347 for(auto sub: sub_decoders){
348 delete sub;
349 }
350 sub_decoders.clear();

Callers 1

OnItemClickMethod · 0.95

Calls 4

ShowFunction · 0.85
sizeMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected