当前位置: 首页>>代码示例>>C++>>正文


C++ DatabaseManager类代码示例

本文整理汇总了C++中DatabaseManager的典型用法代码示例。如果您正苦于以下问题:C++ DatabaseManager类的具体用法?C++ DatabaseManager怎么用?C++ DatabaseManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DatabaseManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QApplication

PhoebetriaApp::PhoebetriaApp(int &argc, char **argv)
    : QApplication(argc, argv),
      m_currentStyle_filename()
{
    setOrganizationName("Phoebetria");
    setApplicationName("Phoebetria");

    QSettings::setDefaultFormat(QSettings::IniFormat);

    DatabaseManager db;
    db.initAllDatabases();

    if (!setTheme(m_prefs.stylesheet()))
    {
        QMessageBox::critical(
                    NULL,
                    tr("Could not set style."),
                    tr("Could not set the application style."
                               " It may not exist. Please check preferences.\n\n"
                               "Style filename: %1\n\n"
                               "Setting to the standard profile instead."
                       ).arg(m_prefs.stylesheet())
                    );
        setTheme(Themes::getBuiltInStyleSheetName());
    }

    m_globalTimer.start(200);
    m_dispatcher.start(200);

    m_fanControllerIO.connect();            // Connect to the IO device
    m_fanControllerIO.connectSignals();

    m_fanControllerIO.fanControllerData().connectSignals();
}
开发者ID:Shub77,项目名称:phoebetria-code,代码行数:34,代码来源:phoebetriaapp.cpp

示例2: main

int main()
{
    Connection conn;
    DbRetVal rv = conn.open("root", "manager");
    if (rv != OK) return 1;
    DatabaseManager *dbMgr = conn.getDatabaseManager();
    if (dbMgr == NULL) { printf("Auth failed\n"); return 2;}

    TableDef tabDef;
    for (int i=0;i<100;i++)
    {
	tabDef.addField("f1", typeInt);
	tabDef.dropField("f1");
    }
    int fieldcount=tabDef.getFieldCount();
    printf("Number of Fields = %d\n",fieldcount);
    rv=dbMgr->createTable("t1", tabDef);
    if(rv==OK) 
    { 
	printf("Table created without Fields\n"); 
	printf("Test failed\n");
	dbMgr->dropTable("t1");
	return 3;
    }
    
    dbMgr->dropTable("t1"); 
    conn.close();
    return 0;
}
开发者ID:mattibickel,项目名称:csql,代码行数:29,代码来源:fieldcount2.c

示例3: time

void Game::saveToDatabase() const
{
    time_t now = time(0);
    struct tm tstruct;
    char buff[80];
    localtime_s(&tstruct, &now);

    strftime(buff, sizeof(buff), "%Y-%m-%d", &tstruct);
    string strDate = buff;

    strftime(buff, sizeof(buff), "%X", &tstruct);
    string strTime = buff;

    string strMovesString;
    string strPromotionsString;
    for (Move m : vecPreviousMoves)
    {
        if (m.isPawnPromotionMove())
        {
            strPromotionsString += m.getInitialSquare().getPieceAtSquare()->getAbbreviation();
        }
        strMovesString += to_string(m.getInitialSquare().getRow());
        strMovesString += to_string(m.getInitialSquare().getCol());
        strMovesString += to_string(m.getFinalSquare().getRow());
        strMovesString += to_string(m.getFinalSquare().getCol());
    }

    DatabaseManager dbManager;
    dbManager.connectToDatabase();
    dbManager.addGame(strDate, strTime, ptrWhitePlayer->getName(), ptrBlackPlayer->getName(), strMovesString, strPromotionsString);
    dbManager.disconnectFromDatabase();
}
开发者ID:oedead26,项目名称:ChessPP,代码行数:32,代码来源:Game.cpp

示例4: emit

/**
 * @brief Slot triggered when `Ok` is clicked
 * Updates the person or tell the MovieDialog that it's done
 */
void PeopleDialog::on_validationButtons_accepted()
{
    Macaw::DEBUG("[PeopleDialog] validationButtons accepted");
    m_people.setName(getName());
    m_people.setBirthday(getBirthday());
    m_people.setBiography(getBiography());

    // If type != 0, it means we come from the movie dialog
    // If type = 0, it means we directly edit a people
    if (m_people.type() != 0)
    {
        Macaw::DEBUG("[PeopleDialog] validationButtons method: type="
                     +QString::number(m_people.type()));
        emit(peopleCreated(m_people));
    }
    else
    {
        Macaw::DEBUG("[PeopleDialog] validationButtons method: type=0");
        DatabaseManager *databaseManager = ServicesManager::instance()->databaseManager();

        databaseManager->updatePeople(m_people);
    }

    Macaw::DEBUG("[PeopleDialog] validationButtons method done");
}
开发者ID:jrutanen,项目名称:macaw-movies,代码行数:29,代码来源:PeopleDialog.cpp

示例5: setElementIdsList

/**
 * @brief Set the ElementIdsList, used to fill the listWidget
 */
void LeftPannel::setElementIdsList()
{
    Macaw::DEBUG_IN("[LeftPannel] Enters setElementIdsList()");

    m_elementIdsList.clear();

    ServicesManager *servicesManager = ServicesManager::instance();
    DatabaseManager *databaseManager = servicesManager->databaseManager();

    QList<Movie> l_matchingMoviesList = servicesManager->matchingMoviesList();

    foreach(Movie l_movie, l_matchingMoviesList) {
        if( (servicesManager->toWatchState()
                 && databaseManager->isMovieInPlaylist(l_movie.id(), Playlist::ToWatch)
                 ) || !servicesManager->toWatchState()
               ) {
            switch (m_typeElement)
            {
                case Macaw::isPeople:
                {
                    QList<People> l_peopleList = l_movie.peopleList(m_typePeople);
                    this->updateElementIdsList(l_peopleList);
                    break;
                }
                case Macaw::isTag:
                {
                    QList<Tag> l_tagList = l_movie.tagList();
                    this->updateElementIdsList(l_tagList);
                    break;
                }
            }
        }
    }
    Macaw::DEBUG_OUT("[LefPannel] Exits setElementIdsList()");
}
开发者ID:jrutanen,项目名称:macaw-movies,代码行数:38,代码来源:LeftPannel.cpp

示例6: main

int main (int argc, char **argv)
{
  Connection conn;
  DbRetVal rv = conn.open("root","manager");
  printf ("Main open Returned %d\n", rv);
  pthread_t thread1, thread2;
  int message1 =1; 
  int message2 =2; 
  int status;

  pthread_create (&thread1, NULL,
		  &print_message_function, (void *) &message1);
  pthread_create (&thread2, NULL,
		  &print_message_function, (void *) &message2);

  pthread_join(thread1, (void **)&status);
  pthread_join(thread2, (void **)&status);


  DatabaseManager *dbMgr = conn.getDatabaseManager();
  if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;}
  dbMgr->dropTable("T1");
  dbMgr->dropTable("T2");

  rv = conn.close();
  printf ("Main Returned %d\n", rv);
  exit (0);
}
开发者ID:mattibickel,项目名称:csql,代码行数:28,代码来源:threadtest2.c

示例7: print_message_function

void* print_message_function(void *ptr)
{
    //if (flag == 0) {flag =1; sleep(2); }
    char tblname[20];
    sprintf(tblname, "T%d", *(int*)ptr );
    Connection conn;
    DbRetVal rv=conn.open("root","manager");
    printf("Thread Return value of open %d %d\n", rv, getpid());
    if(rv!=OK)
    {
      return NULL;
    }
    DatabaseManager *dbMgr = conn.getDatabaseManager();
    if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;}


    TableDef tabDef;
    tabDef.addField("f1", typeInt);
    tabDef.addField("f2", typeInt);
    rv = dbMgr->createTable(tblname, tabDef);
    if (rv != OK) { printf("Table creation failed\n"); return NULL; }
    printf("Table created\n");

    rv = conn.close();
    printf("Thread Return value of close %d %d\n", rv, getpid());
}
开发者ID:mattibickel,项目名称:csql,代码行数:26,代码来源:threadtest2.c

示例8: main

int main()
{

    Connection conn;
    DbRetVal rv = conn.open("root", "manager");
    if (rv != OK) { printf("Error during connection %d\n", rv); return 1; }
    DatabaseManager *dbMgr = conn.getDatabaseManager();
    int ret = createTable(dbMgr);
    if (ret != 0) { return 1; }

    pthread_t thr[2];
    int *status1, *status2;
    pthread_create (&thr[0], NULL, &runTest1,  NULL);
    pthread_create (&thr[1], NULL, &runTest2,  NULL);
    printf("All threads started\n");

    pthread_join(thr[0], (void**)&status1);
    pthread_join(thr[1], (void**)&status2);
    ret = 0;
    if (*status1 != 0 || *status2 != 0) ret = 1;
    if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; }
    if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; }
    dbMgr->dropTable("t1");
    conn.close();
    return ret;
}
开发者ID:mattibickel,项目名称:csql,代码行数:26,代码来源:isotest11.c

示例9: main

int main()
{
    Connection conn;
    DbRetVal rv = conn.open("root","manager");
    if(rv!=OK)return 1;
    DatabaseManager *dbMgr = conn.getDatabaseManager();
    if(dbMgr == NULL)
    {
       printf("Auth failed\n");
       return 2;
    }

    TableDef tabDef;
    tabDef.addField("f1",typeInt,0,NULL,true);
    tabDef.addField("f2",typeInt);
    
    rv = dbMgr->createTable("t1",tabDef);
    if(rv!=OK)
    {
      printf("Table created failed\n");
      conn.close();
      return 0;
    }

    
    Table *table = dbMgr->openTable("t1");
    long spaceused;
    spaceused = table->spaceUsed();
    printf("Total space used=%ld\n",spaceused);

   dbMgr->closeTable(table);
   dbMgr->dropTable("t1");
   conn.close();
   return 0;
}  	
开发者ID:mattibickel,项目名称:csql,代码行数:35,代码来源:spaceusedtest.c

示例10: main

//creating index with non existing field
//It should fail
int main()
{

    Connection conn;
    DbRetVal rv = conn.open("root", "manager");
    if (rv != OK)
    {
       printf("Error during connection %d\n", rv);
       return -1;
    }
    DatabaseManager *dbMgr = conn.getDatabaseManager();
    if (dbMgr == NULL) { printf("Auth failed\n"); return -1;}
    TableDef tabDef;
    tabDef.addField("f1", typeInt, 0, NULL, true);
    tabDef.addField("f2", typeInt);
    rv = dbMgr->createTable("t1", tabDef);
    if (rv != OK) { printf("Table creation failed\n"); return -1; }
    printf("Table created\n");
    HashIndexInitInfo *idxInfo = new HashIndexInitInfo();
    strcpy(idxInfo->tableName, "t1");
    idxInfo->list.append("notexist");
    idxInfo->indType = hashIndex;
#ifdef TREEINDEX
    idxInfo->indType = treeIndex;
#elif defined TRIEINDEX
    idxInfo->indType = trieIndex;
#endif
    int ret =0;
    rv = dbMgr->createIndex("indx1", idxInfo);
    if (rv == OK) ret =1;
    delete idxInfo;
    dbMgr->dropTable("t1");
    conn.close();
    return ret;
}
开发者ID:mattibickel,项目名称:csql,代码行数:37,代码来源:createindexnotexist.c

示例11: main

int main()
{
    Connection conn;
    DbRetVal rv = conn.open("root", "manager");
    if (rv != OK) return 1;
    DatabaseManager *dbMgr = conn.getDatabaseManager();
    if (dbMgr == NULL) { printf("Auth failed\n"); return 2;}

    if ( createTable(dbMgr) != 0 ) { conn.close(); return 3; }
    int inscount =  insertTuple(dbMgr, conn);
    //check the inscount and return error

    Table *table = dbMgr->openTable("t1");
    if (table == NULL)
    {
        printf("Unable to open table\n");
        return 0;
    }


    Condition p1,p2,p3,p4,p5;
    int val1 = 2, val2 = 3, val3 = 4;
    p1.setTerm("f1", OpEquals, &val3);
    p2.setTerm("f2", OpGreaterThan, &val2);
    p3.setTerm("f2", OpEquals, &val3);
    p4.setTerm("f1", OpLessThan, &val1);
    p5.setTerm("f1", OpGreaterThan, &val1);


    Condition cond1, cond1a;
    cond1.setTerm(p1.getPredicate(), OpAnd, p2.getPredicate());
    cond1a.setTerm(cond1.getPredicate(), OpOr, p4.getPredicate());
    table->setCondition(&cond1a);
    printf("Predicate: (f1 ==4 AND f2 >3) OR (f1< 2) \n");
    conn.startTransaction();
    execAndPrint(table);
    conn.commit();

    Condition cond2, cond2a;
    cond2.setTerm(p4.getPredicate(), OpAnd, p2.getPredicate());
    cond2a.setTerm(cond1.getPredicate(), OpOr, cond2.getPredicate());
    table->setCondition(&cond2a);
    printf("Predicate: (f1 ==4 AND f2 >3) OR (f1< 2 AND f2 > 4) \n");
    conn.startTransaction();
    execAndPrint(table);
    conn.commit();

    dbMgr->closeTable(table);
    dbMgr->dropTable("t1");
    conn.close();
    return 0;

}
开发者ID:mattibickel,项目名称:csql,代码行数:53,代码来源:andorpredicate1.c

示例12: aMove

Game::Game(int intGameID)
{
    DatabaseManager dbManager;
    dbManager.connectToDatabase();
    vector<string> vecGame = dbManager.getGame(intGameID);
    dbManager.disconnectFromDatabase();

    ptrWhitePlayer = new Player(vecGame.at(3), WHITE);
    ptrBlackPlayer = new Player(vecGame.at(4), BLACK);

    int intPromotionsStringIndex = 0;
    for (unsigned int i = 0; i < vecGame.at(5).size(); i += 4)
    {
        int intInitialRow = static_cast<int>(vecGame.at(5).at(i) - '0');
        int intInitialCol = static_cast<int>(vecGame.at(5).at(i + 1) - '0');
        int intFinalRow = static_cast<int>(vecGame.at(5).at(i + 2) - '0');
        int intFinalCol = static_cast<int>(vecGame.at(5).at(i + 3) - '0');
        Move aMove(currentBoard.getSquare(intInitialRow, intInitialCol), currentBoard.getSquare(intFinalRow, intFinalCol));

        if (currentBoard.getPieceAt(intInitialRow, intInitialCol)->getType() == PAWN && (intFinalRow == 0 || intFinalRow == 7))
        {
            aMove.setIsPawnPromotionMove(true);
        }
        makeMove(aMove);
        generatePGNString();

        if (aMove.isPawnPromotionMove())
        {
            char charPromotionAbbreviation = vecGame.at(6).at(intPromotionsStringIndex);
            PieceType promotionType;
            if (toupper(charPromotionAbbreviation) == 'N')
            {
                promotionType = KNIGHT;
            }
            else if (toupper(charPromotionAbbreviation) == 'B')
            {
                promotionType = BISHOP;
            }
            else if (toupper(charPromotionAbbreviation) == 'R')
            {
                promotionType = ROOK;
            }
            else
            {
                promotionType = QUEEN;
            }
            promotePawn(intFinalRow, intFinalCol, promotionType);
            intPromotionsStringIndex++;
        }
    }
}
开发者ID:oedead26,项目名称:ChessPP,代码行数:51,代码来源:Game.cpp

示例13: fillListWidget

/**
 * @brief fill the listWidget based on m_elementIdsList
 * @author Olivier CHURLAUD <[email protected]>
 */
void LeftPannel::fillListWidget()
{
    Macaw::DEBUG_IN("[LeftPannel] Enters fillListWidget()");

    m_ui->listWidget->clear();

    DatabaseManager *databaseManager = ServicesManager::instance()->databaseManager();

    // Add the "All" element
    if(m_typeElement != Macaw::isPlaylist) {
        // First space needed for sorting
        Entity l_entity(" All");
        l_entity.setId(0);

        this->addEntityToListWidget(l_entity);
    }

    foreach(int l_objectId, m_elementIdsList) {
        if(l_objectId == -1) {
            // First space needed for sorting
            Entity l_entity(" Unknown");
            l_entity.setId(-1);

            this->addEntityToListWidget(l_entity);
        } else {
            Entity l_entity;
            switch (m_typeElement)
            {
            case Macaw::isPeople:
                l_entity = databaseManager->getOnePeopleById(l_objectId);
                break;
            case Macaw::isTag:
                l_entity = databaseManager->getOneTagById(l_objectId);
                break;
            }

            this->addEntityToListWidget(l_entity);
        }
    }
    if(m_ui->listWidget->selectedItems().isEmpty()) {
        m_ui->listWidget->item(0)->setSelected(true);
    }
    m_ui->listWidget->sortItems();

    Macaw::DEBUG_OUT("[LeftPannel] Exits fillListWidget()");
}
开发者ID:jrutanen,项目名称:macaw-movies,代码行数:50,代码来源:LeftPannel.cpp

示例14: main

int main()
{
    Connection conn;
    DbRetVal rv = conn.open("root", "manager");
    if (rv != OK) return 1;
    DatabaseManager *dbMgr = conn.getDatabaseManager();
    if (dbMgr == NULL) { printf("Auth failed\n"); return 2;}

    if ( createTable(dbMgr) != 0 ) { conn.close(); return 3; }
    if ( createIndex(dbMgr, false) != 0 ) { dbMgr->dropTable("t1");conn.close(); return 4;
 }
    int inscount =  insertTupleWithSameValue(dbMgr, conn);
    if (inscount != 10 ) { dbMgr->dropTable("t1"); conn.close(); return 5; }
    dbMgr->dropTable("t1");
    conn.close();
    return 0;

}
开发者ID:mattibickel,项目名称:csql,代码行数:18,代码来源:uniqueindex2.c

示例15: StepWidget

DbFieldWidget::DbFieldWidget(DatabaseDialog *parent):
    StepWidget(parent),
    ui(new Ui::DbFieldWidget())
{
    ui->setupUi(this);

    connect(this, SIGNAL(signalAddColumns(QStringList)), this, SLOT(slotAddColumns(QStringList)));

    dialog->setButtonState(DatabaseDialog::BUTTON_BACK, true);
    dialog->setButtonState(DatabaseDialog::BUTTON_NEXT, false);
    dialog->setButtonState(DatabaseDialog::BUTTON_FINISH, false);

    DatabaseManager *dm = MatchMaker::instance->dbManager;

    dm->queryConnection(CONNECTION, dialog->db->getColumnQuery(dialog->dbSetup.getTable()),
    [this](QSqlQuery *query){
        //emit signalProcessQuery(query);
        processQuery(query);
    });
}
开发者ID:jasonpaulos,项目名称:MatchMaker,代码行数:20,代码来源:DbFieldWidget.cpp


注:本文中的DatabaseManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。