annotate trunk/src/Support/Common.h @ 384:779bc83bf36c

- More inrementality
author tomwalters
date Tue, 14 Sep 2010 00:46:47 +0000
parents 30dde71d0230
children 7bfed53caacf
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@268 35 // A macro to disallow the copy constructor and operator= functions
tomwalters@268 36 // This should be used in the private: declarations for a class
tomwalters@268 37 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
tomwalters@268 38 TypeName(const TypeName&); \
tomwalters@268 39 void operator=(const TypeName&)
tomwalters@268 40
tomwalters@268 41 #if !defined(_T)
tomwalters@268 42 # ifdef _UNICODE
tomwalters@268 43 # define _T(x) L ## x
tomwalters@268 44 # else
tomwalters@268 45 # define _T(x) x
tomwalters@268 46 # endif
tomwalters@268 47 #endif
tomwalters@268 48
tomwalters@268 49 /*! \brief C++ delete if != NULL
tomwalters@268 50 *
tomwalters@268 51 * This was used so often, that is was moved to a macro.
tomwalters@268 52 */
tomwalters@268 53 #define DELETE_IF_NONNULL(x) { \
tomwalters@268 54 if ( (x) ) { \
tomwalters@268 55 delete (x); \
tomwalters@268 56 (x) = NULL; \
tomwalters@268 57 } \
tomwalters@268 58 }
tomwalters@268 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_ARRAY_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 free 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 FREE_IF_NONNULL(x) { \
tomwalters@268 76 if ( (x) ) { \
tomwalters@268 77 free(x); \
tomwalters@268 78 (x) = NULL; \
tomwalters@268 79 } \
tomwalters@268 80 }
tomwalters@268 81
tomwalters@268 82 #ifdef DEBUG
tomwalters@268 83 # define AIM_VERIFY(x) AIM_ASSERT(x)
tomwalters@268 84 # define AIM_ASSERT(x) { \
tomwalters@268 85 if (!(x)) { \
tomwalters@268 86 LOG_ERROR("Assertion failed.\n"); \
tomwalters@280 87 *(reinterpret_cast<char*>(0)) = 0; \
tomwalters@268 88 } \
tomwalters@268 89 }
tomwalters@268 90 #else
tomwalters@268 91 # define AIM_VERIFY(x) {x;}
tomwalters@268 92 # define AIM_ASSERT(...)
tomwalters@268 93 #endif
tomwalters@268 94
tomwalters@268 95 namespace aimc {
tomwalters@268 96 void LOG_ERROR(const char *sFmt, ...);
tomwalters@268 97 void LOG_INFO(const char *sFmt, ...);
tomwalters@278 98 void LOG_INFO_NN(const char *sFmt, ...);
tomwalters@268 99 } // namespace aimc
tomwalters@268 100
tomwalters@283 101 #endif // AIMC_SUPPORT_COMMON_H_