QString CountLookup::lookupById(Id count_id) { Count count; if (count_id != INVALID_ID && _quasar->db()->lookup(count_id, count)) return count.number(); return ""; }
int main() { Count C; ++C; ++C; ++C; C.display(); }
int main() { Count counter; cout << "counter.x after instantiation: "; counter.display(); cout << "counter.x after call to friend function setX():"; setX(counter, 8); counter.display(); }
void SseProxy::beginSendingCandidateResults(const Count &count, int activityId) { cout << "SseProxy: beginSendingCandidateResults" << endl; DxMessageCode code = BEGIN_SENDING_CANDIDATE_RESULTS; int dataLength = sizeof(Count); Count marshall = count; marshall.marshall(); sendMessage(code, activityId, dataLength, &marshall); }
void SseProxy::beginSendingBadBands(const Count &count, int activityId) { cout << "SseProxy: beginSendingBadBands" << endl; DxMessageCode code = BEGIN_SENDING_BAD_BANDS; int dataLength = sizeof(Count); Count marshall = count; marshall.marshall(); sendMessage(code, activityId, dataLength, &marshall); }
void SseProxy::beginSendingCwCoherentSignals(const Count &count, int activityId) { cout << "SseProxy: beginSendingCwCoherentSignals" << endl; DxMessageCode code = BEGIN_SENDING_CW_COHERENT_SIGNALS; int dataLength = sizeof(Count); Count marshall = count; marshall.marshall(); sendMessage(code, activityId, dataLength, &marshall); }
int main() { Count counter; // create Count object cout << "counter.x after instantiation: "; counter.print(); setX( counter, 8 ); // set x using a friend function cout << "counter.x after call to setX friend function: "; counter.print(); } // end main
int main() { Count counter; counter.print(); setX(counter, 8); counter.print(); return 0; }
void SseProxy::beginSendingArchiveComplexAmplitudes( const Count &nHalfFrames, int activityId) { cout << "SseProxy: beginSendingArchiveComplexAmplitudes" << endl; DxMessageCode code = BEGIN_SENDING_ARCHIVE_COMPLEX_AMPLITUDES; int dataLength = sizeof(Count); Count marshall = nHalfFrames; marshall.marshall(); sendMessage(code, activityId, dataLength, &marshall); }
// Return the number of unique items matching the ids // int List::get_count(Uint16 item_id, int image_id) { info_available(); if (last_count.matches(item_id, image_id)) return last_count.get_count(); int match_count = 0; for (size_t i=0; i<the_list.size(); ++i) if (the_list[i]->compare(item_id, image_id)) match_count++; last_count.set(item_id, image_id, match_count); return last_count.get_count(); }
int main(int argc, const char *argv[]) { Count counter; std::cout << "counter.x after instantiation: "; counter.print(); setX(counter, 8); std::cout << "counter.x after call to setX friend function: "; counter.print(); return 0; }
virtual void run() { while (!isStopping()) { Bottle b; if (p.read(b)) { printf("%s read %s\n", p.getName().c_str(), b.toString().c_str()); counter->count(b.get(1).asInt32()); } } }
int main() { Count counter; // create counter object Count *counterPtr = &counter; // create pointer to counter Count &counterRef = counter; // create reference to counter cout << "Assign 1 to x and print using the object's name: "; counter.x = 1; // assign 1 to data member x counter.print(); // call member function print cout << "Assign 2 to x and print using a reference: "; counterRef.x = 2; // assign 2 to data member x counterRef.print(); // call member function print cout << "Assign 3 to x and print using a pointer: "; counterPtr->x = 3; // assign 3 to data member x counterPtr->print(); // call member function print return 0; } // end main
int main(int argc, const char * argv[]) { Count counter; Count *counterPtr=&counter; Count &counterRef = counter; cout<<"Set counter to 1..\n"; counter.setX(1); counter.print(); cout<<"Set counter Ref to 2..\n"; counterRef.setX(2); counter.print(); cout<<"Set counter Ptr to 3..\n"; counterPtr->setX(3); counterPtr->print(); return 0; }
int main(int argc, char *argv[]) { Network yarp; Count counter; StressPublisher pubs[N]; StressSubscriber subs[N]; for (int i=0; i<N; i++) { pubs[i].n = i; subs[i].n = i; pubs[i].counter = &counter; subs[i].counter = &counter; pubs[i].start(); subs[i].start(); } printf("Started.....\n"); for (int i=0; i<N; i++) { pubs[i].stop(); } printf("Stopping.\n"); for (int i=0; i<N; i++) { subs[i].stop(); } counter.show(); for (int i=0; i<N; i++) { for (int j=0; j<N; j++) { if (!NetworkBase::isConnected(pubs[i].p.getName(), subs[i].p.getName())) { printf(" *** failed to connect %s -> %s\n", pubs[i].p.getName().c_str(), subs[i].p.getName().c_str()); } } } return 0; }
int main() { Count a; a.Show(); { Count b; a.Show(); b.Show(); } a.Show(); }
int main(){ Count a; a.Show(); // local scope { Count b; a.Show(); b.Show(); } a.Show(); }
int main(int argc, char **argv) { Count counter; Count *counterPtr = &counter; Count &counterRef = counter; counter.setX(1); counter.print(); counterPtr->setX(2); counterPtr->print(); counterRef.setX(3); counterRef.print(); counter.print(); }
size_t hashCode(Count const& count) const { return count.hash(); }
void report() const { std::cout << " stores:" << stores.value() << '\n'; std::cout << " loads:" << loads.value() << '\n'; }
bool Player::canGive(const Count<const Transferable *> & types) const { Count<const Transferable *>::const_iterator itr; for (itr = types.begin(); itr != types.end(); ++itr) if (!canGive(itr->first, itr->second)) return false; return true; }
void Player::give(const Count<const Transferable *> & types) { Count<const Transferable *>::const_iterator itr; for (itr = types.begin(); itr != types.end(); ++itr) give(itr->first, itr->second); }
// dispatch incoming sse message to appropriate // dx method void SseProxy::handleIncomingMessage(SseInterfaceHeader *hdr, void *bodybuff) { cout << "SseProxy Recv: " << SseDxMsg::messageCodeToString(hdr->code) << endl; cout << *hdr; DxConfiguration *config; DxActivityParameters *actParam; StartActivity *startAct; DxScienceDataRequest *dataRequest; Count *count; CwPowerSignal *cwPowerSignal; CwCoherentSignal *cwCoherentSignal; ArchiveRequest *archiveRequest; FollowUpCwSignal *followUpCwSignal; FollowUpPulseSignal *followUpPulseSignal; Assert(dx_); // dispatch to Dx here // process message body, if there is one switch (hdr->code) { case REQUEST_INTRINSICS: dx_->requestIntrinsics(this); break; case CONFIGURE_DX: Assert(hdr->dataLength == sizeof(DxConfiguration)); config = static_cast<DxConfiguration *>(bodybuff); config->demarshall(); dx_->configureDx(config); dx_->printConfiguration(); break; case PERM_RFI_MASK: Assert(hdr->dataLength > 0); sendPermRfiMaskToDx(bodybuff); break; case BIRDIE_MASK: Assert(hdr->dataLength > 0); sendBirdieMaskToDx(bodybuff); break; case RCVR_BIRDIE_MASK: Assert(hdr->dataLength > 0); sendRcvrBirdieMaskToDx(bodybuff); break; case TEST_SIGNAL_MASK: Assert(hdr->dataLength > 0); sendTestSignalMaskToDx(bodybuff); break; case RECENT_RFI_MASK: Assert(hdr->dataLength > 0); sendRecentRfiMaskToDx(bodybuff); break; case SEND_DX_ACTIVITY_PARAMETERS: Assert(hdr->dataLength == sizeof(DxActivityParameters)); actParam = static_cast<DxActivityParameters *>(bodybuff); actParam->demarshall(); dx_->setDxActivityParameters(actParam); dx_->printActivityParameters(); break; case DX_SCIENCE_DATA_REQUEST: Assert(hdr->dataLength == sizeof(DxScienceDataRequest)); dataRequest = static_cast<DxScienceDataRequest *>(bodybuff); dataRequest->demarshall(); dx_->dxScienceDataRequest(dataRequest); dx_->printScienceDataRequest(); break; case REQUEST_DX_STATUS: dx_->requestDxStatus(); break; case START_TIME: Assert(hdr->dataLength == sizeof(StartActivity)); startAct = static_cast<StartActivity *>(bodybuff); startAct->demarshall(); dx_->setStartTime(startAct); break; case BEGIN_SENDING_CANDIDATES: Assert(hdr->dataLength == sizeof(Count)); count = static_cast<Count *>(bodybuff); count->demarshall(); dx_->beginSendingCandidates(count); break; case SEND_CANDIDATE_CW_POWER_SIGNAL: Assert(hdr->dataLength == sizeof(CwPowerSignal)); cwPowerSignal = static_cast<CwPowerSignal *>(bodybuff); cwPowerSignal->demarshall(); dx_->sendCandidateCwPowerSignal(cwPowerSignal); break; case SEND_CANDIDATE_PULSE_SIGNAL: Assert(hdr->dataLength > 0); sendCandidatePulseSignalToDx(bodybuff); break; case DONE_SENDING_CANDIDATES: dx_->doneSendingCandidates(); break; case BEGIN_SENDING_FOLLOW_UP_SIGNALS: Assert(hdr->dataLength == sizeof(Count)); count = static_cast<Count *>(bodybuff); count->demarshall(); dx_->beginSendingFollowUpSignals(count); break; case SEND_FOLLOW_UP_CW_SIGNAL: Assert(hdr->dataLength == sizeof(FollowUpCwSignal)); followUpCwSignal = static_cast<FollowUpCwSignal *>(bodybuff); followUpCwSignal->demarshall(); dx_->sendFollowUpCwSignal(followUpCwSignal); break; case SEND_FOLLOW_UP_PULSE_SIGNAL: Assert(hdr->dataLength == sizeof(FollowUpPulseSignal)); followUpPulseSignal = static_cast<FollowUpPulseSignal *>(bodybuff); followUpPulseSignal->demarshall(); dx_->sendFollowUpPulseSignal(followUpPulseSignal); break; case DONE_SENDING_FOLLOW_UP_SIGNALS: dx_->doneSendingFollowUpSignals(); break; case BEGIN_SENDING_CW_COHERENT_SIGNALS: Assert(hdr->dataLength == sizeof(Count)); count = static_cast<Count *>(bodybuff); count->demarshall(); dx_->beginSendingCwCoherentSignals(count); break; case SEND_CW_COHERENT_SIGNAL: Assert(hdr->dataLength == sizeof(CwCoherentSignal)); cwCoherentSignal = static_cast<CwCoherentSignal *>(bodybuff); cwCoherentSignal->demarshall(); dx_->sendCwCoherentSignal(cwCoherentSignal); break; case DONE_SENDING_CW_COHERENT_SIGNALS: dx_->doneSendingCwCoherentSignals(); break; case REQUEST_ARCHIVE_DATA: Assert(hdr->dataLength == sizeof(ArchiveRequest)); archiveRequest = static_cast<ArchiveRequest *>(bodybuff); archiveRequest->demarshall(); dx_->requestArchiveData(archiveRequest); break; case DISCARD_ARCHIVE_DATA: Assert(hdr->dataLength == sizeof(ArchiveRequest)); archiveRequest = static_cast<ArchiveRequest *>(bodybuff); archiveRequest->demarshall(); dx_->discardArchiveData(archiveRequest); break; case STOP_DX_ACTIVITY: dx_->stopDxActivity(hdr->activityId); break; case SHUTDOWN_DX: dx_->shutdown(); break; case RESTART_DX: dx_->restart(); break; default: cout << "SseProxy::handleSseMsg: "; cout << "unexpected message code received:" << hdr->code << endl; break; }; }
/** * Record performance measures */ void record(uint time, const Model& model, double control = 1){ //uint year = IOSKJ::year(time); uint quarter = IOSKJ::quarter(time); times.append(); // Catch magnitude auto catch_total = model.catches_taken(sum); catches_total.append(catch_total); auto catches_by_method = model.catches_taken(sum,by(methods)); catches_ps.append(catches_by_method(PS)); catches_pl.append(catches_by_method(PL)); catches_gn.append(catches_by_method(GN)); // Years catch goes below baseline catches_lower.append(catch_total < 425000/4.0); // Catch variability if(quarter == 0 and catch_total>0){ catches_var.append(catch_total); catches_mapc.append(catch_total); } // Shutdown defined as quarterly catches <10% of recent average // catches of about 400000t catches_shut.append(catch_total<1000); // Changes in MP control e.g. catch or effort limit if (quarter == 0) { if (std::isfinite(control_last_)) { control_ups.append(control>control_last_); control_downs.append(control<control_last_); } control_last_ = control; } // Stock status relative to unfished auto status = model.biomass_status(); status_mean.append(status); status_b10.append(status<0.1); status_b20.append(status<0.2); // Biomass relative to B40 auto b = model.biomass_spawners(sum)/model.biomass_spawners_40; b_ratio.append(b); // F relative to F40 auto f = model.fishing_mortality_get()/model.f_40; f_ratio.append(f); // Kobe plot // Determine quadrant char quadrant; if(b>=1){ if(f<=1) quadrant = 'a'; else quadrant = 'b'; } else { if(f<=1) quadrant = 'c'; else quadrant = 'd'; } // Update performance measures for proportion of time spent in each quadrant kobe_a.append(quadrant=='a'); kobe_b.append(quadrant=='b'); kobe_c.append(quadrant=='c'); kobe_d.append(quadrant=='d'); // Update performance measure for time taken to get back into quadrant A if(quadrant=='a'){ // If previously outside of A then append the time that // have been outside to the mean and reset time counter to zero. if(kobe_out_a>0){ kobe_to_a.append(kobe_out_a); kobe_out_a = 0; } } else { // Outside of A so increment time counter. kobe_out_a++; } // Catch rates // Use vulnerable (i.e. selected) biomass for the three main regions/gears // relative to the start year as a measure of catch rates (CPUE) if(times==1){ // Record baselines for(auto region : regions){ for(auto method : methods){ cpue_baseline(region,method) = model.biomass_vulnerable(region,method); } } } else { // Record relative to baseline for(auto region : regions){ for(auto method : methods){ cpue_mean(region,method).append( model.biomass_vulnerable(region,method)/cpue_baseline(region,method) ); } } } }