Fixed saving/loading dictionary (not loaded words)

git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@676 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
matlabbe
2012-12-12 16:40:18 +00:00
parent aab425e583
commit bb2fbc67e0
6 changed files with 207 additions and 73 deletions
+31 -2
View File
@@ -178,7 +178,7 @@ void DBDriver::emptyTrashes(bool async)
if(this->isConnected())
{
//Only one query to the database
this->saveQuery(uValues(visualWords));
this->saveOrUpdate(uValues(visualWords));
}
for(std::map<int, VisualWord *>::iterator iter=visualWords.begin(); iter!=visualWords.end(); ++iter)
@@ -223,7 +223,6 @@ void DBDriver::asyncSave(VisualWord * vw)
}
}
//Automatically begin and commit a transaction
void DBDriver::saveOrUpdate(const std::vector<Signature *> & signatures) const
{
ULOGGER_DEBUG("");
@@ -254,6 +253,36 @@ void DBDriver::saveOrUpdate(const std::vector<Signature *> & signatures) const
}
}
void DBDriver::saveOrUpdate(const std::vector<VisualWord *> & words) const
{
ULOGGER_DEBUG("");
std::list<VisualWord *> toSave;
std::list<VisualWord *> toUpdate;
if(this->isConnected() && words.size())
{
for(std::vector<VisualWord *>::const_iterator i=words.begin(); i!=words.end();++i)
{
if((*i)->isSaved())
{
toUpdate.push_back(*i);
}
else
{
toSave.push_back(*i);
}
}
if(toUpdate.size())
{
this->updateQuery(toUpdate);
}
if(toSave.size())
{
this->saveQuery(toSave);
}
}
}
void DBDriver::load(VWDictionary * dictionary) const
{
_dbSafeAccessMutex.lock();