tomwalters@268: // Copyright 2006-2010, Thomas Walters, Willem van Engen tomwalters@268: // tomwalters@268: // AIM-C: A C++ implementation of the Auditory Image Model tomwalters@268: // http://www.acousticscale.org/AIMC tomwalters@268: // tomwalters@318: // Licensed under the Apache License, Version 2.0 (the "License"); tomwalters@318: // you may not use this file except in compliance with the License. tomwalters@318: // You may obtain a copy of the License at tomwalters@268: // tomwalters@318: // http://www.apache.org/licenses/LICENSE-2.0 tomwalters@268: // tomwalters@318: // Unless required by applicable law or agreed to in writing, software tomwalters@318: // distributed under the License is distributed on an "AS IS" BASIS, tomwalters@318: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. tomwalters@318: // See the License for the specific language governing permissions and tomwalters@318: // limitations under the License. tomwalters@268: tomwalters@268: /*! \file tomwalters@268: * \brief Common includes for all AIM-C tomwalters@268: */ tomwalters@268: tomwalters@268: /*! \author: Thomas Walters tomwalters@268: * \author: Willem van Engen tomwalters@268: * \date 2010/01/30 tomwalters@296: * \version \$Id$ tomwalters@268: */ tomwalters@268: tomwalters@283: #ifndef AIMC_SUPPORT_COMMON_H_ tomwalters@283: #define AIMC_SUPPORT_COMMON_H_ tomwalters@268: tomwalters@268: #include tomwalters@268: #include tomwalters@268: #include tomwalters@268: tomwalters@427: // Defines for windows tomwalters@427: #ifdef _WINDOWS tomwalters@427: #define M_PI 3.14159265359 tomwalters@427: #define isnan _isnan tomwalters@427: #define isinf(x) (!_finite(x)) tomwalters@427: #define snprintf _snprintf tomwalters@427: #define PATH_MAX _MAX_PATH tomwalters@427: #endif tomwalters@427: tom@400: #define AIM_NAME "AIM-C" tom@400: #define AIM_VERSION_STRING "version_number" tom@400: tomwalters@268: // A macro to disallow the copy constructor and operator= functions tomwalters@268: // This should be used in the private: declarations for a class tomwalters@268: #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ tomwalters@268: TypeName(const TypeName&); \ tomwalters@268: void operator=(const TypeName&) tomwalters@268: tomwalters@268: #if !defined(_T) tomwalters@268: # ifdef _UNICODE tomwalters@268: # define _T(x) L ## x tomwalters@268: # else tomwalters@268: # define _T(x) x tomwalters@268: # endif tomwalters@268: #endif tomwalters@268: tom@399: #if !defined(_S) tom@399: # ifdef _UNICODE tom@399: # define _S(x) L ## x tom@399: # else tom@399: # define _S(x) x tom@399: # endif tom@399: #endif tom@399: tomwalters@268: /*! \brief C++ delete if != NULL tomwalters@268: * tomwalters@268: * This was used so often, that is was moved to a macro. tomwalters@268: */ tomwalters@268: #define DELETE_IF_NONNULL(x) { \ tomwalters@268: if ( (x) ) { \ tomwalters@268: delete (x); \ tomwalters@268: (x) = NULL; \ tomwalters@268: } \ tomwalters@268: } tomwalters@268: tomwalters@268: /*! \brief C++ delete[] if != NULL tomwalters@268: * tomwalters@268: * This was used so often, that is was moved to a macro. tomwalters@268: */ tomwalters@268: #define DELETE_ARRAY_IF_NONNULL(x) { \ tomwalters@268: if ( (x) ) { \ tomwalters@268: delete[] (x); \ tomwalters@268: (x) = NULL; \ tomwalters@268: } \ tomwalters@268: } tomwalters@268: tomwalters@268: /*! \brief C free if != NULL tomwalters@268: * tomwalters@268: * This was used so often, that is was moved to a macro. tomwalters@268: */ tomwalters@268: #define FREE_IF_NONNULL(x) { \ tomwalters@268: if ( (x) ) { \ tomwalters@268: free(x); \ tomwalters@268: (x) = NULL; \ tomwalters@268: } \ tomwalters@268: } tomwalters@268: tomwalters@268: #ifdef DEBUG tomwalters@268: # define AIM_VERIFY(x) AIM_ASSERT(x) tomwalters@268: # define AIM_ASSERT(x) { \ tomwalters@268: if (!(x)) { \ tomwalters@268: LOG_ERROR("Assertion failed.\n"); \ tomwalters@280: *(reinterpret_cast(0)) = 0; \ tomwalters@268: } \ tomwalters@268: } tomwalters@268: #else tomwalters@268: # define AIM_VERIFY(x) {x;} tomwalters@268: # define AIM_ASSERT(...) tomwalters@268: #endif tomwalters@268: tomwalters@268: namespace aimc { tomwalters@268: void LOG_ERROR(const char *sFmt, ...); tomwalters@268: void LOG_INFO(const char *sFmt, ...); tomwalters@278: void LOG_INFO_NN(const char *sFmt, ...); tomwalters@268: } // namespace aimc tomwalters@268: tomwalters@283: #endif // AIMC_SUPPORT_COMMON_H_