annotate trunk/src/Support/Common.h @ 284:fb52ca0e6339

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