• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kleopatra

  • sources
  • kde-4.14
  • kdepim
  • kleopatra
  • utils
checker.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2007 Klarälvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Tools library.
5 **
6 ** This file may be distributed and/or modified under the terms of the
7 ** GNU General Public License version 2 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.GPL included in the
9 ** packaging of this file.
10 **
11 ** Licensees holding valid commercial KD Tools licenses may use this file in
12 ** accordance with the KD Tools Commercial License Agreement provided with
13 ** the Software.
14 **
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 **
18 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
19 ** licensing are not clear to you.
20 **
21 **********************************************************************/
22 
23 #ifndef __KDABTOOLS__CPP__CHECKER_H__
24 #define __KDABTOOLS__CPP__CHECKER_H__
25 
26 #include "kdtoolsglobal.h"
27 
28 #include <cstdlib>
29 
68 class __KDAB__CheckerImplBase {
69 public:
70  virtual ~__KDAB__CheckerImplBase() {}
71  virtual void checkInvariants() const = 0;
72 };
73 
74 template <typename T_Class>
75 class __KDAB__CheckerImpl : public __KDAB__CheckerImplBase {
76  KDAB_DISABLE_COPY( __KDAB__CheckerImpl );
77  const T_Class * const p;
78 public:
79  __KDAB__CheckerImpl( const T_Class * t )
80  : __KDAB__CheckerImplBase(), p( t ) {}
81  void checkInvariants() const {
82  try {
83  p->__KDAB_Checker__checkInvariants__();
84  } catch( ... ) {
85  std::abort();
86  }
87  }
88 };
89 
90 template <bool check_in_ctor, bool check_in_dtor>
91 class __KDAB__Checker {
92  KDAB_DISABLE_COPY( __KDAB__Checker );
93  const __KDAB__CheckerImplBase * const checker;
94 public:
95  template <typename T_Class>
96  __KDAB__Checker( const T_Class * t )
97  : checker( new __KDAB__CheckerImpl<T_Class>( t ) )
98  {
99  if ( check_in_ctor )
100  checker->checkInvariants();
101  }
102  ~__KDAB__Checker() {
103  if ( check_in_dtor )
104  checker->checkInvariants();
105  delete checker;
106  }
107 };
108 
109 #define KDAB_MAKE_CHECKABLE( Class ) \
110  private: \
111  void __KDAB_Checker__checkInvariants__() const; \
112  friend class __KDAB__CheckerImpl<Class>;
113 
114 #define KDAB_DEFINE_CHECKS( Class ) \
115  void Class::__KDAB_Checker__checkInvariants__() const
116 
117 #ifndef NDEBUG
118 # define __KDAB_CHECK_HELPER__( ctor, dtor ) \
119  const __KDAB__Checker<ctor,dtor> __checker_uglified__( this )
120 #else
121 # define __KDAB_CHECK_HELPER__( ctor, dtor ) \
122  do {} while (0)
123 #endif
124 
125 #define KDAB_CHECK_THIS __KDAB_CHECK_HELPER__( true, true )
126 #define KDAB_CHECK_CTOR __KDAB_CHECK_HELPER__( false, true )
127 #define KDAB_CHECK_DTOR __KDAB_CHECK_HELPER__( true, false )
128 
129 #endif /* __KDABTOOLS__CPP__CHECKER_H__ */
130 
__KDAB__Checker::__KDAB__Checker
__KDAB__Checker(const T_Class *t)
Definition: checker.h:96
__KDAB__CheckerImpl
Definition: checker.h:75
__KDAB__CheckerImplBase::~__KDAB__CheckerImplBase
virtual ~__KDAB__CheckerImplBase()
Definition: checker.h:70
__KDAB__Checker
Definition: checker.h:91
__KDAB__CheckerImplBase
Usage:
Definition: checker.h:68
__KDAB__Checker::~__KDAB__Checker
~__KDAB__Checker()
Definition: checker.h:102
kdtoolsglobal.h
__KDAB__CheckerImpl::__KDAB__CheckerImpl
__KDAB__CheckerImpl(const T_Class *t)
Definition: checker.h:79
__KDAB__CheckerImpl::checkInvariants
void checkInvariants() const
Definition: checker.h:81
__KDAB__CheckerImplBase::checkInvariants
virtual void checkInvariants() const =0
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:33:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kleopatra

Skip menu "kleopatra"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



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