1
// -*- mode: C++; tab-width: 2; -*-
4
// --------------------------------------------------------------------------
5
// OpenMS Mass Spectrometry Framework
6
// --------------------------------------------------------------------------
7
// Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
// --------------------------------------------------------------------------
24
// $Maintainer: Stephan Aiche$
25
// $Authors: Marc Sturm $
26
// --------------------------------------------------------------------------
28
#ifndef OPENMS_CONCEPT_MACROS_H
29
#define OPENMS_CONCEPT_MACROS_H
32
#include <OpenMS/config.h>
33
#include <OpenMS/CONCEPT/Exception.h>
39
@defgroup Conditions Condition macros
41
@brief Macros used for to enforce preconditions and postconditions.
43
These macros are enabled if debug info is enabled and optimization is disabled in configure.
44
Otherwise they are replaced by an empty string, so they won't cost any performance.
46
The macros throw Exception::Precondition or Exception::Postcondition respectively if the condition fails.
53
#ifdef OPENMS_ASSERTIONS
56
@brief Precondition macro.
60
#define OPENMS_PRECONDITION(condition, message)\
63
Exception::Precondition e(__FILE__, __LINE__, __PRETTY_FUNCTION__, #condition);\
64
if (std::strcmp(message,"")!=0)\
66
::std::string tmp(e.getMessage());\
68
tmp += ::std::string(message);\
75
@brief Postcondition macro.
79
#define OPENMS_POSTCONDITION(condition, message)\
82
Exception::Postcondition e(__FILE__, __LINE__, __PRETTY_FUNCTION__, #condition);\
83
if (std::strcmp(message,"")!=0)\
85
std::string tmp(e.getMessage());\
87
tmp += std::string(message);\
96
@brief Precondition macro.
100
#define OPENMS_PRECONDITION(condition, message)
103
@brief Postcondition macro.
107
#define OPENMS_POSTCONDITION(condition, message)
111
/** @} */ // end of Conditions
113
#endif //OPENMS_CONCEPT_MACROS_H