本文整理汇总了C++中Match::getId方法的典型用法代码示例。如果您正苦于以下问题:C++ Match::getId方法的具体用法?C++ Match::getId怎么用?C++ Match::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Match
的用法示例。
在下文中一共展示了Match::getId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testGetPairs
void tstMatch::testGetPairs()
{
printStartMsg("tstMatch::testGetGroup");
TournamentDB* db = getScenario04(true);
Tournament t(getSqliteFileName());
MatchMngr* mm = Tournament::getMatchMngr();
Category mx = Tournament::getCatMngr()->getCategoryById(5);
ERR e;
auto mg = mm->getMatchGroup(mx, 1, 1, &e);
CPPUNIT_ASSERT(e == OK);
CPPUNIT_ASSERT(mg != nullptr);
auto mgl = mg->getMatches();
CPPUNIT_ASSERT(mgl.count() == 1);
Match ma = mgl.at(0);
// test the getPair-functions
CPPUNIT_ASSERT(ma.hasPlayerPair1() == false);
CPPUNIT_ASSERT(ma.hasPlayerPair2() == false);
CPPUNIT_ASSERT_THROW(ma.getPlayerPair1(), std::runtime_error);
CPPUNIT_ASSERT_THROW(ma.getPlayerPair2(), std::runtime_error);
// (artificially) assign one pair
PlayerPair pp1 = Tournament::getPlayerMngr()->getPlayerPair(1);
(*db)[TAB_MATCH][ma.getId()].update(MA_PAIR1_REF, pp1.getPairId());
// test again
CPPUNIT_ASSERT(ma.hasPlayerPair1() == true);
CPPUNIT_ASSERT(ma.hasPlayerPair2() == false);
CPPUNIT_ASSERT(ma.getPlayerPair1().getPairId() == pp1.getPairId());
CPPUNIT_ASSERT_THROW(ma.getPlayerPair2(), std::runtime_error);
// (artificially) assign the second pair
PlayerPair pp2 = Tournament::getPlayerMngr()->getPlayerPair(2);
(*db)[TAB_MATCH][ma.getId()].update(MA_PAIR2_REF, pp2.getPairId());
// test again
CPPUNIT_ASSERT(ma.hasPlayerPair1() == true);
CPPUNIT_ASSERT(ma.hasPlayerPair2() == true);
CPPUNIT_ASSERT(ma.getPlayerPair1().getPairId() == pp1.getPairId());
CPPUNIT_ASSERT(ma.getPlayerPair2().getPairId() == pp2.getPairId());
// remove the first one
(*db)[TAB_MATCH][ma.getId()].update(MA_PAIR1_REF, QVariant());
// test again
CPPUNIT_ASSERT(ma.hasPlayerPair1() == false);
CPPUNIT_ASSERT(ma.hasPlayerPair2() == true);
CPPUNIT_ASSERT_THROW(ma.getPlayerPair1(), std::runtime_error);
CPPUNIT_ASSERT(ma.getPlayerPair2().getPairId() == pp2.getPairId());
delete db;
printEndMsg();
}
示例2: linkToMatch
bool BracketVisElement::linkToMatch(const Match& ma) const
{
Category myCat = getLinkedCategory();
if (ma.getCategory() != myCat) return false;
// lock the database before writing
DbLockHolder lh{db, DatabaseAccessRoles::MainThread};
row.update(BV_MATCH_REF, ma.getId());
return true;
}
示例3: _insertMatch
bool DataBase::_insertMatch(const Match &match) {
QSqlQuery query(_db);
query.prepare("insert into Match (match_id, time_stamp, game_type)"\
" values(?, ?, ?)");
query.addBindValue(match.getId());
query.addBindValue(match.getDate().toTime_t());
query.addBindValue(static_cast<int>(match.getMatchType()));
if (!query.exec()) {
qCritical() << "Could not insert match!\n";
return false;
}
return _insertMatchDetails(match.getDetails());
}