本文整理汇总了C++中Computer::getId方法的典型用法代码示例。如果您正苦于以下问题:C++ Computer::getId方法的具体用法?C++ Computer::getId怎么用?C++ Computer::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Computer
的用法示例。
在下文中一共展示了Computer::getId方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: in
vector<int> removeRelation(vector<Person>& p, vector<Computer>& c) {
QTextStream in(stdin);
vector<int> relation;
unsigned int x, y;
QString value;
displayPerson(p);
do{
cout <<"Select a person: ";
value = in.readLine();
x = value.toInt();
if(x > p.size() || x < 1)
cout << "Please choose a number from 1 to " << p.size() << endl;
else
relation.push_back(x - 1);
} while(x > p.size() || x < 1);
Person pers = p[x - 1];
vector<Computer> comps;
for(int i = 0; i < pers.getSize(); i++){
for(unsigned int j = 0; j < c.size(); j++){
if(pers.getComputer(i) == c[j].getId()){
comps.push_back(c[j]);
}
}
}
displayComputer(comps);
do{
cout << "Select a connected computer to remove from chosen person: ";
value = in.readLine();
y = value.toInt();
if(y > comps.size() || y < 1)
cout << "Please choose a number from 1 to " << comps.size() << endl;
else{
Computer comp = comps[y - 1];
int z = -1;
while( c[z].getId() != comp.getId() ) {
z++;
if( c[z].getId() == comp.getId() )
relation.push_back(z);
}
}
} while( y > c.size() || y < 1 );
return relation;
}
示例2: removeEntry
int SQLITEHandler::removeEntry( Computer c ) { // Remove computer from database
if( !status ) // If not connected, fail
return 1;
q.prepare( "DELETE FROM computers WHERE id = (:id)" ); // Delete computer
q.bindValue( ":id", c.getId() );
if( !q.exec() )
return 2;
q.prepare( "DELETE FROM relation WHERE computer = (:id)" ); // Delete relations
q.bindValue( ":id", c.getId() );
if( !q.exec() ) // Attempt to execute query
return 3;
return 0; // Return Success
}
示例3: isRelated
bool Person::isRelated( Computer c ) {
bool related = false;
for( unsigned int x = 0; x < computers.size(); x++ ) {
if( computers[x] == c.getId() )
related = true;
}
return related;
}
示例4: on_button_see_connections_computer_clicked
void MainWindow::on_button_see_connections_computer_clicked() {
int currentlySelectedComputerIndex = ui->computer_list_computer_connections->currentIndex().row();
Computer currentlySelectedComputer = currentlyDisplayedComputers.at(currentlySelectedComputerIndex);
int idOfComputer = currentlySelectedComputer.getId();
string StringIdOfComputer = static_cast<ostringstream*>(&(ostringstream() << idOfComputer) )->str();
vector<Scientist> scientists = sciService.getScientistsByComputerId(StringIdOfComputer);
displayScientistsForComputerConnections(scientists);
ui->button_see_connections_computer->setEnabled(false);
}
示例5: deleteRelation
int SQLITEHandler::deleteRelation( Person p, Computer c ) { // Delete relation between Person and Computer in database
if( !status ) // If not connected, fail
return 1;
q.prepare( "DELETE FROM relation WHERE person = (:person) AND computer = (:computer)" ); // Delete relation
q.bindValue( ":person", p.getId() );
q.bindValue( ":computer", c.getId() );
if( !q.exec() ) // Attempt to execute query
return 2;
return 0; // Return Success
}
示例6: setComputers
void Scientist::setComputers(std::vector<Computer> newComputers)
{
destroyComputers();
for (unsigned int i = 0; i < newComputers.size(); i++)
{
Computer currentComputer = newComputers.at(i);
this->computers.push_back(new Computer(currentComputer.getId(), currentComputer.getName(), currentComputer.getType(), currentComputer.getYearBuilt()));
}
}
示例7: addRelation
int SQLITEHandler::addRelation( Person p, Computer c ) { // Add relation between Person and Computer to database
if( !status ) // If not connected, fail
return 1;
if( p.isRelated( c ) ) // Check if relation already exists
return 2;
q.prepare( "INSERT INTO relation (person, computer) VALUES (:person, :computer)" ); // Delete relation
q.bindValue( ":person", p.getId() );
q.bindValue( ":computer", c.getId() );
if( !q.exec() ) // Attempt to execute query
return 3;
return 0; // Return Success
}
示例8: modifyEntry
int SQLITEHandler::modifyEntry( Computer c ) { // Modify computer in database
if( !status ) // If not connected, fail
return 1;
q.prepare( "UPDATE computers SET name = (:name), creation = (:creation), type = (:type), constructed = (:constructed) WHERE id = (:id)" );
q.bindValue( ":id", c.getId() );
q.bindValue( ":name", c.getName() );
q.bindValue( ":creation", c.getYear() );
q.bindValue( ":type", c.getType() );
q.bindValue( ":constructed", c.getWasBuilt() );
if( !q.exec() ) // Attempt to execute query
return 2;
return 0; // Return Success
}
示例9: updateComputer
bool Computerrepository::updateComputer(Computer computerUpdate) {
QSqlQuery query;
int id = computerUpdate.getId();
QString name = QString::fromStdString((computerUpdate.getName()));
int builtY = computerUpdate.getBuildYear();
QString type = QString::fromStdString((computerUpdate.getType()));
bool builtOrNot = computerUpdate.getBuild();
query.prepare("UPDATE Computers SET Name=:Name, YearBuilt=:YearBuilt,"
" Type=:Type, BuiltOrNot=:BuiltOrNot WHERE id=:id");
query.bindValue(":id", id);
query.bindValue(":Name", name);
query.bindValue(":YearBuilt", builtY);
query.bindValue(":Type", type);
query.bindValue(":BuiltOrNot", builtOrNot);
return query.exec();
}
示例10: editComputer
bool DbManager::editComputer(Computer comp)
{
QString was_built = "";
switch (comp.getBuilt())
{
case 0:
was_built = "0";
break;
case 1:
was_built = "1";
break;
}
return execQuery("UPDATE Computers "
"SET name = '" + comp.getName() + "', "
"year = " + comp.getYear() + ", "
"type = '" + comp.getType() + "', "
"built = " + was_built + " "
"WHERE cID = " + comp.getId());
}
示例11: on_button_remove_computer_clicked
void MainWindow::on_button_remove_computer_clicked() {
int currentlySelectedComputerIndex = ui->table_computers->currentIndex().row();
Computer currentlySelectedComputer = currentlyDisplayedComputers.at(currentlySelectedComputerIndex);
int idToRemove = currentlySelectedComputer.getId();
string stringIdToRemove = static_cast<ostringstream*>( &(ostringstream() << idToRemove) )->str();
int answer = QMessageBox::question(this, "Confirm", "Are you sure?");
if (answer == QMessageBox::No) {
return;
}
bool success = compService.remove(stringIdToRemove);
if (success) {
ui->input_filter_computers->setText("");
displayAllComputers();
ui->statusBar->showMessage("Successfully removed computer", 2500);
ui->button_remove_computer->setEnabled(false);
} else {
int answer = QMessageBox::warning(this, "FAIL", "Failed to remove computer");
}
}
示例12:
vector<Scientist>Service::getAssociatedScientist(Computer computerDetails) {
int idComputerToMatch = computerDetails.getId();
return scientistRepository.getAssociatedScientists(idComputerToMatch);
}