Esempio n. 1
0
//取得
Magic* MagicManager::getById(int id)
{
    std::string sql = "SELECT * FROM " + getTableName() + " WHERE id = ?";
    const char *pzTest;
    sqlite3_prepare_v2(_db, sql.c_str(), strlen(sql.c_str()), &_stmt, &pzTest);
    
    sqlite3_bind_int(_stmt, 1, id);
    sqlite3_step(_stmt);
    
    auto magic = Magic::getInstance();
    
    if(sqlite3_data_count(_stmt)){
        magic->setId(sqlite3_column_int(_stmt, 0));
        magic->setRank(sqlite3_column_int(_stmt, 1));
        magic->setName((char*)sqlite3_column_text(_stmt, 2));
        magic->setParamAttack(sqlite3_column_int(_stmt, 3));
        magic->setParamCure(sqlite3_column_int(_stmt, 4));
        magic->setParamStan(sqlite3_column_int(_stmt, 5));
    }
    
    sqlite3_reset(_stmt);
    sqlite3_clear_bindings(_stmt);
    sqlite3_finalize(_stmt);
    
    return magic;
}
Esempio n. 2
0
Arraylist allGraphs(int rank) {
  Arraylist result = newArraylist(rank);
  Intstack cand = newIntstack(0, NULL), 
    fg = fullgraph(rank);
  unsigned long int x, y, ulim = 1 << fg->size;
  int i;
  setRank(rank);
  for (x = 0L; x < ulim; x++) {
    cand->size = 0;
    y = x;
    i = 0;
    while (y > 0) {
      if (y % 2 == 1) putint(fg->it[i], cand);
      y /= 2;
      i++;
    }
    if (portHistDescending(cand)) {
      putItem((void*) newIntstack(0, cand), result);
    } 
  }
  freestack(cand);
  freestack(fg);
  sortAndWeedForGraphs(rank, result);
  return result;
}
Esempio n. 3
0
int main10(int argc, char *argv[]) { /* Give the classification */
	int rank, option = 0;
	Arraylist ar;
	assert(argc> 1);
	rank = atoi(argv[1]);
	if (argc > 2)
		option = atoi(argv[2]);
	if (option == 2) {
		ar = readCellList();
		setRank(rank);
	} 
	else {
		ar = classify(rank, option);
	}
	if (option != 1) {
		sortAndWeed(rank, ar);
		freePerm();
		printCellList(ar);
#if 0
		printDoubletons(ar);
#endif
		freeStackList(ar);
	}
	if (option == 2)
		finalizeScanner();
	printf("\n");
	reportTime();
#if 0
	reportACnt();
	reportCnt();
#endif
	return 0;
}
Esempio n. 4
0
// assumes at least one spectrum in allRefs
void SearchLibrary::runSearch(Spectrum& s)
{
    scoreMatches(s, cachedSpectra_, targetMatches_);
    scoreMatches(s, cachedDecoySpectra_, decoyMatches_);

    // keep scores from all target psms for estimating Weibull parameters
    vector<double> allScores;
    if(compute_pvalues_){
        for(size_t i=0; i < targetMatches_.size(); i++){
            double dotp = targetMatches_[i].getScore(DOTP);
            allScores.push_back(dotp);
        }
    }

    // there may have been spectra in cachedSpectra_ but none at the
    // correct charge state.  Check again
    if( targetMatches_.size() == 0 ){
        Verbosity::warn("No library spectra found for query %d "
                        "(precursor m/z %.2f).", s.getScanNumber(), s.getMz());
        return;
    }
    if( compute_pvalues_ ){
        addNullScores(s, allScores);
    }

    // sort the matches descending
    sort(targetMatches_.begin(), targetMatches_.end(), compMatchDotScore); 
    sort(decoyMatches_.begin(), decoyMatches_.end(), compMatchDotScore); 

    setRank();
    
    if( printAll_ ){
        cout << "spec " << s.getScanNumber() << endl;
    }

    if( compute_pvalues_ ){
        weibullEstimator_.estimateParams(allScores);
        
        // print params to file
        if( weibullParamFile_.is_open() ){
            weibullParamFile_ << s.getScanNumber() << "\t"
                              << weibullEstimator_.getEta() << "\t"
                              << weibullEstimator_.getBeta() << "\t"
                              << weibullEstimator_.getShift() << "\t"
                              << weibullEstimator_.getCorrelation() << "\t"
                              << weibullEstimator_.getNumPointsFit() 
                //(int)(allScores.size() * fraction_to_fit_)
                              << endl;
        }
        setMatchesPvalues(allScores.size());
    }
}
Esempio n. 5
0
// constructor
// initialize card to a reasonable value.
// the card is initially not visible to any player at the table.
CCard::CCard(void)
{
	setFrontTexture(NULL);
	setBackTexture(NULL);
	setRank(Ace);
	setSuit(Hearts);
	// for debug - set to true
	setFaceUp(false);
	setSpriteLength(0);
	setSpriteWidth(0);
	setLocation(0, 0);
	setFileName(L"");

	return;
}
Esempio n. 6
0
void Planet::setLevel(int level)
{
	if(level < 0 || level > MAX_PLANET_LEVEL)
		return;
	m_nLevel = level;

	if(!m_pRank)
	{
		setRank(Rank::createWithCount(level));
		m_pRank->setPosition(ccp(113,8));
		this->addChild(m_pRank);
	}
	else
	{
		m_pRank->initWithCount(level);
	}
	
}
Esempio n. 7
0
Intstack somePHDvariant(int rank, Intstack cell) {
	/* Pre: cell is centered.
	 * Permute cell such that it becomes portHistDescending.
	 * The cell is destroyed. */
	int hh[RANKLIM];
	Intstack pe = below(rank), pg = newIntstack(rank, NULL) ;
	int i, p, j, q;
	setRank(rank) ;
	portHisto(cell, hh) ;
	
	/* insertion sort of hh, invariant: hh[0..i) is sorted */
	i = 1;
	while (i < rank) {
		j = i;
		p = hh[i];
		q = pe->it[i];
		i++;
		while (j > 0 && hh[j-1] < p) {
			hh[j] = hh[j-1];
			pe->it[j] = pe->it[j-1];
			j--;
		}
		hh[j] = p;
		pe->it[j] = q;
	}
	
	pg->size = rank;
	p = 1;
	for (i = 0; i < rank; i++) {
		pg->it[pe->it[i]] = p;
		p <<= 1;
	}
	freestack(pe) ;
	
	pe = permuteCell(cell, pg) ;
	freestack(pg) ;
	freestack(cell) ;
	return pe;
}
Esempio n. 8
0
void Log::setupSelfBefore()
{
    SimulationItem::setupSelfBefore();

    ProcessCommunicator* comm;

    try
    {
        // get a pointer to the ProcessCommunicator without performing setup
        // to avoid catching (and hiding) fatal errors during such setup
        comm = find<ProcessCommunicator>(false);
    }
    catch (FatalError)
    {
        return;
    }

    // Do the find operation again, now to perform the setup of the
    // PeerToPeerCommunicator so that the correct rank is initialized
    comm = find<ProcessCommunicator>();

    if (comm->isMultiProc()) setRank(comm->rank());
}
Esempio n. 9
0
Scout::Scout(Player* owner, int xPos, int yPos, int boardSpace) : Piece(owner, xPos, yPos, "lib/images/scout.png")
{
	setBoardSpace(boardSpace);
	setRank(2);
}
Esempio n. 10
0
//*****************************************************
Scout::Scout(Player* owner, std::string filename) : Piece(owner, 0, 0, filename.c_str())
{
	setBoardSpace(-1);
	setRank(2);
}
Esempio n. 11
0
Group &
Group::updateRank(RawRank r)
{
    return setRank(std::max(_rank, r));
}
Esempio n. 12
0
//*****************************************************
General::General(Player* owner, int xPos, int yPos, int boardSpace) : Piece(owner, xPos, yPos, "lib/images/general.png"){
	setBoardSpace(boardSpace);
	setRank(9);
}
Esempio n. 13
0
//*****************************************************
General::General(Player* owner, std::string filename) : Piece(owner, 0, 0, filename.c_str()){
	setBoardSpace(-1);
	setRank(9);
}
Esempio n. 14
0
 Puppet::Puppet()
 : mDeck(0)
 {
   setRank(Rank::Puppet);
   _setOwner(this);
 }
Esempio n. 15
0
		bool CalendarTemplateElement::loadFromRecord( const Record& record, util::Env& env )
		{
			bool result(false);

			if(record.isDefined(TABLE_COL_ID))
			{
				RegistryKeyType value(record.getDefault<RegistryKeyType>(TABLE_COL_ID, 0));
				if(value != getKey())
				{
					result = true;
					setKey(value);
				}
			}

			// Rank
			if(record.isDefined(CalendarTemplateElementTableSync::COL_RANK))
			{
				size_t value(
					record.getDefault<size_t>(CalendarTemplateElementTableSync::COL_RANK, 0)
				);
				if(value != getRank())
				{
					result = true;
					setRank(value);
				}
			}

			// Min date
			if(record.isDefined(CalendarTemplateElementTableSync::COL_MIN_DATE))
			{
				date value(neg_infin);
				if(!record.get<string>(CalendarTemplateElementTableSync::COL_MIN_DATE).empty())
				{
					try
					{
						value = from_string(record.get<string>(CalendarTemplateElementTableSync::COL_MIN_DATE));
					}
					catch(...)
					{
					}
				}
				if(value != getMinDate())
				{
					result = true;
					setMinDate(value);
				}
			}

			// Max date
			if(record.isDefined(CalendarTemplateElementTableSync::COL_MAX_DATE))
			{
				date value(pos_infin);
				if(!record.get<string>(CalendarTemplateElementTableSync::COL_MAX_DATE).empty())
				{
					try
					{
						value = from_string(record.get<string>(CalendarTemplateElementTableSync::COL_MAX_DATE));
					}
					catch(...)
					{
					}
				}
				if(value != getMaxDate())
				{
					result = true;
					setMaxDate(value);
				}
			}

			// Days modulo
			if(record.isDefined(CalendarTemplateElementTableSync::COL_INTERVAL))
			{
				days value(
					record.getDefault<long>(CalendarTemplateElementTableSync::COL_INTERVAL, 0)
				);
				if(value != getStep())
				{
					result = true;
					setStep(value);
				}
			}

			// Operation
			if(record.isDefined(CalendarTemplateElementTableSync::COL_POSITIVE))
			{
				Operation value(
					static_cast<Operation>(
						record.getDefault<int>(CalendarTemplateElementTableSync::COL_POSITIVE, 0)
				)	);
				if(value != getOperation())
				{
					result = true;
					setOperation(value);
				}
			}

			// Included calendar
//			if(linkLevel > FIELDS_ONLY_LOAD_LEVEL)
			{
				if(record.isDefined(CalendarTemplateElementTableSync::COL_INCLUDE_ID))
				{
					CalendarTemplate* value(NULL);
					RegistryKeyType iid(
						record.getDefault<RegistryKeyType>(
							CalendarTemplateElementTableSync::COL_INCLUDE_ID,
							0
					)	);
					if(iid > 0)	try
					{
						value = CalendarTemplateTableSync::GetEditable(iid, env).get();
					}
					catch (ObjectNotFoundException<CalendarTemplate> e)
					{
						Log::GetInstance().warn("Data corrupted in " + CalendarTemplateElementTableSync::TABLE.NAME + "/" + CalendarTemplateElementTableSync::COL_INCLUDE_ID, e);
					}
					if(value != getInclude())
					{
						result = true;
						setInclude(value);
					}
				}
			}

			// Link with calendar template
//			if(linkLevel == UP_LINKS_LOAD_LEVEL || linkLevel == UP_DOWN_LINKS_LOAD_LEVEL || linkLevel == ALGORITHMS_OPTIMIZATION_LOAD_LEVEL)
			{
				if(record.isDefined(CalendarTemplateElementTableSync::COL_CALENDAR_ID))
				{
					CalendarTemplate* value(NULL);
					RegistryKeyType id(
						record.getDefault<RegistryKeyType>(
							CalendarTemplateElementTableSync::COL_CALENDAR_ID,
							0
					)	);
					if(id > 0) try
					{
						value = CalendarTemplateTableSync::GetEditable(id, env).get();
					}
					catch (ObjectNotFoundException<CalendarTemplate> e)
					{
						Log::GetInstance().warn("Data corrupted in " + CalendarTemplateElementTableSync::TABLE.NAME + "/" + CalendarTemplateElementTableSync::COL_CALENDAR_ID, e);
					}
					if(value != getCalendar())
					{
						result = true;
						setCalendar(value);
					}
				}
			}

			return result;
		}
Esempio n. 16
0
void CTreeViewGames::onActionRank(const int p_rank) {
    setRank(p_rank);
    m_signal_changed.emit();
}