Exemplo n.º 1
0
void CloginDlg::OnVerification()
{
	// TODO: Add your control notification handler code here
	//将对话框中编辑框的数据读取到成员变量中
	UpdateData(TRUE);
	//检查数据有效性
	if (m_UserName == "")
	{
		AfxMessageBox(_T("请输入用户名"));
		return;
	}
	if (m_PassWord == "")
	{
		AfxMessageBox(_T("请输入密码"));
		return;
	}
	Users user;
	if(!user.isExist(m_UserName,_T("login"))){
		AfxMessageBox(_T("用户不存在"));
		return;
	} 
	user.GetInfo(m_UserName);

	if(user.getPassWord()!=m_PassWord){
		AfxMessageBox(_T("密码错误"));
		return;
	}
	else{
		CRecorderDlg dlg;
		dlg.DoModal();
	}
}
Exemplo n.º 2
0
// Construct user database (coefficients vector+name for each user):
// --constructuserbase <eigenfaces filename> <textfile image list> <database output filename>
void Main::constructUserbase()
{
	std::string eigenfacesname=args.nextArg();
	std::string imagelistname=args.nextArg();
	std::string databasename=args.nextArg();
	EigFaces eigfaces;
	eigfaces.load(eigenfacesname);
	int n=0;
	{
		TextFileReader file(imagelistname);
		std::string image_name=file.readString();
		while (image_name!="") {
			n++;
			image_name=file.readString();
		}
	}
	Users userbase;
	TextFileReader file(imagelistname);
	for (int i=0; i<n; i++) {
		std::string image_name=file.readString();
		Face face(eigfaces.getWidth(), eigfaces.getHeight());
		face.loadTarga(image_name);
		User user(image_name.substr(0, image_name.length()-4), eigfaces.getHeight()*eigfaces.getWidth());
		eigfaces.projectFace(face, user);
		userbase.addUser(user);
	}
	userbase.save(databasename);
}
Exemplo n.º 3
0
void TableWindow::Prepare(QString filter)
{
    Database database = Database::getInstance();
    QSqlDatabase db = database.getDatabase();

    if (db.open()) {
        Users *user = new Users();
        if (user->userCanEdit(login)) {
            QSqlTableModel *model = new QSqlTableModel();
            model->setTable("money_management");
            model->setFilter(filter);
            model->select();
            model->setEditStrategy(QSqlTableModel::OnFieldChange);
            ui->tableView->setModel(model);
        }
        else {
            QSqlQueryModel *model = new QSqlQueryModel();
            QString query = "select * from money_management";

            if (!filter.isEmpty()) {
                query +=  " where " + filter;
            }

            model->setQuery(query, db);
            ui->tableView->setModel(model);
        }
    }
    else {
        qDebug() << "Open db error.";
    }
}
Exemplo n.º 4
0
Users Database::fillUser()
{
    Users u;
    this->query.first();
    this->record = this->query.record();
    u.setId(this->query.value(this->record.indexOf("id")));
    u.setName(this->query.value(this->record.indexOf("name")));
    return u;
}
Exemplo n.º 5
0
Users Database::getUsers(QString name)
{
    Users u;
    u.setId(-1);
    this->query.prepare("Select id, name FROM Users WHERE Users.name=? LIMIT 1;");
    this->query.addBindValue(QVariant(name));
    if(!this->query.exec()){
        this->showError(this->query.lastError());
        return u;
    }
    u = this->fillUser();
    return u;
}
Exemplo n.º 6
0
Users Database::getUsers(unsigned int id)
{
    Users u;
    u.setId(-1);
    this->query.prepare("Select * FROM Users WHERE Users.id=? LIMIT 1;");
    this->query.addBindValue(QVariant(id));
    if(!this->query.exec()){
        this->showError(this->query.lastError());
        return u;
    }
    u = this->fillUser();
    return u;
}
Exemplo n.º 7
0
void VideoWindow::loadUsers(){
    Database db;
    QList<Users> users = db.getAllUsers();
    QStringList completions;
    for(int l = 0; l < users.size(); l++){
        Users u = users.at(l);
        QString name = u.getName().toString();
        completions.push_back(name);
    }
    QCompleter *completer = new QCompleter(completions, this);
    completer->setCompletionMode(QCompleter::PopupCompletion);
    this->ui->observer->setCompleter(completer);
}
Exemplo n.º 8
0
TableWindow::TableWindow(QWidget *parent, QString login) :
    QMainWindow(parent),
    ui(new Ui::TableWindow)
{
    ui->setupUi(this);
    this->login = login;

    ui->actionConnect->connect(ui->actionConnect, SIGNAL(triggered()), this, SLOT(Connect()));
    ui->actionFind->connect(ui->actionFind, SIGNAL(triggered()), this, SLOT(Find()));
    ui->actionChange_password->connect(ui->actionChange_password, SIGNAL(triggered()), this, SLOT(ChangePassword()));
    ui->actionAdd_new_user->connect(ui->actionAdd_new_user, SIGNAL(triggered()), this, SLOT(AddNewUser()));
    ui->actionExit->connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(CloseTableWindow()));

    Users *user = new Users();
    ui->actionAdd_new_user->setVisible(user->userCanEdit(login));
}
Exemplo n.º 9
0
QList<Users> Database::getAllUsers()
{
    QList<Users> users;
    this->query.prepare("Select * FROM Users ORDER BY Users.name;");
    if(!this->query.exec()){
        this->showError(this->query.lastError());
        return users;
    }
    while(this->query.next()){
        Users u;
        u.setId(this->query.value(0));
        u.setName(this->query.value(1));
        users.push_back(u);
    }
    return users;
}
Exemplo n.º 10
0
void AdminWindow::on_btn_Users_clicked()
{
    QVector<UserRegiData*> allUsers;
    Users *users = new Users();
    //
    QSqlQuery query;
    query.prepare("SELECT * FROM Users");
    bool r = query.exec();

    if(r)
    {
        while(query.next())
        {
            UserRegiData *user = new UserRegiData();

            user->setName(query.record().value("name").toString());
            user->setType(query.record().value("type").toString());
            user->setPass(query.record().value("password").toString());
            user->setAddress(query.record().value("address").toString());
            user->setMobile(query.record().value("mobile").toString());
            user->setPhoto(query.record().value("photo").toString());

            allUsers.push_back(user);
        }
    }
    //

    connect(users, SIGNAL(signal_userRemoved(QString)), this, SLOT(onUserRemoved(QString)),  Qt::UniqueConnection);
    connect(users, SIGNAL(signal_userEdited(UserRegiData*)), this, SLOT(onUserEdited(UserRegiData*)), Qt::UniqueConnection);
    connect(users, SIGNAL(signal_userViewed(UserRegiData*)), this, SLOT(onUserViewed(UserRegiData*)),  Qt::UniqueConnection);

    connect(users, SIGNAL(signal_UserRegiSubmitted(UserRegiData*)), this, SLOT(onUserRegiSubmitted(UserRegiData*)), Qt::UniqueConnection);

    connect(this, SIGNAL(signal_AdminPanelUsersBtnClicked(QVector<UserRegiData*>)), users, SLOT(onAdminWindowUsersBtnClicked(QVector<UserRegiData*>)),  Qt::UniqueConnection);


    emit(signal_AdminPanelUsersBtnClicked(allUsers));

    users->setWindowModality(Qt::ApplicationModal);


    users->show();


}
Exemplo n.º 11
0
void
SimpleRedmineClient::retrieveUsers( UsersCb callback, QString parameters )
{
    ENTER()(parameters);

    auto cb = [=]( QNetworkReply* reply, QJsonDocument* json )
    {
        ENTER();

        // Quit on network error
        if( reply->error() != QNetworkReply::NoError )
        {
            DEBUG() << "Network error:" << reply->errorString();
            callback( Users(), RedmineError::ERR_NETWORK, getErrorList(reply, json) );
            RETURN();
        }

        Users users;

        // Iterate over the document
        for( const auto& j1 : json->object() )
        {
            // Iterate over all users
            for( const auto& j2 : j1.toArray() )
            {
                QJsonObject obj = j2.toObject();

                User user;
                parseUser( user, &obj );
                users.push_back( user );
            }
        }

        callback( users, RedmineError::NO_ERR, QStringList() );

        RETURN();
    };

    RedmineClient::retrieveUsers( cb, parameters );

    RETURN();
}
Exemplo n.º 12
0
int Database::editUsers(Users u)
{
    QVariant name = u.getName().toString().toLower();
    if(this->userExist(name) > 0){
        this->showError(QMessageBox::tr("Esse usuário já existe"));
        return 0;
    }
    if(this->userExist(name) >= 0){
        this->query.prepare("UPDATE Users SET name=? WHERE Users.id=?;");
        this->query.addBindValue(name);
        this->query.addBindValue(u.getId());
        if(!this->query.exec()){
            this->showError(this->query.lastError());
            return -1;
        }
        return 1;
    }
    QMessageBox::information(0, QMessageBox::tr("Erro"),QMessageBox::tr("Usuário não encontrado!"));
    return 0;
}
Exemplo n.º 13
0
Arquivo: Session.C Projeto: DTidd/wt
std::vector<User> Session::topUsers(int limit)
{
  dbo::Transaction transaction(session_);

  Users top = session_.find<User>().orderBy("score desc").limit(limit);

  std::vector<User> result;
  for (Users::const_iterator i = top.begin(); i != top.end(); ++i) {
    dbo::ptr<User> user = *i;
    result.push_back(*user);
 
    dbo::ptr<AuthInfo> auth = *user->authInfos.begin();
    std::string name = auth->identity(Auth::Identity::LoginName).toUTF8();

    result.back().name = name;
  }

  transaction.commit();

  return result;
}
Exemplo n.º 14
0
// Find user given face
// --recognizeface <targa filename> <userbase file> <eigenfaces file> <matches>
void Main::recognizeFace()
{
	std::string filename=args.nextArg();
	std::string userbasename = args.nextArg();
	std::string eigfacesname = args.nextArg();
	int matches=args.nextPositiveInt();
	EigFaces eigenfaces;
	eigenfaces.load(eigfacesname);
	Users userbase;
	userbase.load(userbasename);
	Face face(eigenfaces.getWidth(), eigenfaces.getHeight());
	face.loadTarga(filename);
	std::string name;
	eigenfaces.recognizeFace(face, userbase);
	std::cout << "Face '" << filename << "' ";
	std::cout << "recognized as being closest too:" << std::endl;
	for (int i=0; i< matches; i++) {
		const User& user=userbase[i];
		std::cout << i << ": " << user.getName() << "; MSE: " << user.getMse() << std::endl;
	}
}
Exemplo n.º 15
0
// Verify an identity (determine if a face is person x's):
// --verifyface <targa filename> <userbase file> <person name> <eigenfaces filename> <maximum v coefficients MSE>
void Main::verifyFace()
{
	std::string filename = args.nextArg();
	std::string userbasename = args.nextArg();
	std::string username = args.nextArg();
	std::string eigfilename = args.nextArg();
	double max_coefficients_mse = args.nextPositiveFloat();
	EigFaces eigenfaces;
	eigenfaces.load(eigfilename);
	Users userbase;
	userbase.load(userbasename);
	Face face(eigenfaces.getWidth(), eigenfaces.getHeight());
	face.loadTarga(filename);
	const User& user= userbase[username];
	double mse;
	bool verified=eigenfaces.verifyFace(face, user, max_coefficients_mse, mse);
	std::cout << "MSE: " << mse << std::endl;
	std::cout << "Image '" << filename << "' is";
	std::cout << (verified?" ":" not ");
	std::cout << "a picture of " << username << "'s face." << std::endl;
}
Exemplo n.º 16
0
SayWindow::SayWindow(Wt::WContainerWidget* parent) : Wt::WContainerWidget(parent)
{
     // Get the user's name to say Hi with
     HelloApp* app = dynamic_cast<HelloApp*>(Wt::WApplication::instance());
     new Wt::WText(Wt::WString("I have the loggedin user as: ") + app->session().user()->getName() + app->userName(), this);
     addWidget(new Wt::WBreak());
     new Wt::WAnchor(Wt::WLink(Wt::WLink::InternalPath, "/ask"), "Go back to ask page", this);
     // Show a list of users
     addWidget(new Wt::WBreak());
     new Wt::WText(Wt::WString("in database i have to following users:"), this);
     addWidget(new Wt::WBreak());
     addWidget(new Wt::WBreak());
     Wt::WTable* table = new Wt::WTable(this);
     Wt::Dbo::Transaction t(app->session());
     Users users = app->userList();
     int i=0;
     for (Users::const_iterator user=users.begin(); user != users.end(); ++user) {
          table->elementAt(i++, 0)->addWidget(
               new Wt::WText(Wt::WString("user [number] is:") +(*user)->getName())
          );
     }
}
Exemplo n.º 17
0
int Database::insertUser(Users u)
{
    QVariant name = u.getName().toString().toLower();
    if(!this->userExist(name)){
        this->query.prepare("INSERT INTO Users (name) VALUES (:name);");
        this->query.bindValue(":name",name);
        if(!this->query.exec()){
            this->showError(this->query.lastError());
            return -1;
        }
        return this->query.lastInsertId().toInt();
    }
    this->showError(QMessageBox::tr("Esse usuário já existe!"));
    return 0;
}
Exemplo n.º 18
0
string PaybillTransaction::Process(Users user, Users* all_users) {
  double fee, total;
  string balance;    //balance of user for an admin login
  string acct_number;  //account number of user for an admin login
  string transaction_data = "";

  if (user.GetAccountName() == "") {  //if admin login...
    cout << "Account holder's name:" << endl;  //get account holder's name  (for admin login)
    cin.ignore();
    getline(cin, name);
  }
  for (int i = 0; i < 10; i++) {   //search for balance of account holder
    if (all_users[i].GetAccountName().compare(name) == 0) {  
      balance = all_users[i].GetBalance();
      acct_number = all_users[i].GetAccountNumber();
      break;
    }
  }
  cout << "Account number:" << endl;
  cin >> account_number;

  if (user.GetAccountName() != "" && account_number != user.GetAccountNumber()) {   //check if account number is valid
    return "invalid";
  }
  if (user.GetAccountName() == "" && account_number != acct_number) {
    return "invalid";
  }
  cout << "Payee:" << endl;
  cin >> company;

  if (company.compare("EC") != 0 && company.compare("CQ") != 0 && company.compare("TV") != 0) {  //can only accept companies EC, CQ, TV
    return "invalid";
  }
  cout << "Amount:" << endl;
  cin >> amount;
       
  if (user.GetAccountName() != "") {  // get name of user (for standard login)
    name = user.GetAccountName();
  }

  if (user.GetPlanType() == "S") {   //assess paybill transaction fee
    fee = .05;
  } else if (user.GetPlanType() == "N") {
    fee = .10;
  } else {
    fee = 0;
  }
  total = atof(amount.c_str()) + fee;   //total, including fee

  if (total > atof(user.GetBalance().c_str())) {  //check to make sure balance after is at least $0.00
    if (user.GetAccountName() == "") {
      for (int i = 0; i < 10; i++) {   // search for status of account holder
        if (all_users[i].GetAccountName().compare(name) == 0) {
          if (total > atof(all_users[i].GetBalance().c_str())) {
            return "invalid";
          }
        }
      }
    } else {
       return "invalid";
    }
  }
  if (user.GetAccountName() != "" && atof(amount.c_str()) > 2000.00) {   //check if standard user does not exceed limit of $2000.00
    return "invalid";
  }  
  transaction_data = TransactionFile::WriteTransaction("paybill", name, account_number, amount, company); 
  return transaction_data;        
}
Exemplo n.º 19
0
void CFirstPageDlg::OnFpTest()
{

	if(bRecording==FALSE){
		//mean that stay in the state of Stop.
		//click the button can triger the behavior of record.
		pBuffer1=(PBYTE)malloc(INP_BUFFER_SIZE);
		pBuffer2=(PBYTE)malloc(INP_BUFFER_SIZE);
		if (!pBuffer1 || !pBuffer2) {
			if (pBuffer1) free(pBuffer1);
			if (pBuffer2) free(pBuffer2);
			MessageBeep(MB_ICONEXCLAMATION);
			AfxMessageBox(TEXT("Memory erro!"));//TEXT()
			return ;
		}
	
		//open waveform audo for input
		//fill in the structure WAVEFORMATEX
		waveform.wFormatTag=WAVE_FORMAT_PCM; //PCM pulse code modulation
		waveform.nChannels=1;
		waveform.nSamplesPerSec=11025;//sample rate =25khz
		waveform.nAvgBytesPerSec=11025;//ave data rate = 25khz
		waveform.nBlockAlign=1;
		waveform.wBitsPerSample=8; //8 bits per sample
		waveform.cbSize=0;

	
		if (waveInOpen(&hWaveIn,WAVE_MAPPER,&waveform,(DWORD)this->m_hWnd,NULL,CALLBACK_WINDOW)) {
			free(pBuffer1);
			free(pBuffer2);
			MessageBeep(MB_ICONEXCLAMATION);
			AfxMessageBox(_T("Audio can not be open!"));
		}
		//PWAVEHDR pWaveHdr1,pWaveHdr2;
		pWaveHdr1->lpData=(LPSTR)pBuffer1;
		pWaveHdr1->dwBufferLength=INP_BUFFER_SIZE;
		pWaveHdr1->dwBytesRecorded=0;
		pWaveHdr1->dwUser=0;
		pWaveHdr1->dwFlags=0;
		pWaveHdr1->dwLoops=1;
		pWaveHdr1->lpNext=NULL;
		pWaveHdr1->reserved=0;
	
		waveInPrepareHeader(hWaveIn,pWaveHdr1,sizeof(WAVEHDR));
	
		pWaveHdr2->lpData=(LPSTR)pBuffer2;
		pWaveHdr2->dwBufferLength=INP_BUFFER_SIZE;
		pWaveHdr2->dwBytesRecorded=0;
		pWaveHdr2->dwUser=0;
		pWaveHdr2->dwFlags=0;
		pWaveHdr2->dwLoops=1;
		pWaveHdr2->lpNext=NULL;
		pWaveHdr2->reserved=0;
	
		waveInPrepareHeader(hWaveIn,pWaveHdr2,sizeof(WAVEHDR));
	
		//////////////////////////////////////////////////////////////////////////
		pSaveBuffer = (PBYTE)realloc (pSaveBuffer, 1) ;
		// Add the buffers
	
		waveInAddBuffer (hWaveIn, pWaveHdr1, sizeof (WAVEHDR)) ;
		waveInAddBuffer (hWaveIn, pWaveHdr2, sizeof (WAVEHDR)) ;
	
		// Begin sampling
		this->showMsg+=_T("Recording...\r\n");
		((CEdit *)GetDlgItem(IDC_FP_TESTOUT))->SetWindowText(this->showMsg);
		dwDataLength = 0 ;
		
		waveInStart (hWaveIn) ;

	}
	else{
		//bRecording == TRUE
		//Recording state,click the button will stop recording and finish the Test.
		if(bRecording){
			//bEnding=TRUE;
			waveInReset(hWaveIn);//stop the record!
		}
		bRecording = FALSE;
		CString filepath;
		filepath = _T("E:\\Speechdata\\Test");
		//find the directory
		if(!PathIsDirectory(filepath)){
			CreateDirectory(filepath,NULL);
		}
		//set the test filename
		CTime current = CTime::GetCurrentTime();
		CString filename;
		int y = current.GetYear();
		int m = current.GetMonth();
		int d = current.GetDay();
		int h = current.GetHour();
		int min = current.GetMinute();
		int s = current.GetSecond();
		filename.Format(_T("%d%d%d%d%d%d"),y,m,d,h,min,s);
		filename+=".wav";
		filepath+=_T("\\")+filename; 
		
		CFileFind find;
		if(!find.FindFile(filepath)){
			save(filepath);
		}
		find.Close();

		USES_CONVERSION;// #define CString to char *
	
		//CStdioFile myfile;
		CString file1;
		CString folderName = _T("E:\\Speechdata\\");
		file1=_T("speakerdata.mat");
		//file2=_T("NameTable.txt");
		file1=folderName+file1;	//E:\\Speechdata\\speakerdata.mat
		//file2=folderName+file2;
		

		//make sure the corresponse of the file1 and file2
		CFileFind find1;
		//CFileException fileException;
		if(!find1.FindFile(file1)){
			Initial();
			/*
			if(find2.FindFile(file2)){
				myfile.Remove(file2);		
				if(!myfile.Open(file2,CFile::modeCreate,&fileException)){
					AfxMessageBox(_T("Create Failure!"));
				}
				
			}
			find2.Close();
			*/
		}	
		find1.Close();

		char* mysph=W2A(filename);
		mwArray speaker;//store the output
		mwArray sphName(mysph);
		try {
			//TestSpeech(int nargout, mwArray& pytest, const mwArray& SpeechName);
			TestSpeech(1,speaker,sphName);

			//conversion from mwArray to CString.
			mwString str=speaker.ToString();
			const char* pytest = (const char*)str;
			CString name;
			name=pytest;
			
			CTime current = CTime::GetCurrentTime();
			CString curtime;
			int h = current.GetHour();
			int min = current.GetMinute();
			int s = current.GetSecond();
			curtime.Format(_T("%02d:%02d:%02d"),h,min,s);
			this->showMsg+=curtime+_T(":")+name+_T("\r\n");//Display the outcome of TEST
			
			((CEdit *)GetDlgItem(IDC_FP_TESTOUT))->SetWindowText(this->showMsg);
			//显示用户信息(姓名,编号,部门等);

			Users signer;
			if(!signer.isExist(name,_T("train"))){
				AfxMessageBox(_T("Invalid users or the existence of inconformity."));
				return;
			}
			signer.GetUserInfo(name);

			CString signerinfo;
			signerinfo.Format(_T("UserName:%s\r\nUserId:%s\r\nDepartment:%s\r\nEmail:%s\r\n"),signer.getUserName(),signer.getUserId(),signer.getDep(),signer.getEmail());
			UINT inret = MessageBox(signerinfo,_T("测试ing"),MB_ICONQUESTION|MB_OKCANCEL);
			if(inret==IDCANCEL){
				ErrorCnt++;
				if(ErrorCnt == 2){
					AfxMessageBox(_T("Your stored information may have been destroyed.Please contact the Administrator to re-enrollment"));
				}
				AfxMessageBox(_T("SignIn Error: identity discrepancy.Leave %d times to try again!"),2-ErrorCnt);
				return;
			}
			else if(inret == IDOK){
				//flush the signer's signin record.
				//userid timetoarrive
				current = CTime::GetCurrentTime();
				int year = current.GetYear();
				int month = current.GetMonth();
				int day = current.GetDay();

				int hour = current.GetHour();
				int minute = current.GetMinute();
				int second = current.GetSecond();
				CString signtime,signdate;
				signdate.Format(_T("%d/%d/%d"),month,day,year);
				signtime.Format(_T("%02d:%02d:%02d"),hour,minute,second);
				signer.setDTA(signdate);
				signer.setTTA(signtime);

				if(signer.InsertSignIn())
					AfxMessageBox(_T("SignIn Success"));
				else
					AfxMessageBox(_T("SignIn Error"));
				
				this->showMsg="";
				ErrorCnt=0;
			}
			
		}
		catch(const mwException &e){
			 CString ex;
			 char *str=(char *)e.what();
			 str[strlen(e.what())]='\0';
			 ex=str;
			 //display
			 this->showMsg+=ex+_T("\r\n");
			 ((CEdit *)GetDlgItem(IDC_FP_TESTOUT))->SetWindowText(this->showMsg);
			 
			 CString caption=_T("warning");
			 MessageBox(ex,caption);
		}
	}

}
Exemplo n.º 20
0
void run()
{
  /*****
   * Dbo tutorial section 3. A first session
   *****/

  /*
   * Setup a session, would typically be done once at application startup.
   *
   * For testing, we'll be using Sqlite3's special :memory: database. You
   * can replace this with an actual filename for actual persistence.
   */
  dbo::backend::Sqlite3 sqlite3(":memory:");
  sqlite3.setProperty("show-queries", "true");
  dbo::Session session;
  session.setConnection(sqlite3);

  session.mapClass<User>("user");

  /*
   * Try to create the schema (will fail if already exists).
   */
  session.createTables();

  {
    dbo::Transaction transaction(session);

    User *user = new User();
    user->name = "Joe";
    user->password = "******";
    user->role = User::Visitor;
    user->karma = 13;

    dbo::ptr<User> userPtr = session.add(user);
  }

  /*****
   * Dbo tutorial section 4. Querying objects
   *****/

  {
    dbo::Transaction transaction(session);

    dbo::ptr<User> joe = session.find<User>().where("name = ?").bind("Joe");

    std::cerr << "Joe has karma: " << joe->karma << std::endl;

    dbo::ptr<User> joe2 = session.query< dbo::ptr<User> >
      ("select u from user u").where("name = ?").bind("Joe");
  }

  {
    dbo::Transaction transaction(session);

    typedef dbo::collection< dbo::ptr<User> > Users;

    Users users = session.find<User>();

    std::cerr << "We have " << users.size() << " users:" << std::endl;

    for (Users::const_iterator i = users.begin(); i != users.end(); ++i)
      std::cerr << " user " << (*i)->name
		<< " with karma of " << (*i)->karma << std::endl;
  }

  /*****
   * Dbo tutorial section 5. Updating objects
   *****/

  {
    dbo::Transaction transaction(session);

    dbo::ptr<User> joe = session.find<User>().where("name = ?").bind("Joe");

    joe.modify()->karma++;
    joe.modify()->password = "******";
  }

  {
    dbo::Transaction transaction(session);
    dbo::ptr<User> joe = session.find<User>().where("name = ?").bind("Joe");
    if (joe)
      joe.remove();
  }

  {
    dbo::Transaction transaction(session);

    dbo::ptr<User> silly = session.add(new User());
    silly.modify()->name = "Silly";
    silly.remove();
  }

}