本文整理汇总了C++中Database::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ Database::Init方法的具体用法?C++ Database::Init怎么用?C++ Database::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::Init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fire
int main()
{
Database* database;
Player* player1;
database = Database::GetInstance();
database->Init();
// player1 = new Player("test",0);
// printf("dans player = %d\n", player1->__list_charger[1]);
/* while (player1->Get_Weapon()->Get_Charger1() >= 0)
{
// printf("avant fire(chargeur) = %d\n", player1->Get_Weapon()->Get_Nb_Charger1());
printf("avant fire(ammo2) = %d\n", player1->Get_Weapon()->Get_Charger1()->Get_Nb_Ammo());
printf("avant fire(chargeur2) = %d\n", player1->Get_Weapon()->Get_Charger2()->Get_Nb_Ammo());
player1->Fire(0);
player1->Fire(1);
printf("apres fire(ammo2) = %d\n", player1->Get_Weapon()->Get_Charger1()->Get_Nb_Ammo());
printf("apres fire(chargeur2) = %d\n", player1->Get_Weapon()->Get_Charger2()->Get_Nb_Ammo());
if (player1->Get_Weapon()->Get_Charger1()->Get_Nb_Ammo() == 0)
player1->Reload(0);
if (player1->Get_Weapon()->Get_Charger2()->Get_Nb_Ammo() == 0)
player1->Reload(1);
// printf("dans player = %d\n", player1->__list_charger[1]);
printf("apres reload(ammo2) = %d\n", player1->Get_Weapon()->Get_Charger1()->Get_Nb_Ammo());
printf("apres reload(chargeur2) = %d\n", player1->Get_Weapon()->Get_Charger2()->Get_Nb_Ammo());
sleep(1);
}*/
}
示例2: Init
int MultiDatabase :: Init(const std::string & sDBPath, const int iGroupCount)
{
if (access(sDBPath.c_str(), F_OK) == -1)
{
PLErr("DBPath not exist or no limit to open, %s", sDBPath.c_str());
return -1;
}
if (iGroupCount < 1 || iGroupCount > 100000)
{
PLErr("Groupcount wrong %d", iGroupCount);
return -2;
}
std::string sNewDBPath = sDBPath;
if (sDBPath[sDBPath.size() - 1] != '/')
{
sNewDBPath += '/';
}
for (int iGroupIdx = 0; iGroupIdx < iGroupCount; iGroupIdx++)
{
char sGroupDBPath[512] = {0};
snprintf(sGroupDBPath, sizeof(sGroupDBPath), "%sg%d", sNewDBPath.c_str(), iGroupIdx);
Database * poDB = new Database();
assert(poDB != nullptr);
m_vecDBList.push_back(poDB);
if (poDB->Init(sGroupDBPath, iGroupIdx) != 0)
{
return -1;
}
}
PLImp("OK, DBPath %s groupcount %d", sDBPath.c_str(), iGroupCount);
return 0;
}