/* ******************************************************************************** * * * Class HistoManager * * * ******************************************************************************** */ HistoManager::HistoManager() { INSTANCE = this; //! set Info resolver m_player = Engine::instance(); connect(m_player, SIGNAL(mediaChanged()), this, SLOT(addEntry())); m_timer = new QTimer(); connect(m_timer, SIGNAL(timeout()), this, SLOT(addToDatabase())); //! check database histo table checkHisto(); }
int main() { struct Connection *con = malloc(sizeof(struct Connection)); if (!con) { die("Unable to alocate connection"); } con->db = (struct Database *) malloc(sizeof(struct Database)); if (!con->db) { die("unable to allocate memory for database..."); } int cnt = 0; printf("Commandlist \n\ta - add new record\n\tg - get record \n\te - exit\n"); while(1) { printf("Your command: "); int c = getc(stdin), exitfromloop = 0; switch (c) { case 'a' : printf("Enter key: "); char key[MAX_KEY]; scanf ("%s", &key[0]); printf("Enter value: "); char val[MAX_VALUE]; scanf ("%s", &val[0]); //printf("adding %s:%s\n", key, val); int id = addToDatabase(con->db, key, val); if (id > 0) { printf("Added to db, id: %d\n", id); } else { printf("Unable to add :( \n"); } break; case 'g': printf("Enter id: "); int readID; scanf("%d", &readID); printf ("\n"); readFromDatabase(con->db, readID); fseek(stdin, 0, SEEK_END); break; case 'e': exitfromloop =1; break; default: printf("Unknown command %c", c); } if (exitfromloop) { break; } } clean(con); return 0; }
AcBr::ErrorStatus meshDisplay(const AcBrMesh2d& mesh) { AcBr::ErrorStatus returnValue = AcBr::eOk; // make a global element traverser AcBrMesh2dElement2dTraverser meshElemTrav; returnValue = meshElemTrav.setMesh(mesh); if (returnValue != AcBr::eOk) { acutPrintf("\n Error in AcBrMesh2dElement2dTraverser::setMesh:"); errorReport(returnValue); return returnValue; } // display the elements while (!meshElemTrav.done() && (returnValue == AcBr::eOk) && !acedUsrBrk()) { // convert the nodes into a 3d point array for AcDbPolyline AcGePoint3dArray pts; AcBrElement2dNodeTraverser elemNodeTrav; returnValue = elemNodeTrav.setElement(meshElemTrav); if (returnValue != AcBr::eOk) { acutPrintf("\n Error in AcBrElement2dNodeTraverser::setElement:"); errorReport(returnValue); return returnValue; } while (!elemNodeTrav.done() && (returnValue == AcBr::eOk)) { AcBrNode node; returnValue = elemNodeTrav.getNode(node); if (returnValue != AcBr::eOk) { acutPrintf("\n Error in AcBrElement2dNodeTraverser::getNode:"); errorReport(returnValue); return returnValue; } // add the node geometry data to the lightweight polyline point array returnValue = nodeDisplay(node, pts); if (returnValue != AcBr::eOk) { acutPrintf("\n Error in nodeDisplay:"); errorReport(returnValue); return returnValue; } returnValue = elemNodeTrav.next(); if (returnValue != AcBr::eOk) { acutPrintf("\n Error in AcBrElement2dNodeTraverser::next:"); errorReport(returnValue); return returnValue; } } // end element while // create a simple, closed polygon from the element node list AcDb3dPolyline* pline = new AcDb3dPolyline(AcDb::k3dSimplePoly, pts, Adesk::kTrue); if (pline == NULL) { returnValue = (AcBr::ErrorStatus)Acad::eOutOfMemory; acutPrintf("\n Unable to allocate memory for polyline"); return returnValue; } // post the polyline to the database (this should display the element) AcDbObjectId objId; if (addToDatabase(pline, objId) != AcBr::eOk) { acutPrintf("\n addToDatabase failed"); return returnValue; } // close the database object if (pline->close() != AcBr::eOk) { acutPrintf("\n AcDb3dPolyline::close() failed"); return returnValue; } returnValue = meshElemTrav.next(); if (returnValue != AcBr::eOk) { acutPrintf("\n Error in AcBrMesh2dElement2dTraverser::next:"); errorReport(returnValue); return returnValue; } } // end mesh while return returnValue; }
// Bulk add items to database -- different sig (could probably be handled with a template!) void GridDatabase::addToDatabase(const Vector<BfObject *> &objects) { for(S32 i = 0; i < objects.size(); i++) addToDatabase(objects[i]); }
void FileSniffer::saveFiles() { addToDatabase(); }