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

OracleCatalogue.cpp is only compiled if OCCI is to be used

parent 7b2988f1
Branches
Tags
No related merge requests found
......@@ -20,15 +20,15 @@ set (OCCI_SUPPORT ON)
# Switch OCCI support off if using gcc 5.1 or higher
if (CMAKE_COMPILER_IS_GNUCC)
if (GCC_VERSION VERSION_GREATER 5.0)
message(STATUS "Detected gcc >= 5.1 - Switching off OCCI support")
set (OCCI_SUPPORT OFF)
endif (GCC_VERSION VERSION_GREATER 5.0)
if (GCC_VERSION VERSION_GREATER 5.0)
message(STATUS "Detected gcc >= 5.1 - Switching off OCCI support")
set (OCCI_SUPPORT OFF)
endif (GCC_VERSION VERSION_GREATER 5.0)
endif (CMAKE_COMPILER_IS_GNUCC)
if(OCCI_SUPPORT)
find_package (oracle-instantclient REQUIRED)
include_directories (${ORACLE-INSTANTCLIENT_INCLUDE_DIRS})
find_package (oracle-instantclient REQUIRED)
include_directories (${ORACLE-INSTANTCLIENT_INCLUDE_DIRS})
endif(OCCI_SUPPORT)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
......@@ -37,17 +37,26 @@ set (CATALOGUE_LIB_SRC_FILES
ArchiveFileRow.cpp
ArchiveFileItor.cpp
Catalogue.cpp
CatalogueFactory.cpp
CmdLineTool.cpp
InMemoryCatalogue.cpp
SqliteCatalogueSchema.cpp
OracleCatalogue.cpp
TapeFileWritten.cpp
RdbmsCatalogue.cpp
SchemaCreatingSqliteCatalogue.cpp
SqliteCatalogue.cpp
TapeForWriting.cpp)
if (OCCI_SUPPORT)
set (CATALOGUE_LIB_SRC_FILES
${CATALOGUE_LIB_SRC_FILES}
CatalogueFactory.cpp
OracleCatalogue.cpp)
else (OCCI_SUPPORT)
set (CATALOGUE_LIB_SRC_FILES
${CATALOGUE_LIB_SRC_FILES}
CatalogueFactory_OCCI_SUPPORT_OFF.cpp)
endif (OCCI_SUPPORT)
add_library (ctacatalogue SHARED
${CATALOGUE_LIB_SRC_FILES})
......
/*
* 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/CatalogueFactory.hpp"
#include "catalogue/InMemoryCatalogue.hpp"
#include "catalogue/SqliteCatalogue.hpp"
#include "common/exception/Exception.hpp"
#include "common/make_unique.hpp"
namespace cta {
namespace catalogue {
//------------------------------------------------------------------------------
// create
//------------------------------------------------------------------------------
std::unique_ptr<Catalogue> CatalogueFactory::create(const rdbms::Login &login, const uint64_t nbConns) {
try {
switch(login.dbType) {
case rdbms::Login::DBTYPE_IN_MEMORY:
return cta::make_unique<InMemoryCatalogue>(nbConns);
case rdbms::Login::DBTYPE_ORACLE:
throw exception::Exception("OCCI support disabled at compile time");
case rdbms::Login::DBTYPE_SQLITE:
return cta::make_unique<SqliteCatalogue>(login.database, nbConns);
case rdbms::Login::DBTYPE_NONE:
throw exception::Exception("Cannot create a catalogue without a database type");
default:
{
exception::Exception ex;
ex.getMessage() << "Unknown database type: value=" << login.dbType;
throw ex;
}
}
} catch(exception::Exception &ex) {
throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str());
}
}
} // namespace catalogue
} // namespace cta
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment