annotate src/Support/Common.h @ 169:78cbca1cf218

- AWS fixes (part 1)
author tomwalters
date Wed, 11 Aug 2010 08:55:29 +0000
parents bbf4728ffa0e
children ddf35dd82d63
rev   line source
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@141 35 // Defines for windows
tomwalters@141 36 #ifdef _WINDOWS
tomwalters@141 37 #define M_PI 3.14159265359
tomwalters@141 38 #define isnan _isnan
tomwalters@141 39 #define isinf(x) (!_finite(x))
tomwalters@141 40 #define snprintf _snprintf
tomwalters@141 41 #define PATH_MAX _MAX_PATH
tomwalters@141 42 #endif
tomwalters@141 43
tom@119 44 #define AIM_NAME "AIM-C"
tom@119 45 #define AIM_VERSION_STRING "version_number"
tom@119 46
tomwalters@0 47 // A macro to disallow the copy constructor and operator= functions
tomwalters@0 48 // This should be used in the private: declarations for a class
tomwalters@0 49 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
tomwalters@0 50 TypeName(const TypeName&); \
tomwalters@0 51 void operator=(const TypeName&)
tomwalters@0 52
tomwalters@0 53 #if !defined(_T)
tomwalters@0 54 # ifdef _UNICODE
tomwalters@0 55 # define _T(x) L ## x
tomwalters@0 56 # else
tomwalters@0 57 # define _T(x) x
tomwalters@0 58 # endif
tomwalters@0 59 #endif
tomwalters@0 60
tom@118 61 #if !defined(_S)
tom@118 62 # ifdef _UNICODE
tom@118 63 # define _S(x) L ## x
tom@118 64 # else
tom@118 65 # define _S(x) x
tom@118 66 # endif
tom@118 67 #endif
tom@118 68
tomwalters@0 69 /*! \brief C++ delete if != NULL
tomwalters@0 70 *
tomwalters@0 71 * This was used so often, that is was moved to a macro.
tomwalters@0 72 */
tomwalters@0 73 #define DELETE_IF_NONNULL(x) { \
tomwalters@0 74 if ( (x) ) { \
tomwalters@0 75 delete (x); \
tomwalters@0 76 (x) = NULL; \
tomwalters@0 77 } \
tomwalters@0 78 }
tomwalters@0 79
tomwalters@0 80 /*! \brief C++ delete[] if != NULL
tomwalters@0 81 *
tomwalters@0 82 * This was used so often, that is was moved to a macro.
tomwalters@0 83 */
tomwalters@0 84 #define DELETE_ARRAY_IF_NONNULL(x) { \
tomwalters@0 85 if ( (x) ) { \
tomwalters@0 86 delete[] (x); \
tomwalters@0 87 (x) = NULL; \
tomwalters@0 88 } \
tomwalters@0 89 }
tomwalters@0 90
tomwalters@0 91 /*! \brief C free if != NULL
tomwalters@0 92 *
tomwalters@0 93 * This was used so often, that is was moved to a macro.
tomwalters@0 94 */
tomwalters@0 95 #define FREE_IF_NONNULL(x) { \
tomwalters@0 96 if ( (x) ) { \
tomwalters@0 97 free(x); \
tomwalters@0 98 (x) = NULL; \
tomwalters@0 99 } \
tomwalters@0 100 }
tomwalters@0 101
tomwalters@0 102 #ifdef DEBUG
tomwalters@0 103 # define AIM_VERIFY(x) AIM_ASSERT(x)
tomwalters@0 104 # define AIM_ASSERT(x) { \
tomwalters@0 105 if (!(x)) { \
tomwalters@0 106 LOG_ERROR("Assertion failed.\n"); \
tomwalters@8 107 *(reinterpret_cast<char*>(0)) = 0; \
tomwalters@0 108 } \
tomwalters@0 109 }
tomwalters@0 110 #else
tomwalters@0 111 # define AIM_VERIFY(x) {x;}
tomwalters@0 112 # define AIM_ASSERT(...)
tomwalters@0 113 #endif
tomwalters@0 114
tomwalters@0 115 namespace aimc {
tomwalters@0 116 void LOG_ERROR(const char *sFmt, ...);
tomwalters@0 117 void LOG_INFO(const char *sFmt, ...);
tomwalters@6 118 void LOG_INFO_NN(const char *sFmt, ...);
tomwalters@0 119 } // namespace aimc
tomwalters@0 120
tomwalters@11 121 #endif // AIMC_SUPPORT_COMMON_H_