void QOrmObject::loadRelation(QOrmMetaTable *meta) { auto tmp = findRelation(d->meta, meta); if (!tmp) return; tmp->load(this); }
void QOrmObject::remove(QOrmMetaTable *meta, int index) { auto tmp = findRelation(d->meta, meta); if (!tmp) return; tmp->remove(this, index); }
void QOrmObject::append(QOrmMetaTable *meta, QOrmObject *obj) { auto tmp = findRelation(d->meta, meta); if (!tmp) return; tmp->append(this, obj); }
void DocumentModel::breakUp(const IRelation *theRelation) { edge_iterator_t theEdge = findRelation(theRelation), end = boost::edges(theGraph).second; if (end == theEdge) { throw "The specified relation doesn't seem to exist!"; } boost::remove_edge(*theEdge, theGraph); }
// Returns a pointer to the relation with the specified name. Relation Database::accessRelation( string name ) { Relation* r = findRelation(name); if( r == NULL ){ return Relation(); } return *r; }
// Delete the specified tuple from the relation. void Database::removeTupleFromRelation( vector<Entry> tuple, string relationName ) { Relation* targetRelation = findRelation( relationName ); bool didRemove = targetRelation->removeTuple( tuple ); if ( didRemove == true ) { cout << "Tuple removed successfully.\n"; } else { cout << "Tuple not found/removed from the relation.\n"; } }
// remove the specified relation from the database void Database::removeRelationFromDatabase( string relationName ) { Relation* targetRelation = findRelation( relationName ); // Iterator through the vector of the relations until the correct one is // found and then erase it. for ( auto iterator = relations.begin( ); iterator != relations.end( ); ++iterator ) { if ( *iterator == targetRelation ) { relations.erase( iterator ); break; } } }
// Updates all of the entries in a relation that meet the specified condition Relation* Database::update( string relationName, vector<string> attributeNames, vector<Entry> newVals, vector<Condition> conditions ) { Relation* targetRelation = findRelation( relationName ); vector<string> targetAttNames = targetRelation->getAttributeNames( ); vector<int> targetIndeces; for ( unsigned i = 0; i < attributeNames.size( ); i++ ){ for ( unsigned j = 0; j < targetAttNames.size( ); j++ ){ if ( attributeNames.at( i ) == targetAttNames.at( j ) ){ targetIndeces.push_back( j ); } } } ConditionList cl = ConditionList( conditions, targetRelation ); for ( int i = 0; i < targetRelation->getNumTuples( ); i++ ){ if ( cl.evalOnTuple( i ) ){ vector<Entry*> targetRow = targetRelation->getRow( i ); for ( unsigned j = 0; j < targetIndeces.size( ); j++ ){ delete targetRow.at( targetIndeces.at( j ) ); targetRow.at( targetIndeces.at( j ) ) = new Entry( newVals.at( j ) ); } targetRelation->updateRow( targetRow, i ); } } return targetRelation; }
Attribute* Database::accessAttribute( string name , string relationName ) { Relation* relation = findRelation(relationName); vector<Attribute>* attributes = relation->getAttributesPointer(); Attribute* attrib = NULL; unsigned int i; for( i = 0; i < attributes->size(); ++i ){ if( attributes->at(i).name == name ){ attrib = &attributes->at(i); break; } } return attrib; }
int processInventory() { if (menuTable[1]) { menuElementSubStruct *pMenuElementSub = getSelectedEntryInMenu(menuTable[1]); if (pMenuElementSub) { int var2 = pMenuElementSub->ovlIdx; int var4 = pMenuElementSub->header; freeMenu(menuTable[1]); menuTable[1] = NULL; findRelation(var2, var4, currentMenuElementX + 80, currentMenuElementY); return 1; } else { freeMenu(menuTable[1]); menuTable[1] = NULL; } } return 0; }
Relation* Database::accessRelationPointer( string name ){ return findRelation(name); }
int CruiseEngine::processInput() { int16 mouseX = 0; int16 mouseY = 0; int16 button = 0; /*if (inputSub1keyboad()) * { * return 1; * } */ button = 0; if (sysKey != -1) { button = sysKey; mouseX = sysX; mouseY = sysY; sysKey = -1; } else if (automaticMode == 0) { getMouseStatus(&main10, &mouseX, &button, &mouseY); } if (!button) { buttonDown = 0; } // Check for Exit 'X' key if (keyboardCode == Common::KEYCODE_x) return 1; // Check for Pause 'P' key if (keyboardCode == Common::KEYCODE_p) { keyboardCode = Common::KEYCODE_INVALID; _vm->pauseEngine(true); mouseOff(); bool pausedButtonDown = false; while (!_vm->shouldQuit()) { manageEvents(); getMouseStatus(&main10, &mouseX, &button, &mouseY); if (button) pausedButtonDown = true; else if (pausedButtonDown) // Button released, so exit pause break; else if (keyboardCode != Common::KEYCODE_INVALID) break; g_system->delayMillis(10); } if (keyboardCode == Common::KEYCODE_x) // Exit the game return 1; keyboardCode = Common::KEYCODE_INVALID; _vm->pauseEngine(false); mouseOn(); return 0; } // Player Menu - test for both buttons or the F10 key if (((button & CRS_MB_BOTH) == CRS_MB_BOTH) || (keyboardCode == Common::KEYCODE_F10)) { changeCursor(CURSOR_NORMAL); keyboardCode = Common::KEYCODE_INVALID; return (playerMenu(mouseX, mouseY)); } if (userWait) { // Check for left mouse button click or Space to end user waiting if ((keyboardCode == Common::KEYCODE_SPACE) || (button == CRS_MB_LEFT)) userWait = 0; keyboardCode = Common::KEYCODE_INVALID; return 0; } // Handle any changes in game speed if (_speedFlag) { if ((keyboardCode == Common::KEYCODE_KP_PLUS) && (_gameSpeed >= 30)) { _gameSpeed -= 10; keyboardCode = Common::KEYCODE_INVALID; } if ((keyboardCode == Common::KEYCODE_KP_MINUS) && (_gameSpeed <= 200)) { _gameSpeed += 10; keyboardCode = Common::KEYCODE_INVALID; } } if (!userEnabled) { return 0; } if ((currentActiveMenu != -1) && menuTable[currentActiveMenu]) { updateMenuMouse(mouseX, mouseY, menuTable[currentActiveMenu]); } if (dialogueEnabled) { if (menuDown || selectDown || linkedRelation) { closeAllMenu(); menuDown = 0; selectDown = 0; currentActiveMenu = -1; changeCursor(CURSOR_NORMAL); } if ((menuTable[0] == NULL) && (!buttonDown)) { int dialogFound = createDialog(dialogueOvl, dialogueObj, xdial, 0); if (menuTable[0]) { if (dialogFound) { currentActiveMenu = 0; } else { freeMenu(menuTable[0]); menuTable[0] = NULL; currentActiveMenu = -1; } } else { menuDown = 0; } } else { if ((button & CRS_MB_LEFT) && (buttonDown == 0)) { if (menuTable[0]) { callRelation(getSelectedEntryInMenu(menuTable[0]), dialogueObj); freeMenu(menuTable[0]); menuTable[0] = NULL; if (linkedMsgList) { ASSERT(0); // freeMsgList(linkedMsgList); } linkedMsgList = NULL; linkedRelation = NULL; changeCursor(CURSOR_NORMAL); currentActiveMenu = -1; } buttonDown = 1; } } } else if ((button & CRS_MB_LEFT) && (buttonDown == 0)) { // left click buttonDown = 1; // is there a relation if (linkedRelation) { // call sub relation when clicking on an object if (menuDown == 0) { if (menuTable[0]) { int objOvl; int objIdx; int objType; objType = findObject(mouseX, mouseY, &objOvl, &objIdx); if (objType != -1) { callSubRelation(linkedRelation, objOvl, objIdx); } freeMenu(menuTable[0]); menuTable[0] = NULL; } if (linkedMsgList) { // freeMsgList(linkedMsgList); } linkedMsgList = NULL; linkedRelation = NULL; changeCursor(CURSOR_NORMAL); } else { // call sub relation when clicking in inventory if (menuTable[0] && menuTable[1]) { menuElementSubStruct * p0 = getSelectedEntryInMenu(menuTable[1]); if (p0) callSubRelation(linkedRelation, p0->ovlIdx, p0->header); closeAllMenu(); changeCursor(CURSOR_NORMAL); } } selectDown = 0; menuDown = 0; } else { // manage click on object menu if (menuDown == 0) { // Handle left click on an object if (menuTable[0] == 0) { int objOvl; int objIdx; int objType; objType = findObject(mouseX, mouseY, &objOvl, &objIdx); if (objType != -1) { int relation = findRelation(objOvl, objIdx, mouseX, mouseY); if (menuTable[0]) { if (relation) { currentActiveMenu = 0; selectDown = 1; } else { // object has a name but no relation, just move the character freeMenu(menuTable[0]); menuTable[0] = NULL; aniX = mouseX; aniY = mouseY; animationStart = true; } } else { aniX = mouseX; aniY = mouseY; animationStart = true; } } else { // No object found, we move the character to the cursor aniX = mouseX; aniY = mouseY; animationStart = true; } } else { // handle click in menu if (menuTable[0]) { menuElementSubStruct *pMenuElementSub = getSelectedEntryInMenu(menuTable[0]); callRelation(pMenuElementSub, -1); // if there is a linked relation, close menu if (!linkedRelation) { freeMenu(menuTable[0]); menuTable[0] = NULL; changeCursor(CURSOR_NORMAL); } else { // else create the message for the linked relation char text[80]; strcpy(text, menuTable[0]->stringPtr); strcat(text, ":"); strcat(text, currentMenuElement->string); linkedMsgList = renderText(320, (const char *)text); changeCursor(CURSOR_CROSS); } } currentActiveMenu = -1; selectDown = 0; } } else { // Handle left click in inventory if (processInventory()) { currentActiveMenu = 0; selectDown = 1; menuDown = 0; } else { currentActiveMenu = -1; menuDown = 0; } } } } else if ((button & CRS_MB_RIGHT) || (keyboardCode == Common::KEYCODE_F9)) { if (buttonDown == 0) { keyboardCode = Common::KEYCODE_INVALID; // close object menu if there is no linked relation if ((linkedRelation == 0) && (menuTable[0])) { freeMenu(menuTable[0]); menuTable[0] = NULL; selectDown = 0; menuDown = 0; currentActiveMenu = -1; } if ((!selectDown) && (!menuDown) && (menuTable[1] == NULL)) { buildInventory(mouseX, mouseY); if (menuTable[1]) { currentActiveMenu = 1; menuDown = 1; } else { menuDown = 1; } } buttonDown = 1; } } return 0; }