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