- better usage of mapnik::singleton instance in occi datasource
- occi small cosmetics
This commit is contained in:
parent
40c01fd0ed
commit
206a563e0c
4 changed files with 32 additions and 44 deletions
|
@ -120,7 +120,7 @@ occi_datasource::occi_datasource(parameters const& params)
|
|||
{
|
||||
try
|
||||
{
|
||||
pool_ = occi_environment::create_pool(
|
||||
pool_ = occi_environment::instance().create_pool(
|
||||
*params.get<std::string>("user"),
|
||||
*params.get<std::string>("password"),
|
||||
*params.get<std::string>("host"),
|
||||
|
@ -137,7 +137,7 @@ occi_datasource::occi_datasource(parameters const& params)
|
|||
{
|
||||
try
|
||||
{
|
||||
conn_ = occi_environment::create_connection(
|
||||
conn_ = occi_environment::instance().create_connection(
|
||||
*params.get<std::string>("user"),
|
||||
*params.get<std::string>("password"),
|
||||
*params.get<std::string>("host"));
|
||||
|
@ -324,14 +324,14 @@ occi_datasource::~occi_datasource()
|
|||
{
|
||||
if (pool_ != 0)
|
||||
{
|
||||
occi_environment::destroy_pool(pool_);
|
||||
occi_environment::instance().destroy_pool(pool_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (conn_ != 0)
|
||||
{
|
||||
occi_environment::destroy_connection(conn_);
|
||||
occi_environment::instance().destroy_connection(conn_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,8 +132,6 @@ feature_ptr occi_featureset::next()
|
|||
}
|
||||
}
|
||||
|
||||
++feature_id_;
|
||||
|
||||
std::vector<MetaData> listOfColumns = rs_->getColumnListMetaData();
|
||||
|
||||
for (unsigned int i = 1; i < listOfColumns.size(); ++i)
|
||||
|
@ -233,6 +231,8 @@ feature_ptr occi_featureset::next()
|
|||
}
|
||||
}
|
||||
|
||||
++feature_id_;
|
||||
|
||||
return feature;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
|
||||
#include "occi_types.hpp"
|
||||
|
||||
oracle::occi::Environment* occi_environment::env_ = 0;
|
||||
|
||||
std::string occi_enums::resolve_gtype(int gtype)
|
||||
{
|
||||
switch (gtype)
|
||||
|
|
|
@ -27,6 +27,11 @@
|
|||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/utils.hpp>
|
||||
|
||||
// boost
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#endif
|
||||
|
||||
// occi
|
||||
#include <occi.h>
|
||||
|
||||
|
@ -84,42 +89,27 @@ class occi_environment : public mapnik::singleton<occi_environment, mapnik::Crea
|
|||
|
||||
public:
|
||||
|
||||
static oracle::occi::Environment* get_environment()
|
||||
oracle::occi::Environment* get_environment()
|
||||
{
|
||||
if (env_ == 0)
|
||||
{
|
||||
MAPNIK_LOG_DEBUG(occi) << "occi_environment: constructor";
|
||||
|
||||
const int mode = oracle::occi::Environment::OBJECT
|
||||
| oracle::occi::Environment::THREADED_MUTEXED;
|
||||
|
||||
env_ = oracle::occi::Environment::createEnvironment((oracle::occi::Environment::Mode) mode);
|
||||
RegisterClasses(env_);
|
||||
}
|
||||
|
||||
return env_;
|
||||
}
|
||||
|
||||
static oracle::occi::Connection* create_connection(
|
||||
oracle::occi::Connection* create_connection(
|
||||
const std::string& user,
|
||||
const std::string& password,
|
||||
const std::string& host)
|
||||
{
|
||||
oracle::occi::Environment* env = get_environment();
|
||||
|
||||
MAPNIK_LOG_DEBUG(occi) << "occi_environment: create_connection";
|
||||
|
||||
return env->createConnection(user, password, host);
|
||||
return env_->createConnection(user, password, host);
|
||||
}
|
||||
|
||||
static void destroy_connection(oracle::occi::Connection* conn)
|
||||
void destroy_connection(oracle::occi::Connection* conn)
|
||||
{
|
||||
oracle::occi::Environment* env = get_environment();
|
||||
|
||||
env->terminateConnection(conn);
|
||||
env_->terminateConnection(conn);
|
||||
}
|
||||
|
||||
static oracle::occi::StatelessConnectionPool* create_pool(
|
||||
oracle::occi::StatelessConnectionPool* create_pool(
|
||||
const std::string& user,
|
||||
const std::string& password,
|
||||
const std::string& host,
|
||||
|
@ -127,11 +117,9 @@ public:
|
|||
int initial_size,
|
||||
int incr_size)
|
||||
{
|
||||
oracle::occi::Environment* env = get_environment();
|
||||
|
||||
MAPNIK_LOG_DEBUG(occi) << "occi_environment: create_pool";
|
||||
|
||||
return env->createStatelessConnectionPool(
|
||||
return env_->createStatelessConnectionPool(
|
||||
user,
|
||||
password,
|
||||
host,
|
||||
|
@ -141,11 +129,9 @@ public:
|
|||
oracle::occi::StatelessConnectionPool::HOMOGENEOUS);
|
||||
}
|
||||
|
||||
static void destroy_pool(oracle::occi::StatelessConnectionPool* pool)
|
||||
void destroy_pool(oracle::occi::StatelessConnectionPool* pool)
|
||||
{
|
||||
oracle::occi::Environment* env = get_environment();
|
||||
|
||||
env->terminateStatelessConnectionPool(
|
||||
env_->terminateStatelessConnectionPool(
|
||||
pool,
|
||||
oracle::occi::StatelessConnectionPool::SPD_FORCE);
|
||||
}
|
||||
|
@ -153,21 +139,25 @@ public:
|
|||
private:
|
||||
|
||||
occi_environment()
|
||||
: env_(0)
|
||||
{
|
||||
MAPNIK_LOG_DEBUG(occi) << "occi_environment: constructor";
|
||||
|
||||
env_ = oracle::occi::Environment::createEnvironment(
|
||||
(oracle::occi::Environment::Mode)(oracle::occi::Environment::OBJECT
|
||||
| oracle::occi::Environment::THREADED_MUTEXED));
|
||||
RegisterClasses(env_);
|
||||
}
|
||||
|
||||
~occi_environment()
|
||||
{
|
||||
if (env_)
|
||||
{
|
||||
MAPNIK_LOG_DEBUG(occi) << "occi_environment: destructor";
|
||||
MAPNIK_LOG_DEBUG(occi) << "occi_environment: destructor";
|
||||
|
||||
oracle::occi::Environment::terminateEnvironment(env_);
|
||||
env_ = 0;
|
||||
}
|
||||
oracle::occi::Environment::terminateEnvironment(env_);
|
||||
env_ = 0;
|
||||
}
|
||||
|
||||
static oracle::occi::Environment* env_;
|
||||
oracle::occi::Environment* env_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -252,7 +242,7 @@ private:
|
|||
{
|
||||
if (owns_connection_)
|
||||
{
|
||||
occi_environment::destroy_connection(conn_);
|
||||
occi_environment::instance().destroy_connection(conn_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue