annotate trunk/src/Support/Common.h @ 706:f8e90b5d85fd tip

Delete CARFAC code from this repository. It has been moved to https://github.com/google/carfac Please email me with your github username to get access. I've also created a new mailing list to discuss CARFAC development: https://groups.google.com/forum/#!forum/carfac-dev
author ronw@google.com
date Thu, 18 Jul 2013 20:56:51 +0000
parents 6bc760be184b
children
rev   line source
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
tomwalters@427 35 // Defines for windows
tomwalters@427 36 #ifdef _WINDOWS
tomwalters@427 37 #define M_PI 3.14159265359
tomwalters@427 38 #define isnan _isnan
tomwalters@427 39 #define isinf(x) (!_finite(x))
tomwalters@427 40 #define snprintf _snprintf
tomwalters@427 41 #define PATH_MAX _MAX_PATH
tomwalters@427 42 #endif
tomwalters@427 43
tom@400 44 #define AIM_NAME "AIM-C"
tom@400 45 #define AIM_VERSION_STRING "version_number"
tom@400 46
tomwalters@268 47 // A macro to disallow the copy constructor and operator= functions
tomwalters@268 48 // This should be used in the private: declarations for a class
tomwalters@268 49 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
tomwalters@268 50 TypeName(const TypeName&); \
tomwalters@268 51 void operator=(const TypeName&)
tomwalters@268 52
tomwalters@268 53 #if !defined(_T)
tomwalters@268 54 # ifdef _UNICODE
tomwalters@268 55 # define _T(x) L ## x
tomwalters@268 56 # else
tomwalters@268 57 # define _T(x) x
tomwalters@268 58 # endif
tomwalters@268 59 #endif
tomwalters@268 60
tom@399 61 #if !defined(_S)
tom@399 62 # ifdef _UNICODE
tom@399 63 # define _S(x) L ## x
tom@399 64 # else
tom@399 65 # define _S(x) x
tom@399 66 # endif
tom@399 67 #endif
tom@399 68
tomwalters@268 69 /*! \brief C++ delete if != NULL
tomwalters@268 70 *
tomwalters@268 71 * This was used so often, that is was moved to a macro.
tomwalters@268 72 */
tomwalters@268 73 #define DELETE_IF_NONNULL(x) { \
tomwalters@268 74 if ( (x) ) { \
tomwalters@268 75 delete (x); \
tomwalters@268 76 (x) = NULL; \
tomwalters@268 77 } \
tomwalters@268 78 }
tomwalters@268 79
tomwalters@268 80 /*! \brief C++ delete[] if != NULL
tomwalters@268 81 *
tomwalters@268 82 * This was used so often, that is was moved to a macro.
tomwalters@268 83 */
tomwalters@268 84 #define DELETE_ARRAY_IF_NONNULL(x) { \
tomwalters@268 85 if ( (x) ) { \
tomwalters@268 86 delete[] (x); \
tomwalters@268 87 (x) = NULL; \
tomwalters@268 88 } \
tomwalters@268 89 }
tomwalters@268 90
tomwalters@268 91 /*! \brief C free if != NULL
tomwalters@268 92 *
tomwalters@268 93 * This was used so often, that is was moved to a macro.
tomwalters@268 94 */
tomwalters@268 95 #define FREE_IF_NONNULL(x) { \
tomwalters@268 96 if ( (x) ) { \
tomwalters@268 97 free(x); \
tomwalters@268 98 (x) = NULL; \
tomwalters@268 99 } \
tomwalters@268 100 }
tomwalters@268 101
tomwalters@268 102 #ifdef DEBUG
tomwalters@268 103 # define AIM_VERIFY(x) AIM_ASSERT(x)
tomwalters@268 104 # define AIM_ASSERT(x) { \
tomwalters@268 105 if (!(x)) { \
tomwalters@268 106 LOG_ERROR("Assertion failed.\n"); \
tomwalters@280 107 *(reinterpret_cast<char*>(0)) = 0; \
tomwalters@268 108 } \
tomwalters@268 109 }
tomwalters@268 110 #else
tomwalters@268 111 # define AIM_VERIFY(x) {x;}
tomwalters@268 112 # define AIM_ASSERT(...)
tomwalters@268 113 #endif
tomwalters@268 114
tomwalters@268 115 namespace aimc {
tomwalters@268 116 void LOG_ERROR(const char *sFmt, ...);
tomwalters@268 117 void LOG_INFO(const char *sFmt, ...);
tomwalters@278 118 void LOG_INFO_NN(const char *sFmt, ...);
tomwalters@268 119 } // namespace aimc
tomwalters@268 120
tomwalters@283 121 #endif // AIMC_SUPPORT_COMMON_H_