tomwalters@0
|
1 // Copyright 2006-2010, Thomas Walters, Willem van Engen
|
tomwalters@0
|
2 //
|
tomwalters@0
|
3 // AIM-C: A C++ implementation of the Auditory Image Model
|
tomwalters@0
|
4 // http://www.acousticscale.org/AIMC
|
tomwalters@0
|
5 //
|
tomwalters@45
|
6 // Licensed under the Apache License, Version 2.0 (the "License");
|
tomwalters@45
|
7 // you may not use this file except in compliance with the License.
|
tomwalters@45
|
8 // You may obtain a copy of the License at
|
tomwalters@0
|
9 //
|
tomwalters@45
|
10 // http://www.apache.org/licenses/LICENSE-2.0
|
tomwalters@0
|
11 //
|
tomwalters@45
|
12 // Unless required by applicable law or agreed to in writing, software
|
tomwalters@45
|
13 // distributed under the License is distributed on an "AS IS" BASIS,
|
tomwalters@45
|
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
tomwalters@45
|
15 // See the License for the specific language governing permissions and
|
tomwalters@45
|
16 // limitations under the License.
|
tomwalters@0
|
17
|
tomwalters@0
|
18 /*! \file
|
tomwalters@0
|
19 * \brief Common includes for all AIM-C
|
tomwalters@0
|
20 */
|
tomwalters@0
|
21
|
tomwalters@0
|
22 /*! \author: Thomas Walters <tom@acousticscale.org>
|
tomwalters@0
|
23 * \author: Willem van Engen <cnbh@willem.engen.nl>
|
tomwalters@0
|
24 * \date 2010/01/30
|
tomwalters@23
|
25 * \version \$Id$
|
tomwalters@0
|
26 */
|
tomwalters@0
|
27
|
tomwalters@11
|
28 #ifndef AIMC_SUPPORT_COMMON_H_
|
tomwalters@11
|
29 #define AIMC_SUPPORT_COMMON_H_
|
tomwalters@0
|
30
|
tomwalters@0
|
31 #include <stdlib.h>
|
tomwalters@0
|
32 #include <stdio.h>
|
tomwalters@0
|
33 #include <stdarg.h>
|
tomwalters@0
|
34
|
tomwalters@0
|
35 // A macro to disallow the copy constructor and operator= functions
|
tomwalters@0
|
36 // This should be used in the private: declarations for a class
|
tomwalters@0
|
37 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
tomwalters@0
|
38 TypeName(const TypeName&); \
|
tomwalters@0
|
39 void operator=(const TypeName&)
|
tomwalters@0
|
40
|
tomwalters@0
|
41 #if !defined(_T)
|
tomwalters@0
|
42 # ifdef _UNICODE
|
tomwalters@0
|
43 # define _T(x) L ## x
|
tomwalters@0
|
44 # else
|
tomwalters@0
|
45 # define _T(x) x
|
tomwalters@0
|
46 # endif
|
tomwalters@0
|
47 #endif
|
tomwalters@0
|
48
|
tomwalters@0
|
49 /*! \brief C++ delete if != NULL
|
tomwalters@0
|
50 *
|
tomwalters@0
|
51 * This was used so often, that is was moved to a macro.
|
tomwalters@0
|
52 */
|
tomwalters@0
|
53 #define DELETE_IF_NONNULL(x) { \
|
tomwalters@0
|
54 if ( (x) ) { \
|
tomwalters@0
|
55 delete (x); \
|
tomwalters@0
|
56 (x) = NULL; \
|
tomwalters@0
|
57 } \
|
tomwalters@0
|
58 }
|
tomwalters@0
|
59
|
tomwalters@0
|
60 /*! \brief C++ delete[] if != NULL
|
tomwalters@0
|
61 *
|
tomwalters@0
|
62 * This was used so often, that is was moved to a macro.
|
tomwalters@0
|
63 */
|
tomwalters@0
|
64 #define DELETE_ARRAY_IF_NONNULL(x) { \
|
tomwalters@0
|
65 if ( (x) ) { \
|
tomwalters@0
|
66 delete[] (x); \
|
tomwalters@0
|
67 (x) = NULL; \
|
tomwalters@0
|
68 } \
|
tomwalters@0
|
69 }
|
tomwalters@0
|
70
|
tomwalters@0
|
71 /*! \brief C free if != NULL
|
tomwalters@0
|
72 *
|
tomwalters@0
|
73 * This was used so often, that is was moved to a macro.
|
tomwalters@0
|
74 */
|
tomwalters@0
|
75 #define FREE_IF_NONNULL(x) { \
|
tomwalters@0
|
76 if ( (x) ) { \
|
tomwalters@0
|
77 free(x); \
|
tomwalters@0
|
78 (x) = NULL; \
|
tomwalters@0
|
79 } \
|
tomwalters@0
|
80 }
|
tomwalters@0
|
81
|
tomwalters@0
|
82 #ifdef DEBUG
|
tomwalters@0
|
83 # define AIM_VERIFY(x) AIM_ASSERT(x)
|
tomwalters@0
|
84 # define AIM_ASSERT(x) { \
|
tomwalters@0
|
85 if (!(x)) { \
|
tomwalters@0
|
86 LOG_ERROR("Assertion failed.\n"); \
|
tomwalters@8
|
87 *(reinterpret_cast<char*>(0)) = 0; \
|
tomwalters@0
|
88 } \
|
tomwalters@0
|
89 }
|
tomwalters@0
|
90 #else
|
tomwalters@0
|
91 # define AIM_VERIFY(x) {x;}
|
tomwalters@0
|
92 # define AIM_ASSERT(...)
|
tomwalters@0
|
93 #endif
|
tomwalters@0
|
94
|
tomwalters@0
|
95 namespace aimc {
|
tomwalters@0
|
96 void LOG_ERROR(const char *sFmt, ...);
|
tomwalters@0
|
97 void LOG_INFO(const char *sFmt, ...);
|
tomwalters@6
|
98 void LOG_INFO_NN(const char *sFmt, ...);
|
tomwalters@0
|
99 } // namespace aimc
|
tomwalters@0
|
100
|
tomwalters@11
|
101 #endif // AIMC_SUPPORT_COMMON_H_
|