• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

Solid

  • solid
  • solid
soliddefs_p.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2007 Kevin Ottens <ervin@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) version 3, or any
8 later version accepted by the membership of KDE e.V. (or its
9 successor approved by the membership of KDE e.V.), which shall
10 act as a proxy defined in Section 6 of version 3 of the license.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#ifndef SOLID_SOLIDDEFS_P_H
22#define SOLID_SOLIDDEFS_P_H
23
24#include <QtCore/QObject>
25
26#define return_SOLID_CALL(Type, Object, Default, Method) \
27 Type t = qobject_cast<Type>(Object); \
28 if (t!=0) \
29 { \
30 return t->Method; \
31 } \
32 else \
33 { \
34 return Default; \
35 }
36
37
38
39#define SOLID_CALL(Type, Object, Method) \
40 Type t = qobject_cast<Type>(Object); \
41 if (t!=0) \
42 { \
43 t->Method; \
44 }
45
46//
47// WARNING!!
48// This code uses undocumented Qt API
49// Do not copy it to your application! Use only the functions that are here!
50// Otherwise, it could break when a new version of Qt ships.
51//
52
53/*
54 * Lame copy of K_GLOBAL_STATIC below, but that's the price for
55 * being completely kdecore independent.
56 */
57
58namespace Solid
59{
60 typedef void (*CleanUpFunction)();
61
62 class CleanUpGlobalStatic
63 {
64 public:
65 Solid::CleanUpFunction func;
66
67 inline ~CleanUpGlobalStatic() { func(); }
68 };
69}
70
71#ifdef Q_CC_MSVC
72# define SOLID_GLOBAL_STATIC_STRUCT_NAME(NAME) _solid_##NAME##__LINE__
73#else
74# define SOLID_GLOBAL_STATIC_STRUCT_NAME(NAME)
75#endif
76
77#define SOLID_GLOBAL_STATIC(TYPE, NAME) SOLID_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ())
78
79#define SOLID_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
80static QBasicAtomicPointer<TYPE > _solid_static_##NAME = Q_BASIC_ATOMIC_INITIALIZER(0);\
81static bool _solid_static_##NAME##_destroyed; \
82static struct SOLID_GLOBAL_STATIC_STRUCT_NAME(NAME) \
83{ \
84 bool isDestroyed() \
85 { \
86 return _solid_static_##NAME##_destroyed; \
87 } \
88 inline operator TYPE*() \
89 { \
90 return operator->(); \
91 } \
92 inline TYPE *operator->() \
93 { \
94 if (!_solid_static_##NAME) { \
95 if (isDestroyed()) { \
96 qFatal("Fatal Error: Accessed global static '%s *%s()' after destruction. " \
97 "Defined at %s:%d", #TYPE, #NAME, __FILE__, __LINE__); \
98 } \
99 TYPE *x = new TYPE ARGS; \
100 if (!_solid_static_##NAME.testAndSetOrdered(0, x) \
101 && _solid_static_##NAME != x ) { \
102 delete x; \
103 } else { \
104 static Solid::CleanUpGlobalStatic cleanUpObject = { destroy }; \
105 } \
106 } \
107 return _solid_static_##NAME; \
108 } \
109 inline TYPE &operator*() \
110 { \
111 return *operator->(); \
112 } \
113 static void destroy() \
114 { \
115 _solid_static_##NAME##_destroyed = true; \
116 TYPE *x = _solid_static_##NAME; \
117 _solid_static_##NAME = 0; \
118 delete x; \
119 } \
120} NAME;
121
122#endif
Solid::CleanUpGlobalStatic
Definition: soliddefs_p.h:63
Solid::CleanUpGlobalStatic::~CleanUpGlobalStatic
~CleanUpGlobalStatic()
Definition: soliddefs_p.h:67
Solid::CleanUpGlobalStatic::func
Solid::CleanUpFunction func
Definition: soliddefs_p.h:65
Solid
Definition: acadapter.h:29
Solid::CleanUpFunction
void(* CleanUpFunction)()
Definition: soliddefs_p.h:60
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Solid

Skip menu "Solid"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal