Esempio n. 1
0
int CWaitingList::getTableQueueUpdate(int length, char*& buf)
{
    pdu_queuedelta data;
    memset(&data, 0, sizeof(data));

    int numDeltas = 0;
    TableList& tableList = getTableList();

    for (TableList::iterator ti = tableList.begin(),
                             te = tableList.end();
         ti != te;
         ++ti)
    {
        if (length + (numDeltas + 1) * sizeof(pdu_queuedelta) >= MAXBUFFERSIZE)
        {
            Sys_LogError("CpduQueueUpdate::sendAllTables: buffer size too small!\n");
            break;
        }

        numDeltas++;
        data.queueNumber = htons(getQueueNumber());
        data.reason = htons(CpduQueueUpdate::QUEUEDELTA_TABLE_ADD);
        strncpy(data.name, (*ti).table_->getTitle().c_str(), PDU_STRINGSIZE);
        memcpy(buf, &data, sizeof(data));
        buf += sizeof(data);
    }

    return numDeltas;
}
Esempio n. 2
0
bool CWaitingList::addTable(u_int16_t gameType, CTable* table)
{
  bool rc = false;

  // As additional checks, make sure the table is
  // not in the list already
  TableList& tlist = getTableList();
  TableList::iterator tpos = find_if(tlist.begin(),
                                     tlist.end(),
                                     same_socket(table->getSocket()));
  if (tpos == tlist.end())
  {
      tpos = find_if(tlist.begin(),
                     tlist.end(),
                     same_number(table->getNumber()));
  }

  if (tpos == tlist.end())
  {   // okay its not in the list, add it
      tlist.push_back(TablePtr(*table));
      rc = true;
  }
  else
  {
    char s[128];
    sprintf(s, "CLounge: Table is already in waiting list: type %d hi: %d lo: %d",
            gameType, table->getLo(), table->getHi());
    Sys_LogError(s);
  }

  return rc;
}
void moveAll(char *srcDb, char* destDb)
/* Rename all gbLoadRna tables from database to another. */
{
struct slName *tables, *tbl;
struct sqlConnection *conn;
struct dyString* sqlCmd = dyStringNew(256);
char *sep;

gbVerbEnter(1, "moveAll");
conn = hAllocConn(srcDb);
gbLockDb(conn, srcDb);
gbLockDb(conn, destDb);

copyChromInfo(conn, destDb);

/* using one does rename atomically */
tables = getTableList(conn);
dyStringAppend(sqlCmd, "rename table");
sep = " "; /* before first table arg */
for (tbl = tables; tbl != NULL; tbl = tbl->next)
    {
    dyStringPrintf(sqlCmd, "%s%s to %s.%s",
                   sep,tbl->name, destDb, tbl->name);
    sep = ", "; /* before other table arg */
    }
sqlUpdate(conn, sqlCmd->string);
dyStringFree(&sqlCmd);
slFreeList(&tables);

gbUnlockDb(conn, destDb);
gbUnlockDb(conn, srcDb);
hFreeConn(&conn);
gbVerbLeave(1, "moveAll");
}
void copyAll(char *srcDb, char* destDb)
/* Copy all gbLoadRna tables from database to another. */
{
struct slName *tables, *tbl;
struct sqlConnection *conn;

gbVerbEnter(1, "copyAll");
conn = hAllocConn(srcDb);
gbLockDb(conn, srcDb);
gbLockDb(conn, destDb);

copyChromInfo(conn, destDb);

/* copy each table */
tables = getTableList(conn);
for (tbl = tables; tbl != NULL; tbl = tbl->next)
    {
    copyTable(conn, destDb, tbl->name, tbl->name);
    }
slFreeList(&tables);
gbUnlockDb(conn, destDb);
gbUnlockDb(conn, srcDb);
hFreeConn(&conn);
gbVerbLeave(1, "copyAll");
}
int main(int argc, char *argv[])
/* work with singly aligning SNPs only */
/* load oldTable subset into list */
/* load newTable subset into hash */
{

char *snpDb = NULL;
struct weightList *oldTableList = NULL;
struct hash *newTableHash = NULL;
char *oldTableName = NULL;
char *newTableName = NULL;

if (argc != 4)
    usage();

oneToOne = 0;
oneToTwo = 0;
oneToThree = 0;
twoToTwo = 0;
twoToOne = 0;
twoToThree = 0;
threeToThree = 0;
threeToOne = 0;
threeToTwo = 0;

snpDb = argv[1];
hSetDb(snpDb);

oldTableName = argv[2];
newTableName = argv[3];

// check that tables exist
if (!hTableExists(oldTableName))
    errAbort("no %s table in %s\n", oldTableName, snpDb);
if (!hTableExists(newTableName))
    errAbort("no %s table in %s\n", newTableName, snpDb);

oldTableList = getTableList(oldTableName);
newTableHash = getTableHash(newTableName);

logFileHandle = mustOpen("snpCompareWeightLog.out", "w");
processSnps(oldTableList, newTableHash);
carefulClose(&logFileHandle);

countFileHandle = mustOpen("snpCompareWeightCounts.out", "w");
fprintf(countFileHandle, "oneToOne = %d\n", oneToOne);
fprintf(countFileHandle, "oneToTwo = %d\n", oneToTwo);
fprintf(countFileHandle, "oneToThree = %d\n", oneToThree);
fprintf(countFileHandle, "twoToTwo = %d\n", twoToTwo);
fprintf(countFileHandle, "twoToOne = %d\n", twoToOne);
fprintf(countFileHandle, "twoToThree = %d\n", twoToThree);
fprintf(countFileHandle, "threeToThree = %d\n", threeToThree);
fprintf(countFileHandle, "threeToOne = %d\n", threeToOne);
fprintf(countFileHandle, "threeToTwo = %d\n", threeToTwo);
carefulClose(&countFileHandle);

return 0;
}
Esempio n. 6
0
void Schema::resetTablesVertically2()
{
    populateSchemaTables();
    QList<Table*> table_list = getTableList();
    foreach(Table *table, table_list) {
        if(mainwin->getSearchBox()->isVisible())
            table->getSearchTerm(mainwin->getSearchBox()->text());
        table->verticalPosition2();
    }
    scene()->setSceneRect(QRectF());
}
Esempio n. 7
0
void Schema::populateSchemaTables()
{
    foreach (Table *table, getTableList())
        delete table;
    this->table_list.clear();
    this->setTableCount(0);

    QList<Table*> table_list;
    QSqlQuery table_query(parent_database->getDatabaseConnection());
    QString table_query_string = "SELECT 0, tablename FROM pg_tables WHERE schemaname='"+this->getName()+"' ORDER BY 1,2";
    table_query.exec(table_query_string);
    setTableCount(table_query.size());
    if(table_query.lastError().isValid()) {
        QMessageBox *error_message = new QMessageBox(QMessageBox::Critical,
                                    tr("Database error"),
                                    tr("Unable to retrieve schema tables.\n"
                                       "Check your database connection or permissions.\n"),
                                    QMessageBox::Cancel,0,Qt::Dialog);
        error_message->setWindowModality(Qt::NonModal);
        error_message->show();
        return;
    }
    while (table_query.next()) {
        QString table_name = table_query.value(1).toString();
        Table *table;
        if(table_query.value(0).toInt() == 0) {
            table = new Table(parent_database, this, table_name, table_list.size(), QColor(100,50,50));
            table->setView(false);
        }
        else
            return;

        table->setSearched(true);
        if(mainwin->isColumnView())
            table->verticalPosition2();
        else
            table->defaultPosition();

        QObject::connect(mainwin->getSearchBox(), SIGNAL(textChanged(QString)), table, SLOT(getSearchTerm(QString)));
        QObject::connect(mainwin, SIGNAL(showColumnView()), table, SLOT(verticalPosition2()));
        QObject::connect(table, SIGNAL(expandTable(Database *, Schema *, Table*)), mainwin, SLOT(showTableView(Database *, Schema *, Table*)));
        QObject::connect(table, SIGNAL(designTable(Database *, Schema *, Table*)), mainwin, SLOT(showDesignView(Database *, Schema *, Table*)));
        //QObject::connect(table, SIGNAL(rename(Database *, Schema *, Table*)), mainwin, SLOT(renameTable(Database *, Schema *, Table*)));
        QObject::connect(table, SIGNAL(clearTable(Database *, Schema *, Table*)), mainwin, SLOT(clearTableView(Database *, Schema *, Table*)));
        QObject::connect(table, SIGNAL(dropTable(Database *, Schema *, Table*)), mainwin, SLOT(dropTable(Database *, Schema *, Table*)));

        table_list.append(table);
        if(!parent_database->tableNamesList().contains(table_name))
            parent_database->appendTableName(table_name);
    }
    setTableList(table_list);
}
Esempio n. 8
0
bool CWaitingList::removeTable(int tableNumber)
{
  bool rc = false;

  TableList& tlist = getTableList();
  TableList::iterator tpos = find_if(tlist.begin(),
                                     tlist.end(),
                                     same_number(tableNumber));
  if (tpos != tlist.end())
  {
    rc = true;
    tlist.erase(tpos);
  }

  return rc;
}
void dropAll(char *database)
/* Drop all gbLoadRna tables from database. */
{
struct slName *tables, *tbl;
struct sqlConnection *conn;

gbVerbEnter(1, "dropAll");
conn = hAllocConn(database);
gbLockDb(conn, NULL);

tables = getTableList(conn);
for (tbl = tables; tbl != NULL; tbl = tbl->next)
    sqlDropTable(conn, tbl->name);
slFreeList(&tables);
gbUnlockDb(conn, NULL);
hFreeConn(&conn);
gbVerbLeave(1, "dropAll");
}