2 Copyright (C) 2004 Nikolas Zimmermann <wildfox@kde.org>
3 2004 Rob Buis <buis@kde.org>
5 This file is part of the KDE project
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
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 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.
28 // The class expects 'this' to be an ecmafied class which needs
29 // to call ScriptInterpreter::forgetDOMObject on destruction...
33 Shared(bool baseClass = false);
47 inline void KDOM_SAFE_SET(T *&a, T *b)
57 #define KDOM_IMPL_DTOR_ASSIGN_OP(T) \
58 T::~T() { if(d) d->deref(); } \
59 T &T::operator=(const T &other) { \
60 KDOM_SAFE_SET(d, other.d); \
63 bool T::operator==(const T &other) const { \
64 return d == other.d; \
66 bool T::operator!=(const T &other) const { \
67 return !operator==(other); \
71 * Add a null object singleton to the class, of the class' type.
72 * This makes for efficient storage and can be used in comparisons
73 * like this: someNode.firstChild() != Node::null; .
75 * TODO: is there demand for isNull() convenience method? If so, add
78 #define KDOM_INTERNAL(ClassName) static ClassName null; typedef ClassName##Impl Private;
81 * Base classes have a handle() convenience method that gives back
82 * the internal impl pointer, in addition to the null object singleton.
84 #define KDOM_INTERNAL_BASE(ClassName) KDOM_INTERNAL(ClassName) ClassName##Impl *handle() const { return d; }