Skip to content
Snippets Groups Projects
Commit f9828fc9 authored by Steven Murray's avatar Steven Murray
Browse files

Made catalogue a SHARED library to encapsulate depedencies on occi and sqlite3

parent 63e14561
No related branches found
No related tags found
No related merge requests found
......@@ -26,16 +26,22 @@ set (CATALOGUE_LIB_SRC_FILES
DbLogin.cpp
DummyCatalogue.cpp
OcciConn.cpp
OcciEnv.cpp
OcciStmt.cpp
Sqlite.cpp
SqliteCatalogue.cpp
SqliteConn.cpp
SqliteStmt.cpp)
add_library (ctacatalogue
add_library (ctacatalogue SHARED
${CATALOGUE_LIB_SRC_FILES})
target_link_libraries (ctacatalogue
${ORACLE-INSTANTCLIENT_LIBRARIES}
${SQLITE_LIBRARIES})
set (CATALOGUE_UNIT_TESTS_LIB_SRC_FILES
OcciEnvTest.cpp
SqliteCatalogueTest.cpp
SqliteStmtTest.cpp)
......@@ -43,7 +49,6 @@ add_library (ctacatalogueunittests SHARED
${CATALOGUE_UNIT_TESTS_LIB_SRC_FILES})
target_link_libraries (ctacatalogueunittests
ctacatalogue
${SQLITE_LIBRARIES})
ctacatalogue)
install(TARGETS ctacatalogueunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
......@@ -34,7 +34,7 @@ namespace catalogue {
class OcciStmt;
/**
* A C++ wrapper around a connection to an OCCI database.
* A convenience wrapper around a connection to an OCCI database.
*/
class OcciConn {
public:
......
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "catalogue/OcciConn.hpp"
#include "common/exception/Exception.hpp"
#include <gtest/gtest.h>
#include <memory>
namespace unitTests {
class cta_catalogue_OcciConnTest : public ::testing::Test {
protected:
virtual void SetUp() {
}
virtual void TearDown() {
}
};
TEST_F(cta_catalogue_OcciConnTest, constructor) {
using namespace cta::catalogue;
// WARNING - The database whose connection details are specified in the
// following database configuration file will be destroyed
const std::string testDbConfigFile = "cta_catalogue_test_db.conf";
const DbLogin dbLogin = DbLogin::readFromFile(testDbConfigFile);
}
} // namespace unitTests
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "catalogue/OcciEnv.hpp"
#include "common/exception/Exception.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::catalogue::OcciEnv::OcciEnv() {
using namespace oracle::occi;
m_env = Environment::createEnvironment(Environment::THREADED_MUTEXED);
if(NULL == m_env) {
exception::Exception ex;
ex.getMessage() << __FUNCTION__ << " failed"
": createEnvironment() returned a NULL pointer";
throw ex;
}
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
cta::catalogue::OcciEnv::~OcciEnv() throw() {
using namespace oracle::occi;
Environment::terminateEnvironment(m_env);
}
//------------------------------------------------------------------------------
// get
//------------------------------------------------------------------------------
oracle::occi::Environment *cta::catalogue::OcciEnv::get() const {
return m_env;
}
//------------------------------------------------------------------------------
// operator->
//------------------------------------------------------------------------------
oracle::occi::Environment *cta::catalogue::OcciEnv::operator->() const {
return get();
}
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <occi.h>
namespace cta {
namespace catalogue {
/**
* A convenience wrapper around an OCCI environment.
*/
class OcciEnv {
public:
/**
* Constructor.
*
* Creates an OCCI environment with a THREADED_MUTEXED mode.
*/
OcciEnv();
/**
* Destructor.
*
* Terminates the underlying OCCI environment.
*/
~OcciEnv() throw();
/**
* Returns the underlying OCCI environment.
*
* @return The underlying OCCI environment.
*/
oracle::occi::Environment *get() const;
/**
* An alias for the get() method.
*
* @return The underlying OCCI environment.
*/
oracle::occi::Environment *operator->() const;
private:
/**
* The OCCI environment.
*/
oracle::occi::Environment *m_env;
}; // class OcciEnv
} // namespace catalogue
} // namespace cta
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "catalogue/OcciEnv.hpp"
#include <gtest/gtest.h>
#include <memory>
namespace unitTests {
class cta_catalogue_OcciEnvTest : public ::testing::Test {
protected:
virtual void SetUp() {
}
virtual void TearDown() {
}
};
TEST_F(cta_catalogue_OcciEnvTest, constructor) {
using namespace cta::catalogue;
OcciEnv env;
}
} // namespace unitTests
......@@ -35,7 +35,7 @@ namespace catalogue {
class OcciConn;
/**
* A C++ wrapper around an OCCI prepared statement.
* A convenience wrapper around an OCCI prepared statement.
*/
class OcciStmt {
public:
......
......@@ -32,7 +32,7 @@ namespace catalogue {
class SqliteStmt;
/**
* A C++ wrapper around a connection to an SQLite database.
* A convenience wrapper around a connection to an SQLite database.
*/
class SqliteConn {
public:
......
......@@ -35,7 +35,7 @@ namespace catalogue {
class SqliteConn;
/**
* A C++ wrapper around an SQLite prepared statement.
* A convenience wrapper around an SQLite prepared statement.
*/
class SqliteStmt {
public:
......
......@@ -24,11 +24,20 @@ find_path(ORACLE-INSTANTCLIENT_INCLUDE_DIRS
PATHS /usr/include/oracle/12.1/client64
NO_DEFAULT_PATH)
find_library(ORACLE-INSTANTCLIENT_LIBRARIES
find_library(ORACLE-INSTANTCLIENT_OCCI_LIBRARY
NAME occi
PATHS /usr/lib/oracle/12.1/client64/lib
NO_DEFAULT_PATH)
find_library(ORACLE-INSTANTCLIENT_CLNTSH_LIBRARY
NAME clntsh
PATHS /usr/lib/oracle/12.1/client64/lib
NO_DEFAULT_PATH)
set(ORACLE-INSTANTCLIENT_LIBRARIES
${ORACLE-INSTANTCLIENT_OCCI_LIBRARY}
${ORACLE-INSTANTCLIENT_CLNTSH_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(oracle-instantclient DEFAULT_MSG
ORACLE-INSTANTCLIENT_INCLUDE_DIRS ORACLE-INSTANTCLIENT_LIBRARIES)
......@@ -316,4 +316,120 @@
fun:_ZN6castor6server6Thread14pthread_runnerEPv
fun:start_thread
fun:clone
}
\ No newline at end of file
}
{
OCIEnvCreate_1
Memcheck:Cond
fun:__intel_sse2_strcpy
fun:lfvini1
fun:lfvinit
fun:kpummpin
fun:kpuenvcr
fun:OCIEnvCreate
fun:_ZN6oracle4occi11Environment17createEnvironmentENS1_4ModeEPvPFS3_S3_mEPFS3_S3_S3_mEPFvS3_S3_E
fun:_ZN3cta9catalogue7OcciEnvC1Ev
fun:_ZN9unitTests42cta_catalogue_OcciEnvTest_constructor_Test8TestBodyEv
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing4Test3RunEv
fun:_ZN7testing8TestInfo3RunEv
}
{
OCIEnvCreate_2
Memcheck:Cond
fun:__intel_sse2_strcpy
fun:slpmadp
fun:lpmapd
fun:lfvini1
fun:lfvinit
fun:kpummpin
fun:kpuenvcr
fun:OCIEnvCreate
fun:_ZN6oracle4occi11Environment17createEnvironmentENS1_4ModeEPvPFS3_S3_mEPFS3_S3_S3_mEPFvS3_S3_E
fun:_ZN3cta9catalogue7OcciEnvC1Ev
fun:_ZN9unitTests42cta_catalogue_OcciEnvTest_constructor_Test8TestBodyEv
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
}
{
OCIEnvCreate_3
Memcheck:Cond
fun:__intel_sse2_strcpy
fun:slpmadp
fun:lpmapd
fun:lfvini1
fun:lfvinit
fun:kpummpin
fun:kpuenvcr
fun:OCIEnvCreate
fun:_ZN6oracle4occi11Environment17createEnvironmentENS1_4ModeEPvPFS3_S3_mEPFS3_S3_S3_mEPFvS3_S3_E
fun:_ZN3cta9catalogue7OcciEnvC1Ev
fun:_ZN9unitTests42cta_catalogue_OcciEnvTest_constructor_Test8TestBodyEv
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
}
{
OCIEnvCreate_4
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:slzsetevar
fun:lfvSetOHome
fun:slpmloclfv
fun:slpmloc
fun:lpmloadpkg
fun:lfvini1
fun:lfvinit
fun:kpummpin
fun:kpuenvcr
fun:OCIEnvCreate
fun:_ZN6oracle4occi11Environment17createEnvironmentENS1_4ModeEPvPFS3_S3_mEPFS3_S3_S3_mEPFvS3_S3_E
}
{
oracle_misc_1
Memcheck:Leak
match-leak-kinds: possible
fun:malloc
fun:ssMemMalloc
fun:sltsmxi
fun:lmmhpinit
fun:lmmcis
fun:lpmpali
fun:lpminitm
fun:lpminit
fun:lfvini1
fun:lfvinit
fun:kpummpin
fun:kpuenvcr
}
{
OCIEnvCreate_5
Memcheck:Leak
match-leak-kinds: possible
fun:malloc
fun:ssMemMalloc
fun:sltsmxi
fun:lmmhpinit
fun:lmmcis
fun:lpmpali
fun:lpmloadpkg
fun:lfvini1
fun:lfvinit
fun:kpummpin
fun:kpuenvcr
fun:OCIEnvCreate
}
{
oracle_misc_2
Memcheck:Leak
match-leak-kinds: possible
fun:calloc
fun:ssMemCalloc
fun:slwmmgetmem
fun:lmmstvrt
fun:lmmstchnk
fun:lmmstsml
fun:lmmstmalloc
fun:lmmmalloc
fun:lmmcis
fun:lpmpali
fun:lpminitm
fun:lpminit
}
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