annotate src/Support/Common.h @ 231:763576f63761

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