KDECore
Go to the documentation of this file.
23 #include <QtCore/QAtomicPointer>
24 #include <sys/types.h>
25 #include <QtCore/QObject>
49 typedef void (*KdeCleanUpFunction)();
57 class KCleanUpGlobalStatic
60 KdeCleanUpFunction func;
62 inline ~KCleanUpGlobalStatic() { func(); }
72 # define K_GLOBAL_STATIC_STRUCT_NAME(NAME) _k_##NAME##__LINE__
79 # define K_GLOBAL_STATIC_STRUCT_NAME(NAME)
221 #define K_GLOBAL_STATIC(TYPE, NAME) K_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ())
255 #define K_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
256 static QBasicAtomicPointer<TYPE > _k_static_##NAME = Q_BASIC_ATOMIC_INITIALIZER(0); \
257 static bool _k_static_##NAME##_destroyed; \
258 static struct K_GLOBAL_STATIC_STRUCT_NAME(NAME) \
260 inline bool isDestroyed() const \
262 return _k_static_##NAME##_destroyed; \
264 inline bool exists() const \
266 return _k_static_##NAME != 0; \
268 inline operator TYPE*() \
270 return operator->(); \
272 inline TYPE *operator->() \
274 if (!_k_static_##NAME) { \
275 if (isDestroyed()) { \
276 qFatal("Fatal Error: Accessed global static '%s *%s()' after destruction. " \
277 "Defined at %s:%d", #TYPE, #NAME, __FILE__, __LINE__); \
279 TYPE *x = new TYPE ARGS; \
280 if (!_k_static_##NAME.testAndSetOrdered(0, x) \
281 && _k_static_##NAME != x ) { \
284 static KCleanUpGlobalStatic cleanUpObject = { destroy }; \
287 return _k_static_##NAME; \
289 inline TYPE &operator*() \
291 return *operator->(); \
293 static void destroy() \
295 _k_static_##NAME##_destroyed = true; \
296 TYPE *x = _k_static_##NAME; \
297 _k_static_##NAME = 0; \
397 KDECORE_EXPORT mode_t
umask();
458 KDECORE_EXPORT
void ref();
464 KDECORE_EXPORT
void deref();
537 #define KMIN(a,b) qMin(a,b)
543 #define KMAX(a,b) qMax(a,b)
549 #define KABS(a) qAbs(a)
556 #define KCLAMP(x,low,high) qBound(low,x,high)
570 inline KDE_DEPRECATED
T kClamp(
const T& x,
const T& low,
const T& high )
572 if ( x < low )
return low;
573 else if ( high < x )
return high;
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Jul 23 2013 21:56:50 by
doxygen 1.8.1.1 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.