Adding property to SQLite SessionImpl as solution for issue #248

This commit is contained in:
Cristian Thiago Moecke 2014-08-04 17:05:57 -03:00
parent 98db64fa04
commit 0ba87ea2c2
2 changed files with 19 additions and 0 deletions

View File

@ -117,6 +117,10 @@ public:
const std::string& connectorName() const;
/// Returns the name of the connector.
protected:
void setConnectionTimeout(const std::string& prop, const Poco::Any& value);
Poco::Any getConnectionTimeout(const std::string& prop);
private:
std::string _connector;
sqlite3* _pDB;

View File

@ -24,6 +24,7 @@
#include "Poco/String.h"
#include "Poco/Mutex.h"
#include "Poco/Data/DataException.h"
#include "Poco/NumberParser.h"
#include "sqlite3.h"
#include <cstdlib>
@ -51,6 +52,7 @@ SessionImpl::SessionImpl(const std::string& fileName, std::size_t loginTimeout):
addFeature("autoCommit",
&SessionImpl::autoCommit,
&SessionImpl::isAutoCommit);
addProperty("connectionTimeout", &SessionImpl::setConnectionTimeout, &SessionImpl::getConnectionTimeout);
}
@ -212,6 +214,19 @@ void SessionImpl::setConnectionTimeout(std::size_t timeout)
}
void SessionImpl::setConnectionTimeout(const std::string& prop, const Poco::Any& value)
{
int timeout = Poco::RefAnyCast<std::size_t>(value);
setConnectionTimeout(timeout);
}
Poco::Any SessionImpl::getConnectionTimeout(const std::string& prop)
{
return Poco::Any(_timeout/1000);
}
void SessionImpl::autoCommit(const std::string&, bool)
{
// The problem here is to decide whether to call commit or rollback