Skip to content
Snippets Groups Projects
Commit 4b45734c authored by Jordi Inglada's avatar Jordi Inglada
Browse files

ENH: GISConnection becomes a concrete implementation for a bridge pattern

parent 662c75b4
No related branches found
No related tags found
No related merge requests found
......@@ -15,15 +15,15 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbGISConnection_cxx
#define __otbGISConnection_cxx
#ifndef __otbPostGISConnectionImplementation_cxx
#define __otbPostGISConnectionImplementation_cxx
#include "otbGISConnection.h"
#include "otbPostGISConnectionImplementation.h"
#include <sstream>
namespace otb
{
GISConnection::GISConnection()
PostGISConnectionImplementation::PostGISConnectionImplementation()
{
m_Host = "localhost";
m_DBName = "";
......@@ -35,12 +35,12 @@ GISConnection::GISConnection()
}
GISConnection::~GISConnection()
PostGISConnectionImplementation::~PostGISConnectionImplementation()
{
}
void GISConnection::ConnectToDB()
void PostGISConnectionImplementation::ConnectToDB()
{
std::stringstream connstring;
......@@ -55,20 +55,21 @@ void GISConnection::ConnectToDB()
if(m_Options!="")
connstring << " options=" << m_Options;
delete m_PostGISConnection;
if(! m_PostGISConnection )
delete m_PostGISConnection;
m_PostGISConnection = new BasicConnectionType(connstring.str().c_str());
}
void GISConnection::PerformTransaction(const TransactorType& theTransaction)
void PostGISConnectionImplementation::PerformTransaction(const TransactorType& theTransaction)
{
//m_PostGISConnection->perform( theTransaction() );
}
void GISConnection::PrintSelf(std::ostream& os, itk::Indent indent) const
void PostGISConnectionImplementation::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os,indent);
os<<std::endl;
......
......@@ -15,8 +15,8 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbGISConnection_h
#define __otbGISConnection_h
#ifndef __otbPostGISConnectionImplementation_h
#define __otbPostGISConnectionImplementation_h
#include "itkDataObject.h"
#include "itkObjectFactory.h"
......@@ -24,20 +24,20 @@
namespace otb
{
/** \class GISConnection
/** \class PostGISConnectionImplementation
* \brief this class represents a connection to a geospatial database (ie. PostGIS).
*
*
* \sa GISConnectionFileReader
* \sa GISConnectionFileWriter
* \sa PostGISConnectionImplementationFileReader
* \sa PostGISConnectionImplementationFileWriter
*
*/
class ITK_EXPORT GISConnection : public itk::DataObject
class ITK_EXPORT PostGISConnectionImplementation : public itk::DataObject
{
public:
/** Standard class typedefs */
typedef GISConnection Self;
typedef PostGISConnectionImplementation Self;
typedef itk::DataObject Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
......@@ -46,7 +46,7 @@ public:
/** Standard macros */
itkNewMacro(Self);
itkTypeMacro(GISConnection,itk::DataObject);
itkTypeMacro(PostGISConnectionImplementation,itk::DataObject);
/** Typedefs */
......@@ -82,14 +82,14 @@ public:
protected:
/** Constructor */
GISConnection();
PostGISConnectionImplementation();
/** Destructor */
virtual ~GISConnection();
virtual ~PostGISConnectionImplementation();
/** PrintSelf method */
void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
GISConnection(const Self&); //purposely not implemented
PostGISConnectionImplementation(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
......
......@@ -775,13 +775,13 @@ ENDIF(OTB_USE_MAPNIK)
# ---------------- PostGIS Interface ---------------------#
IF(OTB_USE_PQXX)
ADD_TEST(coTuGISConnectionNew ${COMMON_TESTS10}
otbGISConnectionNew
ADD_TEST(coTuPostGISConnectionImplementationNew ${COMMON_TESTS10}
otbPostGISConnectionImplementationNew
)
#This test need a runing PostGIS server on the localhost with trusted potgres user and an ecisting testgis base
ADD_TEST(coTvGISConnectionConnectToDB ${COMMON_TESTS10}
otbGISConnectionConnectToDB
ADD_TEST(coTvPostGISConnectionImplementationConnectToDB ${COMMON_TESTS10}
otbPostGISConnectionImplementationConnectToDB
localhost
testgis
postgres
......@@ -911,8 +911,8 @@ ENDIF(OTB_USE_MAPNIK)
IF(OTB_USE_PQXX)
SET(BasicCommon_SRCS10
otbGISConnectionNew.cxx
otbGISConnectionConnectToDB.cxx
otbPostGISConnectionImplementationNew.cxx
otbPostGISConnectionImplementationConnectToDB.cxx
otbGISTableNew.cxx
)
ENDIF(OTB_USE_PQXX)
......
......@@ -26,7 +26,7 @@
void RegisterTests()
{
REGISTER_TEST(otbGISConnectionNew);
REGISTER_TEST(otbGISConnectionConnectToDB);
REGISTER_TEST(otbPostGISConnectionImplementationNew);
REGISTER_TEST(otbPostGISConnectionImplementationConnectToDB);
REGISTER_TEST(otbGISTableNew);
}
......@@ -18,16 +18,16 @@
#include "itkExceptionObject.h"
#include "otbMacro.h"
#include "otbGISConnection.h"
#include "otbPostGISConnectionImplementation.h"
int otbGISConnectionConnectToDB(int argc, char * argv[])
int otbPostGISConnectionImplementationConnectToDB(int argc, char * argv[])
{
const std::string hostName = argv[1];
const std::string dbName = argv[2];
const std::string userName = argv[3];
typedef otb::GISConnection GISConnectionType;
typedef otb::PostGISConnectionImplementation GISConnectionType;
//Instantiation
GISConnectionType::Pointer connection = GISConnectionType::New();
......
......@@ -18,12 +18,12 @@
#include "itkExceptionObject.h"
#include "otbMacro.h"
#include "otbGISConnection.h"
#include "otbPostGISConnectionImplementation.h"
int otbGISConnectionNew(int argc, char * argv[])
int otbPostGISConnectionImplementationNew(int argc, char * argv[])
{
typedef otb::GISConnection GISConnectionType;
typedef otb::PostGISConnectionImplementation GISConnectionType;
//Instantiation
GISConnectionType::Pointer data = GISConnectionType::New();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment