int main() { boost::signal2<void, int, int> sig; sig.connect(print_sum()); sig.connect(print_product()); sig(3, 5); boost::signals::connection print_diff_con = sig.connect(print_difference()); // sig is still connected to print_diff_con assert(print_diff_con.connected()); sig(5, 3); // prints 8, 15, and 2 print_diff_con.disconnect(); // disconnect the print_difference slot sig(5, 3); // now prints 8 and 15, but not the difference assert(!print_diff_con.connected()); // not connected any more { boost::signals::scoped_connection c = sig.connect(print_quotient()); sig(5, 3); // prints 8, 15, and 1 } // c falls out of scope, so sig and print_quotient are disconnected sig(5, 3); // prints 8 and 15 return 0; }
void list_products_interf(){ int index = list_products(); if(index > 0 && index < amount){ //if index = -1 then user aborted print_product(good[index]); } }
int edit_product(int index) { //show product print_product(good[index]); struct goods tmp = good[index]; int q = ask_question_char("\nVad vill du redigera?\n[N]amn\n[B]eskrivning\n[P]ris\n[L]agerhylla\nAn[t]al\n\n[a]vbryt","NBPLta"); switch (q) { case 'N': printf("Nuvarande namn:%s\n", good[index].name); char *new_name = ask_question_string("Nytt namn:",100); free(good[index].name); good[index].name = new_name; break; case 'B': printf("Nuvarande beskrivning:%s\n", good[index].desc); char *new_desc = ask_question_string("Ny beskrivning:",100); free(good[index].desc); good[index].desc = new_desc; break; case 'P': printf("Nuvarande pris:%d\n", good[index].price); int new_price = ask_question_int("Nytt pris:"); good[index].price = new_price; break; case 'L': printf("Nuvarande lagerhylla:%s\n", good[index].place); char *new_place = ask_for_place("Ny lagerhylla:"); free(good[index].place); good[index].place = new_place; break; case 't': printf("Nuvarande antal:%d\n", good[index].count); int new_count = ask_question_int("Nytt antal:"); good[index].count = new_count; break; case 'a': break; default: edit_product(index); break; } undo.copy = tmp; undo.merch = &good[index]; undo.type = 3; return 0; }
void remove_product_interf() { puts("Ta bort en vara"); puts("Välj en vara att ta bort:"); int i = list_products(); if(i > 0 && i < amount){ print_product(good[i]); char q = ask_question_char("Ta bort varan? [J]a,[N]ej","JN"); if(q == 'J'){ remove_product(i); } } }
int main() { boost::signal2<void, int, int> sig; sig.connect(print_sum()); sig.connect(print_product()); sig(3, 5); boost::signals::connection print_diff_con = sig.connect(print_difference()); // sig is still connected to print_diff_con assert(print_diff_con.connected()); sig(5, 3); // prints 8, 15, and 2 print_diff_con.disconnect(); // disconnect the print_difference slot sig(5, 3); // now prints 8 and 15, but not the difference assert(!print_diff_con.connected()); // not connected any more return 0; }
/* * Scan SCSI busses to detect any devices * that we want to supply to the Amgia. * * Based on code from cdrecord */ static int scanscsi (SCSI *scgp) { int bus; int tgt; int lun = 0; int initiator; int have_tgt; int n; scgp->silent++; for (bus = 0; bus < 16; bus++) { scg_settarget (scgp, bus, 0, 0); if (!scg_havebus (scgp, bus)) continue; initiator = scg_initiator_id (scgp); write_log ("scsibus%d:\n", bus); for (tgt = 0; tgt < 16; tgt++) { n = bus * 100 + tgt; scg_settarget (scgp, bus, tgt, lun); have_tgt = unit_ready (scgp) || scgp->scmd->error != SCG_FATAL; if (!have_tgt && tgt > 7) { if (scgp->scmd->ux_errno == EINVAL) break; continue; } write_log (" %d,%d,%d %d ", bus, tgt, lun, n); if (tgt == initiator) { write_log ("HOST ADAPTOR\n"); continue; } if (!have_tgt) { /* Hack: fd -> -2 means no access */ write_log ( "%c\n", scgp->fd == -2 ? '?':'*'); continue; } if ((scgp->scmd->error < SCG_FATAL) || (scgp->scmd->scb.chk && scgp->scmd->sense_count > 0)) { struct scsi_inquiry *inq = scgp->inq; inquiry (scgp, inq, sizeof (*inq)); print_product (inq); /* Just CD/DVD drives for now */ if (inq->type == INQ_ROMD) add_drive (scgp); } write_log ("\n"); } } scgp->silent--; return 0; }