Exemple #1
0
  std::vector<MetaObject::CompatibleMethod> MetaObjectPrivate::findCompatibleMethod(const std::string &nameOrSignature)
  {
    boost::recursive_mutex::scoped_lock sl(_methodsMutex);
    std::vector<MetaObject::CompatibleMethod>         ret;
    std::string cname(nameOrSignature);

    //no signature specified fallback on findMethod
    if (cname.find(':') == std::string::npos)
    {
      std::vector<MetaMethod> r = findMethod(cname);
      ret.reserve(r.size());
      for (unsigned i=0; i<r.size(); ++i)
        ret.push_back(std::make_pair(r[i], 1.0f));
      return ret;
    }

    std::vector<std::string> sigsorig = qi::signatureSplit(nameOrSignature);
    if (sigsorig[1].empty())
      return ret;

    Signature sresolved(sigsorig[2]);

    for (auto& method: _methods) {
      const qi::MetaMethod& mm = method.second;

      if (sigsorig[1] != mm.name())
        continue;
      float score = sresolved.isConvertibleTo(Signature(mm.parametersSignature()));
      if (score)
        ret.push_back(std::make_pair(mm, score));
    }
    return ret;
  }
bool OrbitalConstraintsBase::getVariables(xmlNodePtr cur)
{
  xmlChar* prnode=xmlGetProp(cur,(const xmlChar*)"print");
  if(prnode != NULL)
  {
    PrintTables = xmlStrEqual(prnode,(const xmlChar*)"yes");
  }
  //save the xml node
  myNode=cur;
  cur = cur->children;
  while(cur != NULL)
  {
    string cname((const char*)(cur->name));
    if(cname == "correlation")
    {
      xmlNodePtr cur1=cur->children;
      while(cur1 != NULL)
      {
        string cname1((const char*)(cur1->name));
        if(cname1 == "parameter")
        {
          getParam(cur1);
        }
        cur1=cur1->next;
      }
    }
    else
      if(cname == "parameter")
      {
        getParam(cur);
      }
    cur = cur->next;
  } // while cur
  return true;
}
Exemple #3
0
int main(int argc, char **argv)
{
    int reti;
    uint16_t vid;
    struct vol *vol;
    struct dir *retdir;
    struct path *path;

    /* initialize */
    printf("Initializing\n============\n");
    TEST(setuplog("default:note","/dev/tty"));

    TEST( afp_options_parse_cmdline(&obj, 3, &args[0]) );

    TEST_int( afp_config_parse(&obj, NULL), 0);
    TEST_int( configinit(&obj), 0);
    TEST( cnid_init() );
    TEST( load_volumes(&obj, NULL) );
    TEST_int( dircache_init(8192), 0);
    obj.afp_version = 32;

    printf("\n");

    /* now run tests */
    printf("Running tests\n=============\n");

    TEST_expr(vid = openvol(&obj, "test"), vid != 0);
    TEST_expr(vol = getvolbyvid(vid), vol != NULL);

    /* test directory.c stuff */
    TEST_expr(retdir = dirlookup(vol, DIRDID_ROOT_PARENT), retdir != NULL);
    TEST_expr(retdir = dirlookup(vol, DIRDID_ROOT), retdir != NULL);
    TEST_expr(path = cname(vol, retdir, cnamewrap("Network Trash Folder")), path != NULL);

    TEST_expr(retdir = dirlookup(vol, DIRDID_ROOT), retdir != NULL);
    TEST_int(getfiledirparms(&obj, vid, DIRDID_ROOT_PARENT, "test"), 0);
    TEST_int(getfiledirparms(&obj, vid, DIRDID_ROOT, ""), 0);

    TEST_expr(reti = createdir(&obj, vid, DIRDID_ROOT, "dir1"),
              reti == 0 || reti == AFPERR_EXIST);

    TEST_int(getfiledirparms(&obj, vid, DIRDID_ROOT, "dir1"), 0);
/*
  FIXME: this doesn't work although it should. "//" get translated to \000 \000 at means ".."
  ie this should getfiledirparms for DIRDID_ROOT_PARENT -- at least afair!
    TEST_int(getfiledirparms(&configs->obj, vid, DIRDID_ROOT, "//"), 0);
*/
    TEST_int(createfile(&obj, vid, DIRDID_ROOT, "dir1/file1"), 0);
    TEST_int(delete(&obj, vid, DIRDID_ROOT, "dir1/file1"), 0);
    TEST_int(delete(&obj, vid, DIRDID_ROOT, "dir1"), 0);

    TEST_int(createfile(&obj, vid, DIRDID_ROOT, "file1"), 0);
    TEST_int(getfiledirparms(&obj, vid, DIRDID_ROOT, "file1"), 0);
    TEST_int(delete(&obj, vid, DIRDID_ROOT, "file1"), 0);


    /* test enumerate.c stuff */
    TEST_int(enumerate(&obj, vid, DIRDID_ROOT), 0);
}
// A helper function to create a color name acceptable in DXF files
// DXF files do not use a RGB definition
static wxString getDXFColorName( COLOR4D aColor )
{
    EDA_COLOR_T color = ColorFindNearest( int( aColor.r*255 ),
                                          int( aColor.g*255 ),
                                          int( aColor.b*255 ) );
    wxString cname( dxf_layer[color].name );
    return cname;
}
Exemple #5
0
void
pln_newlanding(struct emp_qelem *list, coord tx, coord ty, int cno)
{
    struct emp_qelem *qp;
    struct plist *plp;
    struct shpstr ship;
    struct sctstr sect;

    if (cno >= 0)
	getship(cno, &ship);
    for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
	plp = (struct plist *)qp;
	if (cno >= 0) {
	    if (!could_be_on_ship(&plp->plane, &ship))
		pr("\t%s cannot land on ship #%d! %s aborts!\n",
		   prplane(&plp->plane), cno, prplane(&plp->plane));
	    else if (!put_plane_on_ship(&plp->plane, &ship))
		pr("\tNo room on ship #%d! %s aborts!\n",
		   cno, prplane(&plp->plane));
	    else {
		if (plp->plane.pln_own != ship.shp_own) {
		    wu(0, ship.shp_own, "%s %s lands on your %s\n",
		       cname(player->cnum), prplane(&plp->plane),
		       prship(&ship));
		}
		if (plp->pcp->pl_crew && plp->pstage == PLG_INFECT
		    && ship.shp_pstage == PLG_HEALTHY)
		    ship.shp_pstage = PLG_EXPOSED;
	    }
	} else {
	    plp->plane.pln_x = tx;
	    plp->plane.pln_y = ty;
	    getsect(tx, ty, &sect);
	    if (plp->plane.pln_own != sect.sct_own) {
		wu(0, sect.sct_own,
		   "%s %s lands at your sector %s\n",
		   cname(player->cnum),
		   prplane(&plp->plane), xyas(tx, ty, sect.sct_own));
	    }
	    if (plp->pcp->pl_crew && plp->pstage == PLG_INFECT
		&& sect.sct_pstage == PLG_HEALTHY)
		sect.sct_pstage = PLG_EXPOSED;
	    plp->plane.pln_ship = cno;
	}
    }
}
CIMValue CIMHelper::getPropertyValue(const CIMInstance &instanceObject, String name)
{
    CIMName cname(name);
    Uint32 index = instanceObject.findProperty(cname);
    if (index == PEG_NOT_FOUND) return CIMValue();
    CIMConstProperty property = instanceObject.getProperty(index);
    return property.getValue();
}
Exemple #7
0
/*
 * Accept a loan.  If the offering country has too little money,
 * leave him $100 left and offer the rest.  Return RET_OK on
 * success, anything else on error.
 */
static int
loan_accept(struct ltcomstr *ltcp)
{
    struct lonstr *lp;
    struct natstr *lender;
    struct nstr_item nstr;
    struct lonstr loan;

    lp = &ltcp->u.l;
    if (ltcp->proposee != player->cnum) {
	pr("%s %d is still pending.\n", ltcp->Name, ltcp->num);
	return RET_OK;
    }
    if (!getloan(ltcp->num, lp)) {
	logerror("loan_accept: can't read loan");
	pr("can't read loan; get help!\n");
	return RET_FAIL;
    }
    if (lp->l_status == LS_FREE) {	/* other guy retratcted already */
	late(ltcp);
	return RET_OK;
    }
    if (lp->l_status == LS_SIGNED) {	/* already signed somehow */
	prev_signed(ltcp);
	return RET_OK;
    }
    /* check to see if a loan already exists */
    snxtitem_all(&nstr, EF_LOAN);
    while (nxtitem(&nstr, &loan)) {
	if (loan.l_status == LS_SIGNED && loan.l_lonee == lp->l_loner
	    && (loan.l_loner == lp->l_lonee)) {
	    pr("He already owes you money - make him repay his loan!\n");
	    return RET_OK;
	}
    }
    lender = getnatp(ltcp->proposer);
    if (lender->nat_money < lp->l_amtdue) {	/* other guy is poor */
	lp->l_amtdue = lender->nat_money - 100;
	pr("%s no longer has the funds.\n", cname(ltcp->proposer));
	if (lp->l_amtdue <= 0)
	    return RET_FAIL;
	pr("You may borrow $%d at the same terms.\n", lp->l_amtdue);
    }
    lender->nat_money -= lp->l_amtdue;
    putnat(lender);
    player->dolcost -= lp->l_amtdue;
    lp->l_amtpaid = 0;
    (void)time(&lp->l_lastpay);
    lp->l_duedate = lp->l_ldur * SECS_PER_DAY + lp->l_lastpay;
    lp->l_status = LS_SIGNED;
    if (!putloan(ltcp->num, lp)) {
	pr("Problem writing lp->to disk; get help!\n");
	return RET_FAIL;
    }
    accpt(ltcp);
    pr("You are now $%d richer (sort of).\n", lp->l_amtdue);
    return RET_OK;
}
Exemple #8
0
//! reads checks info from database
void Table::loadCheckConstraints()
{
    if (checkConstraintsLoadedM)
        return;
    checkConstraintsM.clear();

    DatabasePtr db = getDatabase();
    wxMBConv* conv = db->getCharsetConverter();
    MetadataLoader* loader = db->getMetadataLoader();
    // first start a transaction for metadata loading, then lock the table
    // when objects go out of scope and are destroyed, table will be unlocked
    // before the transaction is committed - any update() calls on observers
    // can possibly use the same transaction
    MetadataLoaderTransaction tr(loader);
    SubjectLocker lock(this);

    IBPP::Statement& st1 = loader->getStatement(
        "select r.rdb$constraint_name, t.rdb$trigger_source, d.rdb$field_name "
        " from rdb$relation_constraints r "
        " join rdb$check_constraints c on r.rdb$constraint_name=c.rdb$constraint_name and r.rdb$constraint_type = 'CHECK'"
        " join rdb$triggers t on c.rdb$trigger_name=t.rdb$trigger_name and t.rdb$trigger_type = 1 "
        " left join rdb$dependencies d on t.rdb$trigger_name = d.rdb$dependent_name "
        "      and d.rdb$depended_on_name = r.rdb$relation_name "
        "      and d.rdb$depended_on_type = 0 "
        " where r.rdb$relation_name=? "
        " order by 1 "
    );

    st1->Set(1, wx2std(getName_(), conv));
    st1->Execute();
    CheckConstraint *cc = 0;
    while (st1->Fetch())
    {
        std::string s;
        st1->Get(1, s);
        wxString cname(std2wxIdentifier(s, conv));
        if (!cc || cname != cc->getName_()) // new constraint
        {
            wxString source;
            readBlob(st1, 2, source, conv);

            CheckConstraint c;
            c.setParent(this);
            c.setName_(cname);
            c.sourceM = source;
            checkConstraintsM.push_back(c);
            cc = &checkConstraintsM.back();
        }

        if (!st1->IsNull(3))
        {
            st1->Get(3, s);
            wxString fname(std2wxIdentifier(s, conv));
            cc->columnsM.push_back(fname);
        }
    }
    checkConstraintsLoadedM = true;
}
Exemple #9
0
void Settings::SetColor(const char *name, const rgb_color color)
{
	BString cname(name); cname.Append(COLOR);
	ssize_t bytes = sizeof(rgb_color);
	if (!pref.HasData(cname.String(), B_RGB_COLOR_TYPE)) 
		pref.AddData(cname.String(),  B_RGB_COLOR_TYPE, &color, bytes);
	else 
		pref.ReplaceData(cname.String(), B_RGB_COLOR_TYPE, &color, bytes);
}
Exemple #10
0
void
report_god_takes(char *prefix, char *what, natid from)
{
    if (from && from != player->cnum) {
	wu(0, from, "%s%s taken from you by an act of %s!\n",
	   prefix, what, cname(player->cnum));
	nreport_divine_aid(from, -1);
    }
}
Exemple #11
0
static int
cons_postpone(struct ltcomstr *ltcp)
{
    pr("%s %d is still pending.\n", ltcp->Name, ltcp->num);
    if (ltcp->proposee == player->cnum)
	wu(0, ltcp->proposer, "%s %d considered by %s\n",
	   ltcp->name, ltcp->num, cname(player->cnum));
    return RET_OK;
}
Exemple #12
0
void
report_god_gives(char *prefix, char *what, natid to)
{
    if (to && to != player->cnum) {
	wu(0, to, "%s%s given to you by an act of %s!\n",
	   prefix, what, cname(player->cnum));
	nreport_divine_aid(to, 1);
    }
}
void
QvisSubsetPanelWidget::ViewCollection(int id)
{
    avtSILRestriction_p restriction = viewerProxy->GetPlotSILRestriction();
    avtSILCollection_p collection = restriction->GetSILCollection(id);
    numCheckable = 0;
    numChecked = 0;
    tree->clear();

    if(*collection != NULL)
    {
        tree->setEnabled(true);
        blockSignals(true);
          
        SetTitle(collection->GetCategory().c_str());
        const avtSILNamespace *ns = collection->GetSubsets();
        int numElems = ns->GetNumberOfElements();

        avtSILRestrictionTraverser trav(restriction);
        for(int i = 0; i < numElems; ++i)
        {
            int setIdx = ns->GetElement(i);
            avtSILSet_p set = restriction->GetSILSet(setIdx);

            // Create an item for the set and set its checked value.
            CheckedState s = S2S(trav.UsesSetData(setIdx));
            QString cname(set->GetName().c_str());
            QvisSubsetPanelItem *item = new QvisSubsetPanelItem(tree,
                                                                cname,
                                                                s,
                                                                setIdx);
            numCheckable++;

            if(s == CompletelyChecked)
                numChecked++;
            
            // Add all of the collections that come out of the set. Note that
            // they are added as uncheckable items.
            QvisSubsetPanelItem *cItem = NULL;
            const std::vector<int> &mapsOut = set->GetMapsOut();
            for(size_t j = 0; j < mapsOut.size(); ++j)
            {
                int cIndex = mapsOut[j];

                avtSILCollection_p c = restriction->GetSILCollection(cIndex);
                QString collectionName(c->GetCategory().c_str());
                cItem = new QvisSubsetPanelItem(item,
                                                collectionName,
                                                cIndex);
            }
        }
        blockSignals(false);
    }
    EnableButtons(true);
    
    
}
/* helpers */
static PyObject *
repo_enabled(_SackObject *self, PyObject *reponame, int enabled)
{
    PycompString cname(reponame);
    if (!cname.getCString())
        return NULL;
    dnf_sack_repo_enabled(self->sack, cname.getCString(), enabled);
    Py_RETURN_NONE;
}
  bool AGPDeterminantBuilder::createAGP(BasisBuilderT *abuilder, xmlNodePtr cur) {
    bool spinpolarized=false;
    typename BasisBuilderT::BasisSetType *basisSet=0;
    cur = cur->xmlChildrenNode;
    while(cur != NULL) {
      string cname((const char*)(cur->name));
      if(cname == basisset_tag) {
        basisSet = abuilder->addBasisSet(cur);
        if(!basisSet) return false;
      } else if(cname == "coefficient" || cname == "coefficients") {
        if(agpDet == 0) {
          int nup=targetPtcl.first(1), ndown=0;
          if(targetPtcl.groups()>1) ndown = targetPtcl.first(2)-nup;
          basisSet->resize(nup+ndown);
          agpDet = new AGPDeterminant(basisSet);
          agpDet->resize(nup,ndown);
        }
        int offset=1;
        xmlNodePtr tcur=cur->xmlChildrenNode;
        while(tcur != NULL) {
          if(xmlStrEqual(tcur->name,(const xmlChar*)"lambda")) {
            int i=atoi((const char*)(xmlGetProp(tcur,(const xmlChar*)"i")));
            int j=atoi((const char*)(xmlGetProp(tcur,(const xmlChar*)"j")));
            double c=atof((const char*)(xmlGetProp(tcur,(const xmlChar*)"c")));
            agpDet->Lambda(i-offset,j-offset)=c;
            if(i != j) {
              agpDet->Lambda(j-offset,i-offset)=c;
            }
          }
          tcur=tcur->next;
        }
      } else if(cname == "unpaired") {
        spinpolarized=true;
        int offset=1;
        xmlNodePtr tcur=cur->xmlChildrenNode;
        while(tcur != NULL) {
          if(xmlStrEqual(tcur->name,(const xmlChar*)"lambda")) {
            int i=atoi((const char*)(xmlGetProp(tcur,(const xmlChar*)"i")));
            int j=atoi((const char*)(xmlGetProp(tcur,(const xmlChar*)"j")));
            double c=atof((const char*)(xmlGetProp(tcur,(const xmlChar*)"c")));
            agpDet->LambdaUP(j-offset,i-offset)=c;
          }
          tcur=tcur->next;
        }

      }
      cur=cur->next;
    }

    //app_log() << agpDet->Lambda << endl;
    if(spinpolarized) {
      app_log() << "  Coefficients for the unpaired electrons " << endl;
      app_log() << agpDet->LambdaUP << endl;
    }
    return true;
  }
  void ECPotentialBuilder::useXmlFormat(xmlNodePtr cur) {

    cur=cur->children;
    while(cur != NULL) {
      string cname((const char*)cur->name);
      if(cname == "pseudo") {
        string href("none");
        string ionName("none");
        string format("xml");
        //RealType rc(2.0);//use 2 Bohr
        OhmmsAttributeSet hAttrib;
        hAttrib.add(href,"href");
        hAttrib.add(ionName,"elementType"); hAttrib.add(ionName,"symbol");
        hAttrib.add(format,"format");
        //hAttrib.add(rc,"cutoff");
        hAttrib.put(cur);

        int speciesIndex=IonConfig.getSpeciesSet().findSpecies(ionName);
        if(speciesIndex < IonConfig.getSpeciesSet().getTotalNum()) {
          app_log() << endl << "  Adding pseudopotential for " << ionName << endl;
          ECPComponentBuilder ecp(ionName);
          bool success=false;
          if(format == "xml") {
            if(href == "none") {
              success=ecp.put(cur);
            } else {
              success=ecp.parse(href,cur);
            }
          } 
          else if(format == "casino")
          {
            //success=ecp.parseCasino(href,rc);
            success=ecp.parseCasino(href,cur);
          }

          if(success) {
#if !defined(HAVE_MPI)
            ecp.printECPTable();
#endif
            if(ecp.pp_loc) {
              localPot[speciesIndex]=ecp.pp_loc;
              localZeff[speciesIndex]=ecp.Zeff;
              hasLocalPot=true;
            }
            if(ecp.pp_nonloc) {
              nonLocalPot[speciesIndex]=ecp.pp_nonloc;
              hasNonLocalPot=true;
            }
          }
        } else {
          app_error() << "  Ion species " << ionName << " is not found." << endl;
        }
      } 
      cur=cur->next;
    }
  }
Exemple #17
0
//--- Print all created canvasses ---
void printAllCanvases(const char* folder="plots")
{
   TSeqCollection * sc = dynamic_cast<TSeqCollection*>(gROOT->GetListOfCanvases());
   for (int i =0; i<sc->GetSize(); ++i) {
      TCanvas * c = dynamic_cast<TCanvas*>(sc->At(i));
      TString cname(c->GetName());
      printf("Canvas: %s/%s.gif\n",folder,cname.Data());
      c->Print(Form("%s/%s.gif",folder,cname.Data()));
   }
}
Exemple #18
0
static void
preport(struct nwsstr *np)
{
    char *cp;
    int i;
    char buf[255];
    char num[128];
    char *ptr;

    cp = buf;
    sprintf(buf, "%-16.16s  ", ctime(&np->nws_when));
    cp += strlen(cp);
    ptr = numstr(num, np->nws_ntm);
    /*
     * vary the order of the printing of "%d times "
     */
    if (roll0(4) == 0 && np->nws_ntm > 1) {
	sprintf(cp, "%s times ", ptr);
	cp += strlen(cp);
	np->nws_ntm = 1;
    }
    strcpy(cp, cname(np->nws_ano));
    cp += strlen(cp);
    *cp++ = ' ';
    sprintf(cp, rpt[(int)np->nws_vrb].r_newstory[roll0(NUM_RPTS)],
	    cname(np->nws_vno));
    cp += strlen(cp);
    if (np->nws_ntm != 1) {
	sprintf(cp, " %s times", ptr);
	cp += strlen(cp);
    }
    if (cp - buf > 80) {
	for (i = 80; --i > 60;)
	    if (buf[i] == ' ')
		break;
	buf[i] = '\0';
	pr("%s\n\t\t  %s\n", buf, &buf[i + 1]);
    } else {
	pr("%s\n", buf);
    }
    np->nws_ntm = 0;
    return;
}
Exemple #19
0
rgb_color Settings::GetColor(const char *name)
{	
	BString cname(name); cname.Append(COLOR);
	rgb_color *color;
	ssize_t bytes = sizeof(rgb_color);	
	if (pref.FindData(cname.String(), B_RGB_COLOR_TYPE, (const void **)&color, &bytes) == B_OK)
		return (*color);
	else
		return (BeBackgroundGrey);
}
    void JastrowBasisBuilder::createLocalizedBasisSet(xmlNodePtr cur)
  {

    typedef typename RFBUILDER::CenteredOrbitalType COT;
    typedef LocalizedBasisSet<COT> ThisBasisSetType;
    ThisBasisSetType* curBasis= new ThisBasisSetType(sourcePtcl,targetPtcl);

    //create the basis set
    //go thru the tree
    cur = cur->xmlChildrenNode;
    while(cur!=NULL) {
      string cname((const char*)(cur->name));
      if(cname == "atomicBasisSet") {
        const xmlChar* eptr=xmlGetProp(cur,(const xmlChar*)"elementType");
        if(eptr == NULL) {
          app_error() << "   Missing elementType attribute of atomicBasisSet.\n Abort at MOBasisBuilder::put " << endl;
          OHMMS::Controller->abort();
        }

        string elementType((const char*)eptr);
        map<string,BasisSetBuilder*>::iterator it = aoBuilders.find(elementType); 
        if(it == aoBuilders.end()) {
          AtomicBasisBuilder<RFBUILDER>* any = new AtomicBasisBuilder<RFBUILDER>(elementType);
          any->put(cur);
          COT* aoBasis= any->createAOSet(cur);

          if(aoBasis) { //add the new atomic basis to the basis set
            int activeCenter =sourcePtcl.getSpeciesSet().findSpecies(elementType);
            curBasis->add(activeCenter, aoBasis);
            aoBuilders[elementType]=any;

#if !defined(HAVE_MPI)
            string fname(elementType);
            fname.append(".j3.dat");
            ofstream fout(fname.c_str());
            int nr=aoBasis->Rnl.size();
            double r=0.0;
            while(r<20)
            {
              fout << r ;
              for(int i=0; i<nr; i++) fout << " " << aoBasis->Rnl[i]->evaluate(r,1.0/r);
              fout << endl;
              r += 0.013;
            }
#endif
          }
        }
      }
      cur = cur->next;
    }

    //resize the basis set
    curBasis->setBasisSetSize(-1);
    myBasisSet=curBasis;
  }
Exemple #21
0
  /** create Input Analytic function
   *
   * \xmlonly
   * <jastrow name="Jne" 
   *   type="Two-Body|One-Body|Polarization|Three-Body-Geminal"
   *   function="pade|pade2|no-cusp" 
   *   transform="no|yes" spin="no|yes" 
   *   source="ionic system">
   *   <grid/>
   *   <correlation speciesA="sourceSpecies" speciesB="targetSpecies" type="pade|pade2|no-cusp">
   *      <parameter name=" ">value<parameter>
   *   </correlation>
   * </jastrow>
   * \endxmlonly
   */
  bool NJABBuilder::putInFunc(xmlNodePtr cur) {

    string corr_tag("correlation");
    string jastfunction("pade");
    int	ng=1;

    const xmlChar *ftype = xmlGetProp(cur, (const xmlChar *)"function");
    if(ftype != NULL) jastfunction = (const char*) ftype;
    const xmlChar* s=xmlGetProp(cur,(const xmlChar*)"source");
    if(s != NULL) {
      map<string,ParticleSet*>::iterator pa_it(ptclPool.find((const char*)s));
      if(pa_it == ptclPool.end()) return false;
      sourcePtcl = (*pa_it).second;
      ng=sourcePtcl->getSpeciesSet().getTotalNum();
    }

    int ia=0, ib=0, iab=0;
    cur = cur->children;
    while(cur != NULL) {
      string cname((const char*)(cur->name));
      if(cname == "grid") {
        gridPtr=cur; //save the pointer
      } else if(cname == dtable_tag) {
      	string source_name((const char*)(xmlGetProp(cur,(const xmlChar *)"source")));
        map<string,ParticleSet*>::iterator pa_it(ptclPool.find(source_name));
        if(pa_it == ptclPool.end()) return false;
	sourcePtcl=(*pa_it).second;
	ng = sourcePtcl->getSpeciesSet().getTotalNum();
	XMLReport("Number of sources " << ng)
        InFunc.resize(ng,0);
      } else if(cname ==corr_tag) {
        if(sourcePtcl==0) return false;
        string jfunctype(jastfunction);
	string spA((const char*)(xmlGetProp(cur,(const xmlChar *)"speciesA")));
        ftype = xmlGetProp(cur, (const xmlChar *)"type");
        if(ftype) {
          jfunctype=(const char*)ftype;
        }

        ia = sourcePtcl->getSpeciesSet().findSpecies(spA);
	if(!(InFunc[ia])) {
          InFuncType *j1=createInFunc(jfunctype);
	  InFunc[ia]= j1;
	  app_log() <<"   Added Jastrow Correlation ("<<jfunctype 
            << ") between " <<spA<<" and "<<targetPtcl.getName() << endl;
	}
	InFunc[ia]->put(cur);
        InFunc[ia]->addOptimizables(targetPsi.VarList);
      }
      cur = cur->next;
    } // while cur
    
    return true;
  }
  /** This should be moved to branch engine */
  bool EstimatorManager::put(MCWalkerConfiguration& W, QMCHamiltonian& H, xmlNodePtr cur) 
  {
    vector<string> extra;
    cur = cur->children;
    while(cur != NULL) 
    {
      string cname((const char*)(cur->name));
      if(cname == "estimator") 
      {
        xmlChar* att=xmlGetProp(cur,(const xmlChar*)"name");
        if(att) 
        {
          string aname((const char*)att);
          if(aname == "LocalEnergy") 
            add(new LocalEnergyEstimator(H),MainEstimatorName);
          else 
            extra.push_back(aname);
        }
      } 
      cur = cur->next;
    }

    if(Estimators.empty()) 
    {
      app_log() << "  Using a default LocalEnergyOnlyEstimator for the MainEstimator " << endl;
      add(new LocalEnergyOnlyEstimator(),MainEstimatorName);
    } 

    string SkName("sk");
    string GofRName("gofr");
    for(int i=0; i< extra.size(); i++)
    {
      if(extra[i] == SkName && W.Lattice.SuperCellEnum)
      {
        if(CompEstimators == 0) CompEstimators = new CompositeEstimatorSet;
        if(CompEstimators->missing(SkName))
        {
          app_log() << "  EstimatorManager::add " << SkName << endl;
          CompEstimators->add(new SkEstimator(W),SkName);
        }
      } else if(extra[i] == GofRName)
      {
        if(CompEstimators == 0) CompEstimators = new CompositeEstimatorSet;
        if(CompEstimators->missing(GofRName))
        {
          app_log() << "  EstimatorManager::add " << GofRName << endl;
          CompEstimators->add(new GofREstimator(W),GofRName);
        }
      }
    }
    //add extra
    return true;
  }
Exemple #23
0
int
disloan(int n, struct lonstr *loan)
{
    time_t now;
    time_t accept;

    if (loan->l_status == LS_FREE)
	return 0;
    if (loan->l_ldur == 0)
	return 0;
    if (loan->l_loner != player->cnum && loan->l_lonee != player->cnum)
	return 0;
    (void)time(&now);
    pr("\nLoan #%d from %s to", n, cname(loan->l_loner));
    pr(" %s\n", cname(loan->l_lonee));
    if (loan->l_status == LS_PROPOSED) {
	pr("(proposed) principal=$%d interest rate=%d%%",
	   loan->l_amtdue, loan->l_irate);
	pr(" duration(days)=%d\n", loan->l_ldur);
	if (loan->l_duedate < now) {
	    loan->l_status = LS_FREE;
	    putloan(n, loan);
	    pr("This offer has expired\n");
	    return 0;
	}
	accept = loan->l_lastpay + loan->l_ldur * SECS_PER_DAY;
	pr("Loan must be accepted by %s", ctime(&accept));
	return 1;
    }

    pr("Amount paid to date $%d\n", loan->l_amtpaid);
    pr("Amount due (if paid now) $%.2f", loan_owed(loan, now));
    if (now <= loan->l_duedate) {
	pr(" (if paid on due date) $%.2f\n",
	   loan_owed(loan, loan->l_duedate));
	pr("Due date is %s", ctime(&loan->l_duedate));
    } else
	pr(" ** In Arrears **\n");
    return 1;
}
Exemple #24
0
RunnerDBEntry *RunnerDB::getRunnerByName(const string &name, int clubId,
                                         int expectedBirthYear) const
{
  if (expectedBirthYear>0 && expectedBirthYear<100)
    expectedBirthYear = extendYear(expectedBirthYear);

  setupNameHash();
  vector<int> ix;
  string cname(canonizeName(name.c_str()));
  multimap<string, int>::const_iterator it = nhash.find(cname);

  while (it != nhash.end() && cname == it->first) {
    ix.push_back(it->second);
    ++it;
  }

  if (ix.empty())
    return 0;

  if (clubId == 0) {
    if (ix.size() == 1)
      return (RunnerDBEntry *)&rdb[ix[0]];
    else
      return 0; // Not uniquely defined.
  }

  // Filter on club
  vector<int> ix2;
  for (size_t k = 0;k<ix.size(); k++)
    if (rdb[ix[k]].clubNo == clubId || rdb[ix[k]].clubNo==0)
      ix2.push_back(ix[k]);

  if (ix2.empty())
    return 0;
  else if (ix2.size() == 1)
    return (RunnerDBEntry *)&rdb[ix2[0]];
  else if (expectedBirthYear > 0) {
    int bestMatch = 0;
    int bestYear = 0;
    for (size_t k = 0;k<ix2.size(); k++) {
      const RunnerDBEntry &re = rdb[ix2[k]];
      if (abs(re.birthYear-expectedBirthYear) < abs(bestYear-expectedBirthYear)) {
        bestMatch = ix2[k];
        bestYear = re.birthYear;
      }
    }
    if (bestYear>0)
      return (RunnerDBEntry *)&rdb[bestMatch];
  }

  return 0;
}
Exemple #25
0
/*
 * Post-processing after successful acceptance of loan.
 * Notify the press, and the folks involved.
 * (Weird spelling is to avoid accept(2)).
 */
static void
accpt(struct ltcomstr *ltcp)
{
    switch (ltcp->type) {
    case EF_LOAN:
	nreport(ltcp->proposer, N_MAKE_LOAN, player->cnum, 1);
	break;
    default:
	CANT_REACH();
    }
    wu(0, ltcp->mailee, "%s #%d accepted by %s\n",
       ltcp->Name, ltcp->num, cname(player->cnum));
}
Exemple #26
0
//! reads uniques from database
void Table::loadUniqueConstraints()
{
    if (uniqueConstraintsLoadedM)
        return;
    uniqueConstraintsM.clear();

    DatabasePtr db = getDatabase();
    wxMBConv* conv = db->getCharsetConverter();
    MetadataLoader* loader = db->getMetadataLoader();
    // first start a transaction for metadata loading, then lock the table
    // when objects go out of scope and are destroyed, table will be unlocked
    // before the transaction is committed - any update() calls on observers
    // can possibly use the same transaction
    MetadataLoaderTransaction tr(loader);
    SubjectLocker lock(this);

    IBPP::Statement& st1 = loader->getStatement(
        "select r.rdb$constraint_name, i.rdb$field_name, r.rdb$index_name "
        "from rdb$relation_constraints r, rdb$index_segments i "
        "where r.rdb$relation_name=? and r.rdb$index_name=i.rdb$index_name and "
        "(r.rdb$constraint_type='UNIQUE') order by r.rdb$constraint_name, i.rdb$field_position"
    );

    st1->Set(1, wx2std(getName_(), conv));
    st1->Execute();
    UniqueConstraint *cc = 0;
    while (st1->Fetch())
    {
        std::string s;
        st1->Get(1, s);
        wxString cname(std2wxIdentifier(s, conv));
        st1->Get(2, s);
        wxString fname(std2wxIdentifier(s, conv));
        st1->Get(3, s);
        wxString ixname(std2wxIdentifier(s, conv));

        if (cc && cc->getName_() == cname)
            cc->columnsM.push_back(fname);
        else
        {
            UniqueConstraint c;
            uniqueConstraintsM.push_back(c);
            cc = &uniqueConstraintsM.back();
            cc->indexNameM = ixname;
            cc->setName_(cname);
            cc->columnsM.push_back(fname);
            cc->setParent(this);
        }
    }
    uniqueConstraintsLoadedM = true;
}
Exemple #27
0
void GamesXmlParser::getGeometry(vector<xmlNodePtr>& aPtrList) {

    NumberOfAtoms = aPtrList.size();

    IonSystem.create(NumberOfAtoms);

    GroupName.resize(NumberOfAtoms);
    Qv.resize(NumberOfAtoms);
    double nel=0;

    for(int i=0; i<NumberOfAtoms; i++) {
        xmlNodePtr cur=aPtrList[i]->children;
        while(cur != NULL) {
            string cname((const char*)cur->name);
            if(cname == "ATOM_NAME") {
                string aname;
                putContent(aname,cur);
                IonSystem.GroupID[i]=IonSystem.getSpeciesSet().addSpecies(aname);
                GroupName[i]=aname;
            } else if(cname == "ATOMIC_NUMBER") {
                putContent(Qv[i],cur);
                nel+=Qv[i];
            } else if(cname == "ATOM_POSITION") {
                xmlNodePtr tcur=cur->children;
                while(tcur!=NULL) {
                    string tname((const char*)tcur->name);
                    double x,y,z;
                    if(tname == "XCOORD") putContent(x,tcur);
                    else if(tname == "YCOORD") putContent(y,tcur);
                    else if(tname == "ZCOORD") putContent(z,tcur);
                    IonSystem.R[i]=SingleParticlePos_t(x,y,z);
                    tcur=tcur->next;
                }
            }
            cur=cur->next;
        }//loop-cur
    }//i

    NumberOfEls=static_cast<int>(nel);
    NumberOfBeta=(NumberOfEls-NumberOfAlpha)/2;
    NumberOfAlpha=NumberOfEls-NumberOfBeta;

    cout << "Number of atoms " << NumberOfAtoms << endl;
    cout << "Number of electrons " << NumberOfEls << endl;
    cout << "Number of electrons (ALPHA) " << NumberOfAlpha << endl;
    cout << "Number of electrons (BETA) " << NumberOfBeta << endl;
    cout << "Group ID " << endl;
    std::copy(IonSystem.GroupID.begin(), IonSystem.GroupID.end(),
              ostream_iterator<int>(cout, " "));
    cout << endl;
}
Exemple #28
0
int
msl_asat_intercept(struct plnstr *msl, coord x, coord y)
{
    struct sctstr sect;
    struct emp_qelem irvlist;

    getsect(x, y, &sect);
    mpr(sect.sct_own, "%s has positioned a satellite over %s\n",
	cname(msl->pln_own), xyas(x, y, sect.sct_own));
    msl_sel(&irvlist, x, y, msl->pln_own, P_O, 0, 0);
    return msl_intercept(msl, &sect, 0,
			 &irvlist, "satellite", "a-sat missile",
			 N_SAT_KILL);
}
Exemple #29
0
//--- Make Canvas ---
TCanvas * makeCanvas(const char* name, const char* title, bool log=false, const char* opt="", const int dx = 1000, const int dy = 700)
{
   //printf("Canvas opt: %s\n", opt);
   TCanvas * c;
   TString cname(Form("c%s",name));

   if (!TString(opt).Contains("same")) {
      c = new TCanvas(cname.Data(),title,dx,dy);
//      printf("Canvas: %d\n",c);
      if (log) c->SetLogy();
   }
//   printf("Canvas %s: %d\n",cname.Data(), c);
   return c;
}
Exemple #30
0
void ApacheReply::commitHeader( const Falcon::String& name, const Falcon::String& value )
{
   Falcon::AutoCString cvalue( value );

   if ( name.compareIgnoreCase( "Content-Type" ) == 0 )
   {
      m_request->content_type = apr_pstrdup ( m_request->pool, cvalue.c_str() );
   }
   else
   {
      Falcon::AutoCString cname( name );
      apr_table_add( m_request->headers_out, cname.c_str(), cvalue.c_str() );
   }
}