Commit dbebcad9 authored by David Moxey's avatar David Moxey

Remove Loki as a dependency of Nektar++

Switch to a simple static member function to implement singletons, which is guaranteed to be thread-safe in C++11.
parent c094be96
......@@ -222,7 +222,6 @@ ENDIF ()
# Find ThirdParty libraries and headers.
INCLUDE (ThirdPartyTinyxml)
INCLUDE (ThirdPartyLoki)
INCLUDE (ThirdPartyMetis)
INCLUDE (ThirdPartyHDF5)
INCLUDE (ThirdPartyScotch)
......
......@@ -50,10 +50,6 @@ SET(Boost_LIBRARY_DIRS "@Boost_CONFIG_LIBRARY_DIR@")
SET(NEKTAR++_TP_LIBRARIES
${NEKTAR++_TP_LIBRARIES} ${Boost_LIBRARIES})
SET(LOKI_INCLUDE_DIRS "@LOKI_CONFIG_INCLUDE_DIR@")
SET(NEKTAR++_TP_INCLUDE_DIRS
${NEKTAR++_TP_INCLUDE_DIRS} ${LOKI_INCLUDE_DIRS})
SET(TINYXML_INCLUDE_DIRS "@TINYXML_CONFIG_INCLUDE_DIR@")
SET(NEKTAR++_TP_INCLUDE_DIRS
${NEKTAR++_TP_INCLUDE_DIRS} ${TINYXML_INCLUDE_DIRS})
......
########################################################################
#
# ThirdParty configuration for Nektar++
#
# Loki headers library
#
########################################################################
# Try to find system Loki headers. Hint /opt/local/include for MacPorts
# (although there is no Portfile for Loki currently).
FIND_PATH(LOKI_INCLUDE_DIR loki/Singleton.h PATHS /opt/local/include)
IF (LOKI_INCLUDE_DIR)
SET(BUILD_LOKI OFF)
ELSE()
SET(BUILD_LOKI ON)
ENDIF()
OPTION(THIRDPARTY_BUILD_LOKI
"Download and extract Loki library to ThirdParty." ${BUILD_LOKI})
IF (THIRDPARTY_BUILD_LOKI)
# Download Loki if it doesn't already exist.
IF (NOT EXISTS ${TPSRC}/loki-0.1.3.tar.bz2)
FILE(DOWNLOAD ${TPURL}/loki-0.1.3.tar.bz2 ${TPSRC}/loki-0.1.3.tar.bz2)
ENDIF()
# TODO: Check hashes.
# Extract.
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -E tar jxf ${TPSRC}/loki-0.1.3.tar.bz2
WORKING_DIRECTORY ${TPSRC}
)
# Set LOKI_INCLUDE_DIR.
FILE(COPY ${TPSRC}/loki-0.1.3/include/loki/ DESTINATION ${TPDIST}/include/loki/)
SET(LOKI_INCLUDE_DIR ${TPDIST}/include CACHE PATH "" FORCE)
MESSAGE(STATUS "Build Loki: ${LOKI_INCLUDE_DIR}")
SET(LOKI_CONFIG_INCLUDE_DIR ${TPINC})
ELSE()
MESSAGE(STATUS "Found Loki: ${LOKI_INCLUDE_DIR}")
SET(LOKI_CONFIG_INCLUDE_DIR ${LOKI_INCLUDE_DIR})
ENDIF()
INCLUDE_DIRECTORIES(SYSTEM ${LOKI_INCLUDE_DIR})
MARK_AS_ADVANCED(LOKI_INCLUDE_DIR)
......@@ -640,10 +640,6 @@ automatically built during the \nekpp build process. Below are the choices of X:
(MPI-only) Parallel communication library.
\item \inlsh{LOKI}
An implementation of a singleton.
\item \inlsh{METIS}
A graph partitioning library used for substructuring of matrices and mesh
......
......@@ -33,7 +33,6 @@
//
///////////////////////////////////////////////////////////////////////////////
#include <loki/Singleton.h>
#include <Collections/Operator.h>
#include <Collections/Collection.h>
......
......@@ -33,7 +33,6 @@
//
///////////////////////////////////////////////////////////////////////////////
#include <loki/Singleton.h>
#include <Collections/Operator.h>
#include <Collections/Collection.h>
#include <Collections/IProduct.h>
......
......@@ -33,7 +33,6 @@
//
///////////////////////////////////////////////////////////////////////////////
#include <loki/Singleton.h>
#include <Collections/Operator.h>
#include <Collections/Collection.h>
#include <Collections/IProduct.h>
......
......@@ -33,7 +33,6 @@
//
///////////////////////////////////////////////////////////////////////////////
#include <loki/Singleton.h>
#include <Collections/Operator.h>
#include <Collections/Collection.h>
......@@ -107,13 +106,10 @@ Operator::~Operator()
/**
*
*/
OperatorFactory& GetOperatorFactory()
static OperatorFactory& GetOperatorFactory()
{
typedef Loki::SingletonHolder<OperatorFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
static OperatorFactory instance;
return instance;
}
......
......@@ -33,7 +33,6 @@
//
///////////////////////////////////////////////////////////////////////////////
#include <loki/Singleton.h>
#include <Collections/Operator.h>
#include <Collections/Collection.h>
......
......@@ -43,6 +43,4 @@
#define FIELD_UTILS_EXPORT
#endif
#define LOKI_CLASS_LEVEL_THREADING
#endif // NEKTAR_FIELD_UTILS_DECLSPEC_H
......@@ -46,12 +46,10 @@ namespace FieldUtils
/**
* Returns an instance of the module factory, held as a singleton.
*/
ModuleFactory &GetModuleFactory()
static ModuleFactory &GetModuleFactory()
{
typedef Loki::SingletonHolder<ModuleFactory, Loki::CreateUsingNew,
Loki::NoDestroy, Loki::SingleThreaded>
Type;
return Type::Instance();
static ModuleFactory instance;
return instance;
}
/**
......
......@@ -46,12 +46,10 @@ MappingSharedPtr Mapping::m_mappingPtr = MappingSharedPtr();
bool Mapping::m_init = false;
bool Mapping::m_isDefined = false;
MappingFactory& GetMappingFactory()
static MappingFactory& GetMappingFactory()
{
typedef Loki::SingletonHolder<MappingFactory,
Loki::CreateUsingNew,
Loki::NoDestroy > Type;
return Type::Instance();
static MappingFactory instance;
return instance;
}
Mapping::Mapping(const LibUtilities::SessionReaderSharedPtr& pSession,
......
......@@ -43,8 +43,6 @@
#include <LibUtilities/BasicUtils/FieldIO.h>
#include <LibUtilities/BasicUtils/FileSystem.h>
#include <loki/Singleton.h>
#include <fstream>
#include <set>
......@@ -73,10 +71,8 @@ std::string fldCmdFormat = SessionReader::RegisterCmdLineArgument(
*/
FieldIOFactory &GetFieldIOFactory()
{
typedef Loki::
SingletonHolder<FieldIOFactory, Loki::CreateUsingNew, Loki::NoDestroy,
Loki::ClassLevelLockable> Type;
return Type::Instance();
static FieldIOFactory instance;
return instance;
}
/// Enumerator for auto-detection of FieldIO types.
......
......@@ -69,11 +69,8 @@ namespace Nektar
{
MeshPartitionFactory& GetMeshPartitionFactory()
{
typedef Loki::SingletonHolder<MeshPartitionFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
static MeshPartitionFactory instance;
return instance;
}
MeshPartition::MeshPartition(const LibUtilities::SessionReaderSharedPtr& pSession) :
......
......@@ -48,11 +48,8 @@ namespace Thread
*/
ThreadManagerFactory& GetThreadManagerFactory()
{
typedef Loki::SingletonHolder<ThreadManagerFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
static ThreadManagerFactory instance;
return instance;
}
/**
......@@ -142,11 +139,8 @@ ThreadMaster::~ThreadMaster()
*/
ThreadMaster& GetThreadMaster()
{
typedef Loki::SingletonHolder<ThreadMaster,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
static ThreadMaster instance;
return instance;
}
......
......@@ -45,7 +45,6 @@
#include <boost/enable_shared_from_this.hpp>
#include <LibUtilities/BasicUtils/NekFactory.hpp>
#include <loki/Singleton.h>
namespace Nektar
{
......
......@@ -34,7 +34,6 @@
///////////////////////////////////////////////////////////////////////////////
#include <LibUtilities/Communication/Comm.h>
#include <loki/Singleton.h> // for CreateUsingNew, NoDestroy, etc
namespace Nektar
{
......@@ -60,10 +59,8 @@ bool Comm::v_RemoveExistingFiles(void)
CommFactory &GetCommFactory()
{
typedef Loki::SingletonHolder<CommFactory, Loki::CreateUsingNew,
Loki::NoDestroy, Loki::SingleThreaded>
Type;
return Type::Instance();
static CommFactory instance;
return instance;
}
}
}
......@@ -34,7 +34,6 @@
///////////////////////////////////////////////////////////////////////////////
#include <LibUtilities/FFT/NektarFFT.h>
#include <loki/Singleton.h> // for CreateUsingNew, NoDestroy, etc
namespace Nektar
{
......@@ -68,11 +67,8 @@ namespace Nektar
NektarFFTFactory& GetNektarFFTFactory()
{
typedef Loki::SingletonHolder<NektarFFTFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::ClassLevelLockable> Type;
return Type::Instance();
static NektarFFTFactory instance;
return instance;
}
/**
......
......@@ -33,7 +33,6 @@
//
///////////////////////////////////////////////////////////////////////////////
#include <loki/Singleton.h>
#include <LibUtilities/Foundations/GaussPoints.h>
#include <LibUtilities/Foundations/FourierPoints.h>
#include <LibUtilities/Foundations/FourierSingleModePoints.h>
......@@ -109,12 +108,14 @@ namespace Nektar
PointsManagerT &PointsManager(void)
{
return Loki::SingletonHolder<PointsManagerT>::Instance();
static PointsManagerT instance;
return instance;
}
BasisManagerT &BasisManager(void)
{
return Loki::SingletonHolder<BasisManagerT>::Instance();
static BasisManagerT instance;
return instance;
}
} // end of namespace LibUtilities
......
......@@ -42,16 +42,6 @@
#include <boost/algorithm/string/trim.hpp>
#include <boost/random/detail/seed.hpp>
#ifdef _MSC_VER
#include <boost/preprocessor/cat.hpp>
#endif //MSC_VER
#ifdef _MSC_VER
#define NEKTAR_MATH_NAME(x) BOOST_PP_CAT(_, x)
#else
#define NEKTAR_MATH_NAME(x) x
#endif
#if( BOOST_VERSION / 100 % 1000 >= 36 )
using namespace boost::spirit::classic;
#else
......
......@@ -43,7 +43,5 @@
#define LIB_UTILITIES_EXPORT
#endif
#define LOKI_CLASS_LEVEL_THREADING
#endif //NEKTAR__LIB_UTILITIES_LIB_UTILITIES_DECLSPEC_H
......@@ -36,10 +36,7 @@ namespace Nektar
{
MemPool& GetMemoryPool()
{
typedef Loki::SingletonHolder<MemPool ,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
static MemPool instance;
return instance;
}
}
......@@ -42,7 +42,6 @@
#include <boost/pool/pool.hpp>
#include <boost/thread/mutex.hpp>
#include <loki/Singleton.h>
#include <map>
#include <LibUtilities/BasicUtils/ErrorUtil.hpp>
#include <LibUtilities/LibUtilitiesDeclspec.h>
......
......@@ -44,9 +44,9 @@ namespace Nektar
{
TimeIntegrationSchemeManagerT &TimeIntegrationSchemeManager(void)
{
TimeIntegrationSchemeManagerT& m = Loki::SingletonHolder<TimeIntegrationSchemeManagerT>::Instance();
m.RegisterGlobalCreator(TimeIntegrationScheme::Create);
return m;
static TimeIntegrationSchemeManagerT instance;
instance.RegisterGlobalCreator(TimeIntegrationScheme::Create);
return instance;
}
......@@ -1862,4 +1862,4 @@ namespace Nektar
return os;
}
}
}
\ No newline at end of file
}
......@@ -41,11 +41,8 @@ namespace LibUtilities {
TimeIntegrationWrapperFactory &GetTimeIntegrationWrapperFactory()
{
typedef Loki::SingletonHolder<TimeIntegrationWrapperFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
static TimeIntegrationWrapperFactory instance;
return instance;
}
TimeIntegrationWrapper::TimeIntegrationWrapper()
......
......@@ -43,7 +43,5 @@
#define LOCAL_REGIONS_EXPORT
#endif
#define LOKI_CLASS_LEVEL_THREADING
#endif //NEKTAR_STD_REGIONS_DECLSPEC_H
......@@ -203,11 +203,8 @@ namespace Nektar
*/
GlobalLinSysFactory& GetGlobalLinSysFactory()
{
typedef Loki::SingletonHolder<GlobalLinSysFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
static GlobalLinSysFactory instance;
return instance;
}
/**
......
......@@ -43,7 +43,5 @@
#define MULTI_REGIONS_EXPORT
#endif
#define LOKI_CLASS_LEVEL_THREADING
#endif //NEKTAR_MULTI_REGIONS_DECLSPEC_H
......@@ -87,11 +87,8 @@ namespace Nektar
*/
PreconFactory& GetPreconFactory()
{
typedef Loki::SingletonHolder<PreconFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
static PreconFactory instance;
return instance;
}
void Preconditioner::v_InitObject()
......
......@@ -47,34 +47,26 @@ namespace NekMeshUtils
EngineFactory &GetEngineFactory()
{
typedef Loki::SingletonHolder<EngineFactory, Loki::CreateUsingNew,
Loki::NoDestroy, Loki::SingleThreaded>
Type;
return Type::Instance();
static EngineFactory instance;
return instance;
}
CADVertFactory &GetCADVertFactory()
{
typedef Loki::SingletonHolder<CADVertFactory, Loki::CreateUsingNew,
Loki::NoDestroy, Loki::SingleThreaded>
Type;
return Type::Instance();
static CADVertFactory instance;
return instance;
}
CADCurveFactory &GetCADCurveFactory()
{
typedef Loki::SingletonHolder<CADCurveFactory, Loki::CreateUsingNew,
Loki::NoDestroy, Loki::SingleThreaded>
Type;
return Type::Instance();
static CADCurveFactory instance;
return instance;
}
CADSurfFactory &GetCADSurfFactory()
{
typedef Loki::SingletonHolder<CADSurfFactory, Loki::CreateUsingNew,
Loki::NoDestroy, Loki::SingleThreaded>
Type;
return Type::Instance();
static CADSurfFactory instance;
return instance;
}
Array<OneD, NekDouble> CADSystem::GetPeriodicTranslationVector(int first,
......
......@@ -33,8 +33,6 @@
//
////////////////////////////////////////////////////////////////////////////////
#include <loki/Singleton.h>
#include <NekMeshUtils/MeshElements/Element.h>
using namespace std;
......@@ -46,9 +44,8 @@ namespace NekMeshUtils
ElementFactory &GetElementFactory()
{
typedef Loki::SingletonHolder<ElementFactory, Loki::CreateUsingNew,
Loki::NoDestroy> Type;
return Type::Instance();
static ElementFactory instance;
return instance;
}
Element::Element(ElmtConfig pConf, unsigned int pNumNodes,
......
......@@ -50,11 +50,8 @@ namespace NekMeshUtils
*/
ModuleFactory& GetModuleFactory()
{
typedef Loki::SingletonHolder<ModuleFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
static ModuleFactory instance;
return instance;
}
/**
......
......@@ -43,6 +43,4 @@
#define NEKMESHUTILS_EXPORT
#endif
#define LOKI_CLASS_LEVEL_THREADING
#endif //NEKTAR_SOLVER_UTILS_DECLSPEC_H
......@@ -45,11 +45,8 @@ namespace SolverUtils
*/
AdvectionFactory& GetAdvectionFactory()
{
typedef Loki::SingletonHolder<AdvectionFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
static AdvectionFactory instance;
return instance;
}
......
......@@ -41,11 +41,8 @@ namespace Nektar
{
DiffusionFactory& GetDiffusionFactory()
{
typedef Loki::SingletonHolder<DiffusionFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
static DiffusionFactory instance;
return instance;
}
void Diffusion::InitObject(
......
......@@ -65,11 +65,8 @@ std::string Driver::driverDefault =
DriverFactory& GetDriverFactory()
{
typedef Loki::SingletonHolder<DriverFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
static DriverFactory instance;
return instance;
}
/**
......
......@@ -82,11 +82,8 @@ namespace Nektar
*/
EquationSystemFactory& GetEquationSystemFactory()
{
typedef Loki::SingletonHolder<EquationSystemFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::ClassLevelLockable> Type;
return Type::Instance();
static EquationSystemFactory instance;
return instance;
}
/**
......
......@@ -41,11 +41,8 @@ namespace SolverUtils
{
FilterFactory& GetFilterFactory()
{
typedef Loki::SingletonHolder<FilterFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
static FilterFactory instance;
return instance;
}
......
......@@ -43,11 +43,8 @@ namespace Nektar
{
ForcingFactory& GetForcingFactory()
{
typedef Loki::SingletonHolder<ForcingFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
static ForcingFactory instance;
return instance;
}
Forcing::Forcing(const LibUtilities::SessionReaderSharedPtr& pSession)
......
......@@ -33,7 +33,6 @@
//
///////////////////////////////////////////////////////////////////////////////
#define LOKI_CLASS_LEVEL_THREADING
#include <LibUtilities/BasicUtils/VmathArray.hpp>
#include <SolverUtils/RiemannSolvers/RiemannSolver.h>
......@@ -62,11 +61,8 @@ namespace Nektar
*/
RiemannSolverFactory& GetRiemannSolverFactory()
{
typedef Loki::SingletonHolder<RiemannSolverFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
static RiemannSolverFactory instance;
return instance;
}
/**
......
......@@ -43,7 +43,5 @@
#define SOLVER_UTILS_EXPORT
#endif
#define LOKI_CLASS_LEVEL_THREADING
#endif //NEKTAR_SOLVER_UTILS_DECLSPEC_H
......@@ -43,7 +43,5 @@
#define SPATIAL_DOMAINS_EXPORT
#endif
#define LOKI_CLASS_LEVEL_THREADING
#endif //NEKTAR_SPATIAL_DOMAINS_DECLSPEC_H
......@@ -43,7 +43,5 @@
#define STD_REGIONS_EXPORT
#endif
#define LOKI_CLASS_LEVEL_THREADING
#endif //NEKTAR_STD_REGIONS_DECLSPEC_H
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="UnitTests"
ProjectGUID="{90C99C49-729A-4563-95FF-E324AE79F26E}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="loki.lib"
OutputFile="$(OutDir)/UnitTests.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/UnitTests.pdb"