Mercurial > hg > aimc
comparison src/Support/Common.h @ 0:582cbe817f2c
- Initial add of support code and modules. Not everything is working yet.
author | tomwalters |
---|---|
date | Fri, 12 Feb 2010 12:31:23 +0000 |
parents | |
children | 8c859ef1fb75 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:582cbe817f2c |
---|---|
1 // Copyright 2006-2010, Thomas Walters, Willem van Engen | |
2 // | |
3 // AIM-C: A C++ implementation of the Auditory Image Model | |
4 // http://www.acousticscale.org/AIMC | |
5 // | |
6 // This program is free software: you can redistribute it and/or modify | |
7 // it under the terms of the GNU General Public License as published by | |
8 // the Free Software Foundation, either version 3 of the License, or | |
9 // (at your option) any later version. | |
10 // | |
11 // This program is distributed in the hope that it will be useful, | |
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 // GNU General Public License for more details. | |
15 // | |
16 // You should have received a copy of the GNU General Public License | |
17 // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | |
19 /*! \file | |
20 * \brief Common includes for all AIM-C | |
21 */ | |
22 | |
23 /*! \author: Thomas Walters <tom@acousticscale.org> | |
24 * \author: Willem van Engen <cnbh@willem.engen.nl> | |
25 * \date 2010/01/30 | |
26 * \version \$Id: Common.h 1 2010-02-02 11:04:50Z tcw $ | |
27 */ | |
28 | |
29 #ifndef _AIMC_SUPPORT_COMMON_H_ | |
30 #define _AIMC_SUPPORT_COMMON_H_ | |
31 | |
32 #include <stdlib.h> | |
33 #include <stdio.h> | |
34 #include <stdarg.h> | |
35 | |
36 // A macro to disallow the copy constructor and operator= functions | |
37 // This should be used in the private: declarations for a class | |
38 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ | |
39 TypeName(const TypeName&); \ | |
40 void operator=(const TypeName&) | |
41 | |
42 #if !defined(_T) | |
43 # ifdef _UNICODE | |
44 # define _T(x) L ## x | |
45 # else | |
46 # define _T(x) x | |
47 # endif | |
48 #endif | |
49 | |
50 /*! \brief C++ delete if != NULL | |
51 * | |
52 * This was used so often, that is was moved to a macro. | |
53 */ | |
54 #define DELETE_IF_NONNULL(x) { \ | |
55 if ( (x) ) { \ | |
56 delete (x); \ | |
57 (x) = NULL; \ | |
58 } \ | |
59 } | |
60 | |
61 /*! \brief C++ delete[] if != NULL | |
62 * | |
63 * This was used so often, that is was moved to a macro. | |
64 */ | |
65 #define DELETE_ARRAY_IF_NONNULL(x) { \ | |
66 if ( (x) ) { \ | |
67 delete[] (x); \ | |
68 (x) = NULL; \ | |
69 } \ | |
70 } | |
71 | |
72 /*! \brief C free if != NULL | |
73 * | |
74 * This was used so often, that is was moved to a macro. | |
75 */ | |
76 #define FREE_IF_NONNULL(x) { \ | |
77 if ( (x) ) { \ | |
78 free(x); \ | |
79 (x) = NULL; \ | |
80 } \ | |
81 } | |
82 | |
83 #ifdef DEBUG | |
84 # define AIM_VERIFY(x) AIM_ASSERT(x) | |
85 # define AIM_ASSERT(x) { \ | |
86 if (!(x)) { \ | |
87 LOG_ERROR("Assertion failed.\n"); \ | |
88 *((char*)0) = 0; \ | |
89 } \ | |
90 } | |
91 #else | |
92 # define AIM_VERIFY(x) {x;} | |
93 # define AIM_ASSERT(...) | |
94 #endif | |
95 | |
96 namespace aimc { | |
97 void LOG_ERROR(const char *sFmt, ...); | |
98 void LOG_INFO(const char *sFmt, ...); | |
99 } // namespace aimc | |
100 | |
101 #endif // _AIMC_SUPPORT_COMMON_H_ |