summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorHans-Joachim Lankenau <hjs@openoffice.org>2004-06-25 16:14:07 +0000
committerHans-Joachim Lankenau <hjs@openoffice.org>2004-06-25 16:14:07 +0000
commit424e2f1281188324acb9f9eb674efd598422d066 (patch)
treef86ccd8904ec419db3555204f0f853746b8c9bcc /sal
parent694e6f5f9a5abf7dcd8b01e632f14d36250a5d29 (diff)
INTEGRATION: CWS tune04 (1.4.98); FILE MERGED
2004/06/10 15:07:31 cmc 1.4.98.2: #i29636# make helper a little more flexible 2004/06/10 12:05:28 cmc 1.4.98.1: #i29636# add helper templates to instance.hxx to simplify usage
Diffstat (limited to 'sal')
-rw-r--r--sal/inc/rtl/instance.hxx39
1 files changed, 37 insertions, 2 deletions
diff --git a/sal/inc/rtl/instance.hxx b/sal/inc/rtl/instance.hxx
index 695f80137f19..820ef76fb150 100644
--- a/sal/inc/rtl/instance.hxx
+++ b/sal/inc/rtl/instance.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: instance.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: obo $ $Date: 2003-09-04 10:55:55 $
+ * last change: $Author: hjs $ $Date: 2004-06-25 17:14:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,6 +65,9 @@
#ifndef INCLUDED_OSL_DOUBLECHECKEDLOCKING_H
#include "osl/doublecheckedlocking.h"
#endif
+#ifndef INCLUDED_OSL_GETGLOBALMUTEX_HXX
+#include "osl/getglobalmutex.hxx"
+#endif
namespace {
@@ -370,4 +373,36 @@ rtl_Instance< Inst, InstCtor, Guard, GuardCtor, Data, DataCtor >::m_pInstance
}
+namespace rtl
+{
+ template< typename T, typename Unique > struct StaticInstance
+ {
+ T * operator ()()
+ {
+ static T instance;
+ return &instance;
+ }
+ };
+
+ template< typename T, typename Unique, typename Base = StaticInstance<T, Unique> > struct Static : public Base
+ {
+ static T & get()
+ {
+ return *rtl_Instance<
+ T, Static, osl::MutexGuard, osl::GetGlobalMutex >::create(
+ Static(), osl::GetGlobalMutex());
+ }
+ };
+
+ template< typename T, typename InitAggregate > struct StaticAggregate : public InitAggregate
+ {
+ static T * get()
+ {
+ return rtl_Instance<
+ T, StaticAggregate, osl::MutexGuard, osl::GetGlobalMutex >::create(
+ StaticAggregate(), osl::GetGlobalMutex());
+ }
+ };
+}
+
#endif // INCLUDED_RTL_INSTANCE_HXX