tomwalters@0: // Copyright 2006-2010, Thomas Walters, Willem van Engen tomwalters@0: // tomwalters@0: // AIM-C: A C++ implementation of the Auditory Image Model tomwalters@0: // http://www.acousticscale.org/AIMC tomwalters@0: // tomwalters@0: // This program is free software: you can redistribute it and/or modify tomwalters@0: // it under the terms of the GNU General Public License as published by tomwalters@0: // the Free Software Foundation, either version 3 of the License, or tomwalters@0: // (at your option) any later version. tomwalters@0: // tomwalters@0: // This program is distributed in the hope that it will be useful, tomwalters@0: // but WITHOUT ANY WARRANTY; without even the implied warranty of tomwalters@0: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the tomwalters@0: // GNU General Public License for more details. tomwalters@0: // tomwalters@0: // You should have received a copy of the GNU General Public License tomwalters@0: // along with this program. If not, see . tomwalters@0: tomwalters@0: /*! \file tomwalters@0: * \brief Common includes for all AIM-C tomwalters@0: */ tomwalters@0: tomwalters@0: /*! \author: Thomas Walters tomwalters@0: * \author: Willem van Engen tomwalters@0: * \date 2010/01/30 tomwalters@0: * \version \$Id: Common.h 1 2010-02-02 11:04:50Z tcw $ tomwalters@0: */ tomwalters@0: tomwalters@11: #ifndef AIMC_SUPPORT_COMMON_H_ tomwalters@11: #define AIMC_SUPPORT_COMMON_H_ tomwalters@0: tomwalters@0: #include tomwalters@0: #include tomwalters@0: #include tomwalters@0: tomwalters@0: // A macro to disallow the copy constructor and operator= functions tomwalters@0: // This should be used in the private: declarations for a class tomwalters@0: #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ tomwalters@0: TypeName(const TypeName&); \ tomwalters@0: void operator=(const TypeName&) tomwalters@0: tomwalters@0: #if !defined(_T) tomwalters@0: # ifdef _UNICODE tomwalters@0: # define _T(x) L ## x tomwalters@0: # else tomwalters@0: # define _T(x) x tomwalters@0: # endif tomwalters@0: #endif tomwalters@0: tomwalters@0: /*! \brief C++ delete if != NULL tomwalters@0: * tomwalters@0: * This was used so often, that is was moved to a macro. tomwalters@0: */ tomwalters@0: #define DELETE_IF_NONNULL(x) { \ tomwalters@0: if ( (x) ) { \ tomwalters@0: delete (x); \ tomwalters@0: (x) = NULL; \ tomwalters@0: } \ tomwalters@0: } tomwalters@0: tomwalters@0: /*! \brief C++ delete[] if != NULL tomwalters@0: * tomwalters@0: * This was used so often, that is was moved to a macro. tomwalters@0: */ tomwalters@0: #define DELETE_ARRAY_IF_NONNULL(x) { \ tomwalters@0: if ( (x) ) { \ tomwalters@0: delete[] (x); \ tomwalters@0: (x) = NULL; \ tomwalters@0: } \ tomwalters@0: } tomwalters@0: tomwalters@0: /*! \brief C free if != NULL tomwalters@0: * tomwalters@0: * This was used so often, that is was moved to a macro. tomwalters@0: */ tomwalters@0: #define FREE_IF_NONNULL(x) { \ tomwalters@0: if ( (x) ) { \ tomwalters@0: free(x); \ tomwalters@0: (x) = NULL; \ tomwalters@0: } \ tomwalters@0: } tomwalters@0: tomwalters@0: #ifdef DEBUG tomwalters@0: # define AIM_VERIFY(x) AIM_ASSERT(x) tomwalters@0: # define AIM_ASSERT(x) { \ tomwalters@0: if (!(x)) { \ tomwalters@0: LOG_ERROR("Assertion failed.\n"); \ tomwalters@8: *(reinterpret_cast(0)) = 0; \ tomwalters@0: } \ tomwalters@0: } tomwalters@0: #else tomwalters@0: # define AIM_VERIFY(x) {x;} tomwalters@0: # define AIM_ASSERT(...) tomwalters@0: #endif tomwalters@0: tomwalters@0: namespace aimc { tomwalters@0: void LOG_ERROR(const char *sFmt, ...); tomwalters@0: void LOG_INFO(const char *sFmt, ...); tomwalters@6: void LOG_INFO_NN(const char *sFmt, ...); tomwalters@0: } // namespace aimc tomwalters@0: tomwalters@11: #endif // AIMC_SUPPORT_COMMON_H_