Commit fa4617b2 authored by Tristan Matthews's avatar Tristan Matthews

Merge branch 'master' of...

Merge branch 'master' of git+ssh://git.sflphone.org/var/repos/sflphone/git/sflphone into video_preview

Resolved Conflicts:
	daemon/src/account.h
	daemon/src/audio/codecs/celtcodec.cpp
	daemon/src/audio/pulseaudio/pulselayer.cpp
	daemon/src/config/sfl_config.cpp
	daemon/src/config/yamlemitter.cpp
	daemon/src/config/yamlemitter.h
	daemon/src/config/yamlparser.cpp
	daemon/src/main.cpp
	daemon/src/preferences.cpp
	daemon/src/preferences.h
	daemon/src/sip/sdp.cpp
	daemon/src/sip/sdp.h
	daemon/src/sip/sipaccount.cpp
	daemon/src/sip/sipvoiplink.cpp
	daemon/test/audiolayertest.h
	daemon/test/gaincontroltest.cpp
	daemon/test/sdptest.cpp
	gnome/configure.ac
	gnome/src/dbus/dbus.c
parents d47564e8 d3bb0daf
...@@ -51,8 +51,6 @@ Short description of content of source tree ...@@ -51,8 +51,6 @@ Short description of content of source tree
------------------------------------------- -------------------------------------------
- ringtones/ contains the different ringtones. - ringtones/ contains the different ringtones.
- stund/ is an implementation of the protocol STUN used when there is a NAT.
- utilspp/ allows to implement a singleton.
- src/ is the core of SFLphone. It contains the main.cpp, managerimpl.cpp - src/ is the core of SFLphone. It contains the main.cpp, managerimpl.cpp
files, audio and gui directories, and files about signalisation SIP. Later, files, audio and gui directories, and files about signalisation SIP. Later,
it should be better, when IAX will be implemented, that a directory groups it should be better, when IAX will be implemented, that a directory groups
......
emerge commoncpp2
# editer /usr/lib/pkgconfig/libccext2.pc pour le includedir -> /usr/include/
ACCEPT_KEYWORDS=~x86 emerge ccrtp
emerge libosip
ACCEPT_KEYWORDS=~x86 emerge libeXosip
emerge libsamplerate
emerge cvs
emerge =qt-3.3.6-r1
cvs ...
cd tools/
portaudio.sh
cd portaudio
make install
cd ../../
./tools/autotoolize.sh
./configure --with-qtdir=/usr/qt/3 PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
make
make install
sflphone
...@@ -6,10 +6,6 @@ AC_INIT([sflphone],[1.0.2],[sflphoneteam@savoirfairelinux.com],[sflphone]) ...@@ -6,10 +6,6 @@ AC_INIT([sflphone],[1.0.2],[sflphoneteam@savoirfairelinux.com],[sflphone])
AC_COPYRIGHT([[Copyright (c) Savoir-Faire Linux 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012]]) AC_COPYRIGHT([[Copyright (c) Savoir-Faire Linux 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012]])
AC_REVISION([$Revision$]) AC_REVISION([$Revision$])
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])
...@@ -50,7 +46,8 @@ AC_FUNC_ALLOCA ...@@ -50,7 +46,8 @@ AC_FUNC_ALLOCA
AC_HEADER_STDC AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h malloc.h memory.h \ AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h malloc.h memory.h \
netdb.h netinet/in.h stdlib.h string.h strings.h \ netdb.h netinet/in.h stdlib.h string.h strings.h \
sys/ioctl.h sys/socket.h sys/time.h unistd.h utime.h ostream]) sys/ioctl.h sys/socket.h sys/time.h unistd.h utime.h \
ostream getopt.h])
dnl Check for typedefs, structures, and compiler characteristics dnl Check for typedefs, structures, and compiler characteristics
AC_HEADER_STAT AC_HEADER_STAT
...@@ -89,9 +86,6 @@ AC_DEFINE_UNQUOTED([RETSIGTYPE],[$ac_cv_type_signal],[Define as the return type ...@@ -89,9 +86,6 @@ AC_DEFINE_UNQUOTED([RETSIGTYPE],[$ac_cv_type_signal],[Define as the return type
AC_FUNC_STAT AC_FUNC_STAT
AC_FUNC_UTIME_NULL AC_FUNC_UTIME_NULL
AC_FUNC_VPRINTF AC_FUNC_VPRINTF
AC_CHECK_FUNCS([bzero floor gethostbyname gethrtime gettimeofday \
inet_ntoa memset mkdir pathconf pow regcomp select setlocale \
socket strchr strdup strerror strrchr strstr strtol utime])
dnl Check for GNU ccRTP dnl Check for GNU ccRTP
PKG_PROG_PKG_CONFIG PKG_PROG_PKG_CONFIG
...@@ -147,13 +141,15 @@ AS_IF([test "x$enable_video" != "xno"], [ ...@@ -147,13 +141,15 @@ AS_IF([test "x$enable_video" != "xno"], [
AM_CONDITIONAL(SFL_VIDEO, test "x$enable_video" != "xno") AM_CONDITIONAL(SFL_VIDEO, test "x$enable_video" != "xno")
LIBCCGNU2_MIN_VERSION=1.3.1 LIBCCGNU2_MIN_VERSION=1.3.1
PKG_CHECK_MODULES(CCGNU2, libccgnu2 >= ${LIBCCGNU2_MIN_VERSION},, AC_MSG_ERROR([Missing common cpp development package: libcommoncpp2-dev])) PKG_CHECK_MODULES([CCGNU2], [commoncpp] >= ${LIBCCGNU2_MIN_VERSION}, AC_DEFINE_UNQUOTED([COMMONCPP_PREFIX], [1], [Use commoncpp include prefix]), [
PKG_CHECK_MODULES([CCGNU2], [libccgnu2] >= ${LIBCCGNU2_MIN_VERSION}, AC_DEFINE_UNQUOTED([CCPP_PREFIX], [1], [Use cc++ include prefix]),
LIBCCEXT2_MIN_VERSION=1.3.1 AC_MSG_ERROR([Missing common cpp development package: libcommoncpp2-dev]))
PKG_CHECK_MODULES(CCEXT2, libccext2 >= ${LIBCCEXT2_MIN_VERSION}) ])
LIBCCRT_MIN_VERSION=1.3.0 LIBCCRTP_MIN_VERSION=1.3.0
PKG_CHECK_MODULES(CCRTP, libccrtp1 >= ${LIBCCRT_MIN_VERSION},, AC_MSG_ERROR([Missing ccrtp development package: libccrtp-dev])) PKG_CHECK_MODULES([CCRTP], [libccrtp] >= ${LIBCCRTP_MIN_VERSION},, [
PKG_CHECK_MODULES([CCRTP], [libccrtp1] >= ${LIBCCRTP_MIN_VERSION},, AC_MSG_ERROR([Missing ccrtp development package: libccrtp-dev]))
])
dnl Check for OpenSSL to link against pjsip and provide SIPS TLS support dnl Check for OpenSSL to link against pjsip and provide SIPS TLS support
PKG_CHECK_MODULES([libssl], libssl,, AC_MSG_ERROR([Missing ssl development package: libssl-dev])) PKG_CHECK_MODULES([libssl], libssl,, AC_MSG_ERROR([Missing ssl development package: libssl-dev]))
...@@ -218,37 +214,6 @@ AC_SEARCH_LIBS([speex_preprocess_run], [speexdsp], [], [ ...@@ -218,37 +214,6 @@ AC_SEARCH_LIBS([speex_preprocess_run], [speexdsp], [], [
AC_MSG_ERROR([Unable to find speexdsp development files]) AC_MSG_ERROR([Unable to find speexdsp development files])
]) ])
# check for libcelt
AC_ARG_WITH([celt], [AS_HELP_STRING([--without-celt],
[disable support for celt codec])], [], [with_celt=yes])
AS_IF([test "x$with_celt" != xno],
[PKG_CHECK_MODULES(CELT, celt >= 0.9.1,
[
with_celt_91=yes; AC_MSG_NOTICE([Using celt 0.9.1])
],
[
PKG_CHECK_MODULES(CELT, celt >= 0.7.1,
[
with_celt_71=yes; AC_MSG_NOTICE([Using celt 0.7.1])
],
[
dnl celt071 is how certain distros package celt
PKG_CHECK_MODULES(CELT, celt071 >= 0.7.1,
[
with_celt_071=yes; AC_MSG_NOTICE([Using celt071])
],
[
AC_MSG_FAILURE([libcelt link test failed. You may use --without-celt to compile without celt codec support.])
])
])
])]
)
AM_CONDITIONAL(BUILD_CELT_91, test "x$with_celt_91" = "xyes" )
AM_CONDITIONAL(BUILD_CELT_71, test "x$with_celt_71" = "xyes" )
AM_CONDITIONAL(BUILD_CELT_071, test "x$with_celt_071" = "xyes" )
dnl Check for IAX dnl Check for IAX
AC_ARG_WITH([iax2], [AS_HELP_STRING([--without-iax2], AC_ARG_WITH([iax2], [AS_HELP_STRING([--without-iax2],
[disable support for the iax2 protocol])], [], [with_iax2=yes]) [disable support for the iax2 protocol])], [], [with_iax2=yes])
...@@ -285,8 +250,6 @@ CXXFLAGS="${CXXFLAGS} -g -Wno-return-type -Wall -Wextra -Wnon-virtual-dtor -Weff ...@@ -285,8 +250,6 @@ CXXFLAGS="${CXXFLAGS} -g -Wno-return-type -Wall -Wextra -Wnon-virtual-dtor -Weff
dnl What to generate dnl What to generate
AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([libs/Makefile \ AC_CONFIG_FILES([libs/Makefile \
libs/utilspp/Makefile \
libs/utilspp/singleton/Makefile \
libs/iax2/Makefile]) libs/iax2/Makefile])
AC_CONFIG_FILES([src/Makefile \ AC_CONFIG_FILES([src/Makefile \
......
...@@ -9,20 +9,8 @@ ASTYLERC="$(top_srcdir)/../astylerc" ...@@ -9,20 +9,8 @@ ASTYLERC="$(top_srcdir)/../astylerc"
indent="/usr/bin/astyle" indent="/usr/bin/astyle"
# for pjsip # for pjsip
PJSIP_LIBS= \ include $(src)/libs/pjproject/build.mak
-L$(src)/libs/pjproject/pjnath/lib/ \ PJSIP_LIBS=$(APP_LDFLAGS) $(APP_LDLIBS)
-L$(src)/libs/pjproject/pjsip/lib/ \
-L$(src)/libs/pjproject/pjlib/lib/ \
-L$(src)/libs/pjproject/pjlib-util/lib/ \
-L$(src)/libs/pjproject/pjmedia/lib/ \
-lpjnath-$(target) \
-lpjsua-$(target) \
-lpjsip-$(target) \
-lpjmedia-$(target) \
-lpjsip-simple-$(target) \
-lpjsip-ua-$(target) \
-lpjlib-util-$(target) \
-lpj-$(target)
SIP_CFLAGS=-I$(src)/libs/pjproject/pjsip/include \ SIP_CFLAGS=-I$(src)/libs/pjproject/pjsip/include \
-I$(src)/libs/pjproject/pjlib/include \ -I$(src)/libs/pjproject/pjlib/include \
......
SUBDIRS = utilspp iax2 SUBDIRS = iax2
EXTRA_DIST=pjproject EXTRA_DIST=pjproject
This diff is collapsed.
This diff is collapsed.
SUBDIRS = singleton
noinst_LTLIBRARIES = libutilspp.la
libutilspp_la_SOURCES = \
null_type.hpp \
singleton.hpp \
threading_single.hpp threading_single.inl
libutilspp_la_LIBADD = ./singleton/libsingleton.la
/*
* Copyright (c) <2002-2004> <Jean-Philippe Barrette-LaPierre>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (cURLpp), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef UTILSPP_NULLTYPE_HPP
#define UTILSPP_NULLTYPE_HPP
namespace utilspp
{
struct NullType;
}
#endif
#include "threading_single.hpp"
#include "singleton/singleton_holder.hpp"
noinst_LTLIBRARIES = libsingleton.la
libsingleton_la_SOURCES = \
creation_using_new.hpp creation_using_new.inl \
lifetime_default.hpp lifetime_default.inl \
singleton_holder.hpp singleton_holder.inl
/*
* Copyright (c) <2002-2004> <Jean-Philippe Barrette-LaPierre>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (cURLpp), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __CREATION_USING_NEW_HPP__
#define __CREATION_USING_NEW_HPP__
/**
* This class is a creation policy for the utilspp::singleton_holder. The
* policy is creating the singleton by a "new" call.
*/
namespace utilspp
{
template< typename T >
struct CreationUsingNew
{
static T *create();
static void destroy( T *obj );
};
}
#include "creation_using_new.inl"
#endif // __CREATION_USING_NEW_HPP__
/*
* Copyright (c) <2002-2004> <Jean-Philippe Barrette-LaPierre>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (cURLpp), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef CREATION_USING_NEW_INL
#define CREATION_USING_NEW_INL
template< typename T >
T *
utilspp::CreationUsingNew< T >::create()
{
return new T;
}
template< typename T >
void
utilspp::CreationUsingNew< T >::destroy( T *obj )
{
delete obj;
}
#endif
/*
* Copyright (c) <2002-2004> <Jean-Philippe Barrette-LaPierre>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (cURLpp), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef LIFETIME_DEFAULT_HPP
#define LIFETIME_DEFAULT_HPP
namespace utilspp
{
template< typename T >
class LifetimeDefault
{
public:
static void scheduleDestruction( T *obj, void (*func)() );
static void onDeadReference();
};
}
#include "lifetime_default.inl"
#endif
/*
* Copyright (c) <2002-2004> <Jean-Philippe Barrette-LaPierre>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (cURLpp), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __LIFETIME_DEFAULT_INL__
#define __LIFETIME_DEFAULT_INL__
#include <cstdlib>
#include <stdexcept>
template< typename T >
void
utilspp::LifetimeDefault< T >::scheduleDestruction( T *, void (*func)() )
{
std::atexit(func);
}
template< typename T >
void
utilspp::LifetimeDefault< T >::onDeadReference()
{
throw std::logic_error("Dead reference detected");
}
#endif // __LIFETIME_DEFAULT_INL__
/*
* Copyright (c) <2002-2004> <Jean-Philippe Barrette-LaPierre>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (cURLpp), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __SINGLETON_HOLDER_HPP__
#define __SINGLETON_HOLDER_HPP__
#include "creation_using_new.hpp"
#include "lifetime_default.hpp"
#include "../threading_single.hpp"
namespace utilspp
{
template
< class T,
template < class > class CreationPolicy = utilspp::CreationUsingNew,
template < class > class LifetimePolicy = utilspp::LifetimeDefault,
template < class > class ThreadingModel = utilspp::ThreadingSingle >
class SingletonHolder
{
public:
//the accessor method.
static T& instance();
static void makeInstance();
static void terminate();
protected:
//protected to be sure that nobody may create one by himself.
SingletonHolder();
private:
static void destroySingleton();
private:
typedef typename ThreadingModel< T * >::VolatileType InstanceType;
static InstanceType mInstance;
static bool mDestroyed;
};
}
#include "singleton_holder.inl"
#endif
/*
* Copyright (c) <2002-2004> <Jean-Philippe Barrette-LaPierre>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (cURLpp), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __SINGLETON_HOLDER_INL__
#define __SINGLETON_HOLDER_INL__
#include <cassert>
template
<
class T,
template < class > class CreationPolicy,
template < class > class LifetimePolicy,
template < class > class ThreadingModel
>
T&
utilspp::SingletonHolder
<
T,
CreationPolicy,
LifetimePolicy,
ThreadingModel
>
::instance()
{
if ( mInstance == NULL )
{
makeInstance();
}
return ( *mInstance );
}
template
<
class T,
template < class > class CreationPolicy,
template < class > class LifetimePolicy,
template < class > class ThreadingModel
>
void
utilspp::SingletonHolder
<
T,
CreationPolicy,
LifetimePolicy,
ThreadingModel
>::makeInstance()
{
if ( mInstance == NULL )
{
typename ThreadingModel< T >::lock guard;
(void)guard;
if ( mInstance == NULL ) {
if ( mDestroyed )
{
LifetimePolicy< T >::onDeadReference();
mDestroyed = false;
}
mInstance = CreationPolicy< T >::create();
LifetimePolicy< T >::scheduleDestruction( mInstance, &destroySingleton );
}
}
}
template
<
class T,
template < class > class CreationPolicy,
template < class > class LifetimePolicy,
template < class > class ThreadingModel
>
void
utilspp::SingletonHolder
<
T,
CreationPolicy,
LifetimePolicy,
ThreadingModel
>
::destroySingleton()
{
assert( !mDestroyed );
CreationPolicy< T >::destroy( mInstance );
mInstance = NULL;
mDestroyed = true;
}
template < class T,
template < class > class C,
template < class > class L,
template < class > class M
>
typename utilspp::SingletonHolder< T, C, L, M>::InstanceType
utilspp::SingletonHolder< T, C, L, M >::mInstance;
template
<
class T,
template < class > class C,
template < class > class L,
template < class > class M
>
bool utilspp::SingletonHolder< T, C, L, M >::mDestroyed;
#endif // __SINGLETON_HOLDER_INL__
/*
* Copyright (c) <2002-2004> <Jean-Philippe Barrette-LaPierre>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (cURLpp), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __THREADING_SINGLE_HPP__
#define __THREADING_SINGLE_HPP__
#include "null_type.hpp"
namespace utilspp
{
template < typename T = utilspp::NullType >
struct ThreadingSingle
{
struct mutex
{
void lock();
void unlock();
};
struct lock
{
lock();
lock( mutex &m );
};