Paragraph * ParIterator::operator->() const { return const_cast<Paragraph*>(&text()->getPar(pit())); }
/////////////////////////////////////////////////////////////////////////////// // TestFCOSetImpl -- FCOSetImpl component test harness /////////////////////////////////////////////////////////////////////////////// void TestFCOSetImpl() { cDebug d("TestFCOSetImpl()"); d.TraceDebug("Entering...\n"); iFCO* pFCO1 = new cFSObject(cFCOName(_T("fco1"))); iFCO* pFCO2 = new cFSObject(cFCOName(_T("fco2"))); iFCO* pFCO3 = new cFSObject(cFCOName(_T("fco3"))); cFCOSetImpl set; set.Insert(pFCO1); set.Insert(pFCO2); set.Insert(pFCO3); // the set should have AddRef()ed, so I can release these now. pFCO1->Release(); pFCO2->Release(); pFCO3->Release(); // let's iterate over the fcos cIterProxy<iFCOIter> pit(set.GetIter()); pit->SeekBegin(); PrintIter(pit, d); // lookup a specific fco cIterProxy<iFCOIter> pit2(set.Lookup(cFCOName(_T("fco2")))); if(! (iFCOIter*)pit2) { d.TraceError("Lookup failed for fco2!\n"); TEST(false); } d.TraceDebug("Iterating from fco2 to end...\n"); PrintIter(pit2, d); // Insert something d.TraceDebug("Inserting dog...\n"); pFCO1 = new cFSObject(cFCOName(_T("dog"))); set.Insert(pFCO1); pFCO1->Release(); pit->SeekBegin(); PrintIter(pit, d); // ...and then remove it d.TraceDebug("Removing fco3\n"); cIterProxy<iFCOIter> pit3(set.Lookup(cFCOName(_T("fco3")))); if(! (iFCOIter*)pit3) { d.TraceError("Lookup failed for fco3!\n"); TEST(false); } pit3->Remove(); pit3->SeekBegin(); PrintIter(pit3, d); // test operator= cFCOSetImpl set2; set2 = set; pit = set2.GetIter(); d.TraceDebug("Made a new set and set it equal to the first with operator=; printing out...\n"); PrintIter(pit, d); // test IsEmpty set.Clear(); TEST(set.IsEmpty()); // test refrence counting... d.TraceDebug("Set 1 was cleared out; printing set 2 to ensure ref counting worked\n"); pit->SeekBegin(); PrintIter(pit, d); // test serialization cFCOSetImpl set3; cMemoryArchive a; cSerializerImpl writeSer(a, cSerializerImpl::S_WRITE); writeSer.Init(); set2.Write(&writeSer); writeSer.Finit(); a.Seek(0, cBidirArchive::BEGINNING); cSerializerImpl readSer(a, cSerializerImpl::S_READ); readSer.Init(); set3.Read(&readSer); readSer.Finit(); d.TraceDebug("Serialized the set out and read it back in; this should be the same as above...\n"); pit = set3.GetIter(); PrintIter(pit, d); d.TraceDebug("Leaving...\n"); return; }
Paragraph const * ParConstIterator::operator->() const { return &text()->getPar(pit()); }
Paragraph & ParIterator::operator*() const { return const_cast<Paragraph&>(text()->getPar(pit())); }
bool EQPacketOPCodeDB::save(const QString& filename) { // create QFile object QFile file(filename); // open the file for write only if (!file.open(IO_WriteOnly)) return false; // create a QTextStream object on the QFile object QTextStream out(&file); // set the output encoding to be UTF8 out.setEncoding(QTextStream::UnicodeUTF8); // set the number output to be left justified decimal out.setf(QTextStream::dec | QTextStream::left); // print document header out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl << "<!DOCTYPE seqopcodes SYSTEM \"seqopcodes.dtd\">" << endl << "<seqopcodes>" << endl; // set initial indent QString indent = " "; EQPacketOPCode* currentOPCode; EQPacketPayload* currentPayload; typedef std::map<long, EQPacketOPCode*> OrderedMap; OrderedMap orderedOPCodes; // iterate over all the opcodes, inserting them into the ordered map QIntDictIterator<EQPacketOPCode> it(m_opcodes); while ((currentOPCode = it.current()) != NULL) { // insert into the ordered opcode map orderedOPCodes.insert(OrderedMap::value_type(currentOPCode->opcode(), currentOPCode)); // get next opcode ++it; } OrderedMap::iterator oit; QCString opcodeString(256); static const char* dirStrs[] = { "client", "server", "both", }; static const char* sztStrs[] = { "none", "match", "modulus", }; // iterate over the ordered opcode map for (oit = orderedOPCodes.begin(); oit != orderedOPCodes.end(); ++oit) { currentOPCode = oit->second; // output the current opcode opcodeString.sprintf("%04x", currentOPCode->opcode()); out << indent << "<opcode id=\"" << opcodeString << "\" name=\"" << currentOPCode->name() << "\""; if (currentOPCode->implicitLen()) out << " implicitlen=\"" << currentOPCode->implicitLen() << "\""; if (!currentOPCode->updated().isEmpty()) out << " updated=\"" << currentOPCode->updated() << "\""; out << ">" << endl; // increase the indent indent += " "; // output the comments QStringList comments = currentOPCode->comments(); for (QStringList::Iterator cit = comments.begin(); cit != comments.end(); ++cit) out << indent << "<comment>" << *cit << "</comment>" << endl; QCString dirStr; QCString sztStr; // iterate over the payloads QPtrListIterator<EQPacketPayload> pit(*currentOPCode); while ((currentPayload = pit.current()) != 0) { // output the payload out << indent << "<payload dir=\"" << dirStrs[currentPayload->dir()-1] << "\" typename=\"" << currentPayload->typeName() << "\" sizechecktype=\"" << sztStrs[currentPayload->sizeCheckType()] << "\"/>" << endl; ++pit; } // decrease the indent indent.remove(0, 4); // close the opcode entity out << indent << "</opcode>" << endl; } // output closing entity out << "</seqopcodes>" << endl; return true; }
Paragraph const & ParConstIterator::operator*() const { return text()->getPar(pit()); }
void zorba_state::zorba(machine_config &config) { // basic machine hardware Z80(config, m_maincpu, 24_MHz_XTAL / 6); m_maincpu->set_addrmap(AS_PROGRAM, &zorba_state::zorba_mem); m_maincpu->set_addrmap(AS_IO, &zorba_state::zorba_io); /* video hardware */ screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); screen.set_color(rgb_t::green()); screen.set_refresh_hz(50); screen.set_screen_update("crtc", FUNC(i8275_device::screen_update)); GFXDECODE(config, "gfxdecode", m_palette, gfx_zorba); PALETTE(config, m_palette, palette_device::MONOCHROME_HIGHLIGHT); /* sound hardware */ SPEAKER(config, "mono").front_center(); BEEP(config, m_beep, 800).add_route(ALL_OUTPUTS, "mono", 1.00); // should be horizontal frequency / 16, so depends on CRTC parameters INPUT_MERGER_ANY_HIGH(config, "irq0").output_handler().set(FUNC(zorba_state::irq_w<0>)); INPUT_MERGER_ANY_HIGH(config, "irq1").output_handler().set(FUNC(zorba_state::irq_w<1>)); INPUT_MERGER_ANY_HIGH(config, "irq2").output_handler().set(FUNC(zorba_state::irq_w<2>)); /* devices */ Z80DMA(config, m_dma, 24_MHz_XTAL / 6); // busack on cpu connects to bai pin m_dma->out_busreq_callback().set(FUNC(zorba_state::busreq_w)); //connects to busreq on cpu m_dma->out_int_callback().set("irq0", FUNC(input_merger_device::in_w<0>)); //ba0 - not connected m_dma->in_mreq_callback().set(FUNC(zorba_state::memory_read_byte)); m_dma->out_mreq_callback().set(FUNC(zorba_state::memory_write_byte)); m_dma->in_iorq_callback().set(FUNC(zorba_state::io_read_byte)); m_dma->out_iorq_callback().set(FUNC(zorba_state::io_write_byte)); I8251(config, m_uart0, 0); // U32 COM port J2 m_uart0->txd_handler().set("rs232", FUNC(rs232_port_device::write_txd)); // TODO: this line has a LED attached m_uart0->dtr_handler().set("rs232", FUNC(rs232_port_device::write_dtr)); m_uart0->rts_handler().set("rs232", FUNC(rs232_port_device::write_rts)); m_uart0->rxrdy_handler().set(FUNC(zorba_state::tx_rx_rdy_w<1>)); m_uart0->txrdy_handler().set(FUNC(zorba_state::tx_rx_rdy_w<0>)); I8251(config, m_uart1, 0); // U31 printer port J3 m_uart1->txd_handler().set("serprn", FUNC(rs232_port_device::write_txd)); m_uart1->rts_handler().set("serprn", FUNC(rs232_port_device::write_rts)); m_uart1->rxrdy_handler().set(FUNC(zorba_state::tx_rx_rdy_w<3>)); m_uart1->txrdy_handler().set(FUNC(zorba_state::tx_rx_rdy_w<2>)); I8251(config, m_uart2, 0); // U30 serial keyboard J6 m_uart2->txd_handler().set("keyboard", FUNC(zorba_keyboard_device::txd_w)); m_uart2->rxrdy_handler().set(FUNC(zorba_state::tx_rx_rdy_w<5>)); m_uart2->txrdy_handler().set(FUNC(zorba_state::tx_rx_rdy_w<4>)); // port A - disk select etc, beeper // port B - parallel interface PIA6821(config, m_pia0, 0); m_pia0->writepa_handler().set(FUNC(zorba_state::pia0_porta_w)); m_pia0->writepb_handler().set("parprndata", FUNC(output_latch_device::bus_w)); m_pia0->cb2_handler().set("parprn", FUNC(centronics_device::write_strobe)); // IEEE488 interface PIA6821(config, m_pia1, 0); m_pia1->readpa_handler().set(m_ieee, FUNC(ieee488_device::dio_r)); // TODO: gated with PB1 m_pia1->writepa_handler().set(m_ieee, FUNC(ieee488_device::host_dio_w)); // TODO: gated with PB1 m_pia1->readpb_handler().set(FUNC(zorba_state::pia1_portb_r)); m_pia1->writepb_handler().set(FUNC(zorba_state::pia1_portb_w)); m_pia1->ca2_handler().set(m_ieee, FUNC(ieee488_device::host_ifc_w)); m_pia1->cb2_handler().set(m_ieee, FUNC(ieee488_device::host_ren_w)); m_pia1->irqa_handler().set("irq1", FUNC(input_merger_device::in_w<0>)); m_pia1->irqb_handler().set("irq1", FUNC(input_merger_device::in_w<1>)); // PIT pit8254_device &pit(PIT8254(config, "pit", 0)); pit.set_clk<0>(24_MHz_XTAL / 3); pit.set_clk<1>(24_MHz_XTAL / 3); pit.set_clk<2>(24_MHz_XTAL / 3); pit.out_handler<0>().set(FUNC(zorba_state::br1_w)); pit.out_handler<1>().set(m_uart1, FUNC(i8251_device::write_txc)); pit.out_handler<1>().append(m_uart1, FUNC(i8251_device::write_rxc)); pit.out_handler<2>().set(m_uart2, FUNC(i8251_device::write_txc)); pit.out_handler<2>().append(m_uart2, FUNC(i8251_device::write_rxc)); // CRTC I8275(config, m_crtc, 14.318'181_MHz_XTAL / 7); m_crtc->set_character_width(8); m_crtc->set_display_callback(FUNC(zorba_state::zorba_update_chr), this); m_crtc->drq_wr_callback().set(m_dma, FUNC(z80dma_device::rdy_w)); m_crtc->irq_wr_callback().set("irq0", FUNC(input_merger_device::in_w<1>)); m_crtc->set_screen("screen"); // Floppies FD1793(config, m_fdc, 24_MHz_XTAL / 24); m_fdc->intrq_wr_callback().set("irq2", FUNC(input_merger_device::in_w<0>)); m_fdc->drq_wr_callback().set("irq2", FUNC(input_merger_device::in_w<1>)); FLOPPY_CONNECTOR(config, m_floppy0, zorba_floppies, "525dd", floppy_image_device::default_floppy_formats).enable_sound(true); FLOPPY_CONNECTOR(config, m_floppy1, zorba_floppies, "525dd", floppy_image_device::default_floppy_formats).enable_sound(true); // J1 IEEE-488 IEEE488(config, m_ieee); m_ieee->srq_callback().set(m_pia1, FUNC(pia6821_device::ca2_w)); // TODO: gated with PB1 from PIA // J2 EIA RS232/internal modem // TODO: this has additional lines compared to a regular RS232 port (TxC in, RxC in, RxC out, speaker in, power) rs232_port_device &rs232(RS232_PORT(config, "rs232", default_rs232_devices, nullptr)); rs232.rxd_handler().set(m_uart0, FUNC(i8251_device::write_rxd)); // TODO: this line has a LED attached rs232.cts_handler().set(m_uart0, FUNC(i8251_device::write_cts)); // TODO: this line has a LED attached rs232.dsr_handler().set(m_uart0, FUNC(i8251_device::write_dsr)); // J3 Parallel printer centronics_device &parprn(CENTRONICS(config, "parprn", centronics_devices, "printer")); parprn.busy_handler().set(m_uart1, FUNC(i8251_device::write_cts)); parprn.busy_handler().append(m_uart1, FUNC(i8251_device::write_dsr)); // TODO: shared with serial CTS parprn.fault_handler().set(FUNC(zorba_state::printer_fault_w)); parprn.select_handler().set(FUNC(zorba_state::printer_select_w)); output_latch_device &parprndata(OUTPUT_LATCH(config, "parprndata")); parprn.set_output_latch(parprndata); // J3 Serial printer rs232_port_device &serprn(RS232_PORT(config, "serprn", default_rs232_devices, nullptr)); serprn.rxd_handler().set(m_uart1, FUNC(i8251_device::write_rxd)); // TODO: this line has a LED attached // J6 TTL-level serial keyboard ZORBA_KEYBOARD(config, "keyboard").rxd_cb().set(m_uart2, FUNC(i8251_device::write_rxd)); SOFTWARE_LIST(config, "flop_list").set_original("zorba"); }
void trapfunc::sinkhole( Creature *c, const tripoint &p ) { player *pl = dynamic_cast<player*>( c ); if( pl == nullptr ) { // TODO: Handle monsters return; } const auto random_neighbor = []( tripoint center ) { center.x += rng( -1, 1 ); center.y += rng( -1, 1 ); return center; }; const auto safety_roll = [&]( const std::string &itemname, const int diff ) { const int roll = rng( pl->skillLevel( skill_throw ), pl->skillLevel( skill_throw ) + pl->str_cur + pl->dex_cur ); if( roll < diff ) { pl->add_msg_if_player( m_bad, _( "You fail to attach it..." ) ); pl->use_amount( itemname, 1 ); g->m.spawn_item( random_neighbor( pl->pos() ), itemname ); return false; } std::vector<tripoint> safe; tripoint tmp = pl->pos(); int &i = tmp.x; int &j = tmp.y; for( i = pl->posx() - 1; i <= pl->posx() + 1; i++ ) { for( j = pl->posy() - 1; j <= pl->posy() + 1; j++ ) { if( g->m.move_cost( tmp ) > 0 && g->m.tr_at( tmp ).loadid != tr_pit ) { safe.push_back( tmp ); } } } if( safe.empty() ) { pl->add_msg_if_player( m_bad, _( "There's nowhere to pull yourself to, and you sink!" ) ); pl->use_amount( itemname, 1 ); g->m.spawn_item( random_neighbor( pl->pos() ), itemname ); return false; } else { pl->add_msg_player_or_npc( m_good, _( "You pull yourself to safety!" ), _( "<npcname> steps on a sinkhole, but manages to pull themselves to safety." ) ); pl->setpos( random_entry( safe ) ); if( pl == &g->u ) { g->update_map( &g->u ); } return true; } }; pl->add_memorial_log( pgettext( "memorial_male", "Stepped into a sinkhole." ), pgettext( "memorial_female", "Stepped into a sinkhole." ) ); bool success = false; if( query_for_item( pl, "grapnel", _( "You step into a sinkhole! Throw your grappling hook out to try to catch something?" ) ) ) { success = safety_roll( "grapnel", 6 ); } else if( query_for_item( pl, "bullwhip", _( "You step into a sinkhole! Throw your whip out to try and snag something?" ) ) ) { success = safety_roll( "bullwhip", 8 ); } else if( query_for_item( pl, "rope_30", _( "You step into a sinkhole! Throw your rope out to try to catch something?" ) ) ) { success = safety_roll( "rope_30", 12 ); } pl->add_msg_player_or_npc( m_warning, _( "The sinkhole collapses!" ), _( "A sinkhole under <npcname> collapses!" ) ); g->m.remove_trap( p ); g->m.ter_set( p, t_pit ); if( success ) { return; } pl->moves -= 100; pl->add_msg_player_or_npc( m_bad, _( "You fall into the sinkhole!" ), _( "<npcname> falls into a sinkhole!" ) ); pit( c, p ); }
void EQPacketStream::dispatchPacket(const uint8_t* data, size_t len, uint16_t opCode, const EQPacketOPCode* opcodeEntry) { emit decodedPacket(data, len, m_dir, opCode, opcodeEntry); bool unknown = true; // unless there is an opcode entry, there is nothing to dispatch... if (opcodeEntry) { EQPacketPayload* payload; EQPacketDispatch* dispatch; #ifdef PACKET_INFO_DIAG seqDebug( "dispatchPacket: attempting to dispatch opcode %#04x '%s'", opcodeEntry->opcode(), (const char*)opcodeEntry->name()); #endif // iterate over the payloads in the opcode entry, and dispatch matches EQPayloadListIterator pit(*opcodeEntry); bool found = false; while ((payload = pit.current()) != 0) { // see if this packet matches if (payload->match(data, len, m_dir)) { found = true; unknown = false; // #ifdef PACKET_INFO_DIAG seqDebug( "\tmatched payload, find dispatcher in dict (%d/%d)", m_dispatchers.count(), m_dispatchers.size()); #endif // find the dispather for the payload dispatch = m_dispatchers.find((void*)payload); // if found, dispatch if (dispatch) { #ifdef PACKET_INFO_DIAG seqDebug("\tactivating signal..."); #endif dispatch->activate(data, len, m_dir); } } // go to next possible payload ++pit; } #ifdef PACKET_PAYLOAD_SIZE_DIAG if (!found && !opcodeEntry->isEmpty()) { QString tempStr; tempStr.sprintf("%s (%#04x) (dataLen: %u) doesn't match:", (const char*)opcodeEntry->name(), opcodeEntry->opcode(), len); for (payload = pit.toFirst(); payload != 0; payload = ++pit) { if (payload->dir() & m_dir) { if (payload->sizeCheckType() == SZC_Match) tempStr += QString(" sizeof(%1):%2") .arg(payload->typeName()).arg(payload->typeSize()); else if (payload->sizeCheckType() == SZC_Modulus) tempStr += QString(" modulus of sizeof(%1):%2") .arg(payload->typeName()).arg(payload->typeSize()); } } seqWarn(tempStr); } #endif // PACKET_PAYLOAD_SIZE_DIAG } #ifdef PACKET_INFO_DIAG else { seqWarn("dispatchPacket(): buffer size %d opcode %04x stream %s (%d) not in opcodeDB", len, opCode, EQStreamStr[m_streamid], m_streamid); } #endif emit decodedPacket(data, len, m_dir, opCode, opcodeEntry, unknown); }
//////////////////////////////////////////////////// // setup connection bool EQPacketStream::connect2(const QString& opcodeName, const char* payloadType, EQSizeCheckType szt, const QObject* receiver, const char* member) { const EQPacketOPCode* opcode = m_opcodeDB.find(opcodeName); if (!opcode) { seqDebug("connect2: Unknown opcode '%s' with payload type '%s'", (const char*)opcodeName, payloadType); seqDebug("\tfor receiver '%s' of type '%s' to member '%s'", receiver->name(), receiver->className(), member); return false; } EQPacketPayload* payload; // try to find a matching payload for this opcode EQPayloadListIterator pit(*opcode); while ((payload = pit.current()) != 0) { // if all the parameters match, then use this payload if ((payload->dir() & m_dir) && (payload->typeName() == payloadType) && (payload->sizeCheckType() == szt)) break; ++pit; } // if no payload found, create one and issue a warning if (!payload) { seqDebug("connect2: Warning! opcode '%s' has no matching payload.", (const char*)opcodeName); seqDebug("\tdir '%d' payload '%s' szt '%d'", m_dir, payloadType, szt); seqDebug("\tfor receiver '%s' of type '%s' to member '%s'", receiver->name(), receiver->className(), member); return false; } // attempt to find an existing dispatch EQPacketDispatch* dispatch = m_dispatchers.find((void*)payload); // if no existing dispatch was found, create one if (!dispatch) { // construct a name for the dispatch QCString dispatchName(256); dispatchName.sprintf("PacketDispatch:%s:%s:%d:%s:%d", (const char*)name(), (const char*)opcodeName, payload->dir(), (const char*)payload->typeName(), payload->sizeCheckType()); // create new dispatch object dispatch = new EQPacketDispatch(this, dispatchName); // insert dispatcher into dispatcher dictionary m_dispatchers.insert((void*)payload, dispatch); } // attempt to connect the dispatch object to the receiver return dispatch->connect(receiver, member); }
/****************************************************************************** * Function: main * * Description: * Set up a PIT server and handle network requests. This server * handles both TCP and UDP requests. * * Parameters: * The usual argc and argv parameters to a main() function. * * Return Value: * This is a daemon program and never returns. However, in the degenerate * case where no sockets are created, the function returns zero. ******************************************************************************/ int main( int argc, char *argv[ ] ) { int opt; int tSckt[ MAXTCPSCKTS ]; /* Array of TCP socket descriptors. */ size_t tScktSize = MAXTCPSCKTS; /* Size of uSckt (# of elements). */ int uSckt[ MAXUDPSCKTS ]; /* Array of UDP socket descriptors. */ size_t uScktSize = MAXUDPSCKTS; /* Size of uSckt (# of elements). */ strcpy(service_name,DFLT_SERVICE); /* ** Set the program name (w/o directory prefix). */ pgmName = strrchr( argv[ 0 ], '/' ); pgmName = pgmName == NULL ? argv[ 0 ] : pgmName + 1; /* ** Process command options. */ opterr = 0; /* Turns off "invalid option" error messages. */ while ( ( opt = getopt( argc, argv, VALIDOPTS ) ) >= 0 ) { switch ( opt ) { case 'v': /* Verbose mode. */ { verbose = true; break; } case 'p': /* Get the port number */ { strcpy(service_name,optarg); need++; break; } default: { USAGE; } } /* End SWITCH on command option. */ } /* End WHILE processing options. */ if(need < 1) { USAGE; exit; } /* ** Open both a TCP and UDP socket, for both IPv4 & IPv6, on which to receive ** service requests. */ if ( ( openSckt( service_name, "tcp", tSckt, &tScktSize ) < 0 ) || ( openSckt( service_name, "udp", uSckt, &uScktSize ) < 0 ) ) { exit( 1 ); } /* ** Run the Programmable Interdimensional Timer server. */ if ( ( tScktSize > 0 ) || ( uScktSize > 0 ) ) { pit( tSckt, /* pit() never returns. */ tScktSize, uSckt, uScktSize ); } /* ** Since pit() never returns, execution only gets here if no sockets were ** created. */ if ( verbose ) { fprintf( stderr, "%s: No sockets opened... terminating.\n", pgmName ); } return 0; } /* End main() */
bool JastrowBuilder::addThreeBody(xmlNodePtr cur) { if(sourceOpt == targetPtcl.getName()) { app_warning() << " Three-Body Jastrow Function needs a source different from " << targetPtcl.getName() << endl; app_warning() << " Exit JastrowBuilder::addOneBody." << endl; return false; } PtclPoolType::iterator pit(ptclPool.find(sourceOpt)); if(pit == ptclPool.end()) { app_error() << " JastrowBuilder::addThreeBody requires a center. " << sourceOpt << " is invalid " << endl; return false; } app_log() << " JastrowBuilder::addThreeBody source="<< sourceOpt << endl; xmlNodePtr basisPtr=NULL; xmlNodePtr coeffPtr=NULL; cur = cur->xmlChildrenNode; string diagOnly("no"); while(cur != NULL) { string cname((const char*)(cur->name)); if(cname == basisset_tag) { basisPtr=cur; } else if(cname.find("coeff")<cname.size()) { coeffPtr=cur; OhmmsAttributeSet oAttrib; oAttrib.add(diagOnly,"diagonal"); oAttrib.put(cur); } cur=cur->next; } if(basisPtr == NULL) { app_error() << " JastrowBuilder::addThreeBody exit. Missing <basisset/>"<< endl; return false; } ParticleSet* sourcePtcl=(*pit).second; JastrowBasisBuilder* basisBuilder = new JastrowBasisBuilder(targetPtcl,*sourcePtcl,funcOpt,transformOpt == "yes"); basisBuilder->put(basisPtr); if(diagOnly == "yes") { app_log() << "\n creating Three-Body Jastrow function using only diagnoal blocks." << endl; ThreeBodyBlockSparse* J3 = new ThreeBodyBlockSparse(*sourcePtcl, targetPtcl); J3->setBasisSet(basisBuilder->myBasisSet); J3->put(coeffPtr,targetPsi.VarList); J3->setBlocks(basisBuilder->SizeOfBasisPerCenter); targetPsi.addOrbital(J3); } else { app_log() << "\n creating Three-Body Jastrow function using a complete Geminal matrix." << endl; ThreeBodyGeminal* J3 = new ThreeBodyGeminal(*sourcePtcl, targetPtcl); J3->setBasisSet(basisBuilder->myBasisSet); J3->put(coeffPtr,targetPsi.VarList); targetPsi.addOrbital(J3); } //if(jbuilder) //{ // jbuilder->put(cur); // Children.push_back(jbuilder); // return true; //} // } else if (jasttype == "Three-Body-Pade") { // app_log() << "\n creating Three-Body-Pade Jastrow function " << endl; // string source_name("i"); // const xmlChar* iptr = xmlGetProp(cur, (const xmlChar *)"source"); // //if(iptr != NULL) source_name=(const char*)iptr; // PtclPoolType::iterator pit(ptclPool.find(source_name)); // if(pit != ptclPool.end()) { // jbuilder = new ThreeBodyPadeBuilder(*targetPtcl,*targetPsi,*((*pit).second)); // } // } return true; }
void InputPatchEditor::fillMappingTree() { QTreeWidgetItem* iitem = NULL; QTreeWidgetItem* pitem = NULL; QString pluginName; int i; /* Disable check state change tracking when the tree is filled */ disconnect(m_mapTree, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(slotMapItemChanged(QTreeWidgetItem*))); m_mapTree->clear(); /* Add an empty item so that user can choose not to assign any plugin to an input universe */ pitem = new QTreeWidgetItem(m_mapTree); pitem->setText(KMapColumnName, KInputNone); pitem->setText(KMapColumnInput, QString("%1").arg(KInputInvalid)); pitem->setFlags(pitem->flags() | Qt::ItemIsUserCheckable); /* Set "Nothing" selected if there is no valid input selected */ if (m_currentInput == KInputInvalid) pitem->setCheckState(KMapColumnName, Qt::Checked); else pitem->setCheckState(KMapColumnName, Qt::Unchecked); /* Go thru available plugins and put them as the tree's root nodes. */ QStringListIterator pit(_app->inputMap()->pluginNames()); while (pit.hasNext() == true) { i = 0; pluginName = pit.next(); pitem = new QTreeWidgetItem(m_mapTree); pitem->setText(KMapColumnName, pluginName); pitem->setText(KMapColumnInput, QString("%1") .arg(KInputInvalid)); /* Go thru available inputs provided by each plugin and put them as their parent plugin's leaf nodes. */ QStringListIterator iit( _app->inputMap()->pluginInputs(pluginName)); while (iit.hasNext() == true) { iitem = new QTreeWidgetItem(pitem); iitem->setText(KMapColumnName, iit.next()); iitem->setText(KMapColumnInput, QString("%1").arg(i)); iitem->setFlags(iitem->flags() | Qt::ItemIsUserCheckable); /* Select the currently mapped plugin input and expand its parent node. */ if (m_currentPluginName == pluginName && m_currentInput == i) { iitem->setCheckState(KMapColumnName, Qt::Checked); pitem->setExpanded(true); } else { int uni; iitem->setCheckState(KMapColumnName, Qt::Unchecked); uni = _app->inputMap()->mapping(pluginName, i); if (uni != -1) { /* If a mapping exists for this plugin and output, make it impossible to map it to another universe. */ iitem->setFlags(iitem->flags() & (!Qt::ItemIsEnabled)); iitem->setText(KMapColumnName, iitem->text(KMapColumnName) + QString(" (Mapped to universe %1)") .arg(uni + 1)); } } i++; } /* If no inputs were appended to the plugin node, put a "Nothing" node there. */ if (i == 0) { iitem = new QTreeWidgetItem(pitem); iitem->setText(KMapColumnName, KInputNone); iitem->setText(KMapColumnInput, QString("%1").arg(KInputInvalid)); iitem->setFlags(iitem->flags() & ~Qt::ItemIsEnabled); iitem->setFlags(iitem->flags() & ~Qt::ItemIsSelectable); iitem->setCheckState(KMapColumnName, Qt::Unchecked); } } /* Enable check state change tracking after the tree has been filled */ connect(m_mapTree, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(slotMapItemChanged(QTreeWidgetItem*))); }
///destructor LocalECPotential::~LocalECPotential() { map<int,RadialPotentialType*>::iterator pit(PPset.begin()), pit_end(PPset.end()); while(pit != pit_end) { delete (*pit).second; ++pit; } }
bool CppEditorCompletion::doObjectCompletion( const QString &objName ) { if ( !ths ) return FALSE; QString object( objName ); int i = -1; if ( ( i = object.findRev( "->" ) ) != -1 ) object = object.mid( i + 2 ); if ( ( i = object.findRev( "." ) ) != -1 ) object = object.mid( i + 1 ); object = object.simplifyWhiteSpace(); QObject *obj = 0; if ( ths->name() == object || object == "this" ) { obj = ths; } else { obj = ths->child( object ); } if ( !obj ) return FALSE; QValueList<CompletionEntry> lst; if ( obj->children() ) { for ( QObjectListIt cit( *obj->children() ); cit.current(); ++cit ) { QString s( cit.current()->name() ); if ( s.find( " " ) == -1 && s.find( "qt_" ) == -1 && s.find( "unnamed" ) == -1 ) { CompletionEntry c; c.type = "variable"; c.text = s; c.prefix = ""; lst << c; } } } QStrList props = obj->metaObject()->propertyNames( TRUE ); for ( QPtrListIterator<char> pit( props ); pit.current(); ++pit ) { QString f( pit.current() ); QChar c = f[ 0 ]; f.remove( (uint)0, 1 ); f.prepend( c.upper() ); f.prepend( "set" ); CompletionEntry ce; ce.type = "property"; ce.text = f; ce.postfix = "()"; if ( lst.find( ce ) == lst.end() ) lst << ce; } QStrList slts = obj->metaObject()->slotNames( TRUE ); for ( QPtrListIterator<char> sit( slts ); sit.current(); ++sit ) { QString f( sit.current() ); f = f.left( f.find( "(" ) ); CompletionEntry c; c.type = "slot"; c.text = f; c.postfix = "()"; if ( lst.find( c ) == lst.end() ) lst << c; } if ( lst.isEmpty() ) return FALSE; showCompletion( lst ); return TRUE; }